Skip to content

Commit

Permalink
Merge pull request #45 from OntoUML/maven-fixes
Browse files Browse the repository at this point in the history
Maven fixes
  • Loading branch information
victorviola authored Apr 18, 2020
2 parents c8a80c8 + 6aacf91 commit ca9dffb
Show file tree
Hide file tree
Showing 63 changed files with 991 additions and 400 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,5 @@ repo/
.idea/
*.iml
ontouml-vp-plugin.zip

.java-version
117 changes: 117 additions & 0 deletions .mvn/wrapper/MavenWrapperDownloader.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
/*
* Copyright 2007-present the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import java.net.*;
import java.io.*;
import java.nio.channels.*;
import java.util.Properties;

public class MavenWrapperDownloader {

private static final String WRAPPER_VERSION = "0.5.6";
/**
* Default URL to download the maven-wrapper.jar from, if no 'downloadUrl' is provided.
*/
private static final String DEFAULT_DOWNLOAD_URL = "https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/"
+ WRAPPER_VERSION + "/maven-wrapper-" + WRAPPER_VERSION + ".jar";

/**
* Path to the maven-wrapper.properties file, which might contain a downloadUrl property to
* use instead of the default one.
*/
private static final String MAVEN_WRAPPER_PROPERTIES_PATH =
".mvn/wrapper/maven-wrapper.properties";

/**
* Path where the maven-wrapper.jar will be saved to.
*/
private static final String MAVEN_WRAPPER_JAR_PATH =
".mvn/wrapper/maven-wrapper.jar";

/**
* Name of the property which should be used to override the default download url for the wrapper.
*/
private static final String PROPERTY_NAME_WRAPPER_URL = "wrapperUrl";

public static void main(String args[]) {
System.out.println("- Downloader started");
File baseDirectory = new File(args[0]);
System.out.println("- Using base directory: " + baseDirectory.getAbsolutePath());

// If the maven-wrapper.properties exists, read it and check if it contains a custom
// wrapperUrl parameter.
File mavenWrapperPropertyFile = new File(baseDirectory, MAVEN_WRAPPER_PROPERTIES_PATH);
String url = DEFAULT_DOWNLOAD_URL;
if(mavenWrapperPropertyFile.exists()) {
FileInputStream mavenWrapperPropertyFileInputStream = null;
try {
mavenWrapperPropertyFileInputStream = new FileInputStream(mavenWrapperPropertyFile);
Properties mavenWrapperProperties = new Properties();
mavenWrapperProperties.load(mavenWrapperPropertyFileInputStream);
url = mavenWrapperProperties.getProperty(PROPERTY_NAME_WRAPPER_URL, url);
} catch (IOException e) {
System.out.println("- ERROR loading '" + MAVEN_WRAPPER_PROPERTIES_PATH + "'");
} finally {
try {
if(mavenWrapperPropertyFileInputStream != null) {
mavenWrapperPropertyFileInputStream.close();
}
} catch (IOException e) {
// Ignore ...
}
}
}
System.out.println("- Downloading from: " + url);

File outputFile = new File(baseDirectory.getAbsolutePath(), MAVEN_WRAPPER_JAR_PATH);
if(!outputFile.getParentFile().exists()) {
if(!outputFile.getParentFile().mkdirs()) {
System.out.println(
"- ERROR creating output directory '" + outputFile.getParentFile().getAbsolutePath() + "'");
}
}
System.out.println("- Downloading to: " + outputFile.getAbsolutePath());
try {
downloadFileFromURL(url, outputFile);
System.out.println("Done");
System.exit(0);
} catch (Throwable e) {
System.out.println("- Error downloading");
e.printStackTrace();
System.exit(1);
}
}

private static void downloadFileFromURL(String urlString, File destination) throws Exception {
if (System.getenv("MVNW_USERNAME") != null && System.getenv("MVNW_PASSWORD") != null) {
String username = System.getenv("MVNW_USERNAME");
char[] password = System.getenv("MVNW_PASSWORD").toCharArray();
Authenticator.setDefault(new Authenticator() {
@Override
protected PasswordAuthentication getPasswordAuthentication() {
return new PasswordAuthentication(username, password);
}
});
}
URL website = new URL(urlString);
ReadableByteChannel rbc;
rbc = Channels.newChannel(website.openStream());
FileOutputStream fos = new FileOutputStream(destination);
fos.getChannel().transferFrom(rbc, 0, Long.MAX_VALUE);
fos.close();
rbc.close();
}

}
Binary file added .mvn/wrapper/maven-wrapper.jar
Binary file not shown.
2 changes: 2 additions & 0 deletions .mvn/wrapper/maven-wrapper.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.6.3/apache-maven-3.6.3-bin.zip
wrapperUrl=https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar
104 changes: 87 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,34 +10,104 @@ If you are interested to know more, feel free to open an issue to provide feedba
* [Lucas Bassetti](https://github.com/LucasBassetti)
* [Victor Viola](https://github.com/victorviola)

## Installation Instructions
## User Instructions

To install the **OntoUML Plugin for Visual Paradigm**, please go to our [releases page](https://github.com/OntoUML/ontouml-vp-plugin/releases).

## Development Instructions
## Developer Instructions

### Requirements

Requirements:
* [Visual Paradigm](https://www.visual-paradigm.com/)
* [Maven](https://maven.apache.org/)
* Java 8 or later
* Maven (optional, a Maven Wrapper is embedded in the project)

### Build instructions

#### Setting up

1. Clone the project

`git clone https://github.com/OntoUML/ontouml-vp-plugin.git`


2. Open `pom.xml` and set the value of the variables listed below:

2.1. Set the path to the folder in which the Visual Paradigm application is located:

```xml
<visualparadigm.app.dir>
/Applications/Visual Paradigm.app/Contents/Resources/app
</visualparadigm.app.dir>
```

This path is typically:

- On Windows: `C:\Program Files\Visual Paradigm CE 16.1`
- On macOS: `/Applications/Visual Paradigm.app/Contents/Resources/app/`

2.2. Set the path to Visual Paradigm's plugin folder

```xml
<visualparadigm.plugin.dir>
/Users/<YOUR_USERNAME>/Library/Application Support/VisualParadigm/plugins
</visualparadigm.plugin.dir>
```

This path is typically:

- On Linux: `~/.config/VisualParadigm/plugins/`
- On Windows: `C:\Users\<YOUR_USER_NAME>\AppData\Roaming\VisualParadigm\plugins\`
- On macOS: `/Users/<YOUR_USERNAME>/Library/Application Support/VisualParadigm/plugins/`

#### Maven Commands

The commands listed below invoke Maven through the Maven Wrapper.
On Windows, replace `./mvnw` for `./mvnw.cmd`

In any OS, to invoke your local Maven installation instead of the wrapper, replace `./mvnw` with `mvn`.

* To **compile** the plugin, run:

```shell script
$ ./mvnw compile
```

The compiled files will be created in the `target` folder.

Build instructions:
* Clone this project within Visual Paradigm's `plugins` folder, typically:
* `~/.config/VisualParadigm/plugins/` in **Linux**
* `C:\Users\<YOUR_USER_NAME>\AppData\Roaming\VisualParadigm\plugins\` in **Windows**
* `~/Library/Application Support/VisualParadigm/plugins/` in **macOS**
* To **compile** and **package** the plugin, run

```git clone https://github.com/OntoUML/ontouml-vp-plugin.git```
```shell script
$ ./mvnw package
```

This command will create, within the `target` folder, a `*.zip` file that can be distributed to the end users of the plugin.

* To import necessary Visual Paradigm dependencies, run the `initialization` command passing the path to your Visual Paradigm installation `VISUAL_PARADIGM_PATH`
* `VISUAL_PARADIGM_PATH` in **macOS** is typically `/Applications/Visual\ Paradigm.app/Contents/Resources/app/`
* To **compile**, **package**, and **install** the plugin, run

```mvn initialize -Dvisualparadigm.app.dir=VISUAL_PARADIGM_PATH```
```shell script
$ ./mvnw install
```

In addition to the previous results, this command will copy the compiled files to Visual Paradigm's `plugins` folder.

* To compile your source, run
* To **run** Visual Paradigm while being able to see the output in the command line, run:

```mvn compile -Dvisualparadigm.app.dir=VISUAL_PARADIGM_PATH```
```shell script
$ ./mvnw exec:exec
```

Note that before running this command, you should install the plugin. That can be achieved by running:

```shell script
$ ./mvnw install exec:exec
```

* To **clean** the built files, run:

* To generate an ZIP plugin installation, run
```shell script
$ ./mvnw clean
```

This does not remove the installed files, just the `target` folder and its contents.

```mvn package -Dvisualparadigm.app.dir=VISUAL_PARADIGM_PATH```
12 changes: 1 addition & 11 deletions assembly.xml → assembly/assembly.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,8 @@
<includeBaseDirectory>false</includeBaseDirectory>
<fileSets>
<fileSet>
<directory>${project.basedir}/classes</directory>
<directory>${project.build.directory}/classes</directory>
<outputDirectory>./</outputDirectory>
</fileSet>
<fileSet>
<directory>${project.basedir}/icons</directory>
<outputDirectory>./icons/</outputDirectory>
</fileSet>
</fileSets>
<files>
<file>
<source>${project.basedir}/plugin.xml</source>
<outputDirectory>./</outputDirectory>
</file>
</files>
</assembly>
Loading

0 comments on commit ca9dffb

Please sign in to comment.