Skip to content

Commit

Permalink
Merge pull request #13 from jperedadnr/master
Browse files Browse the repository at this point in the history
#6 Add javafx:jlink goal
  • Loading branch information
José Pereda authored Apr 25, 2019
2 parents 76b6ecb + 2c8222f commit b79541a
Show file tree
Hide file tree
Showing 4 changed files with 385 additions and 13 deletions.
95 changes: 83 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@ Maven plugin to run JavaFX 11+ applications

## Install

Clone the project, set JDK 11 and run
The plugin is available via Maven Central.

In case you want to build and install the latest snapshot, you can
clone the project, set JDK 11 and run

```
mvn install
Expand All @@ -25,7 +28,7 @@ JavaFX dependencies are added as usual:
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-controls</artifactId>
<version>11.0.2</version>
<version>12.0.1</version>
</dependency>
```

Expand All @@ -37,7 +40,7 @@ Add the plugin:
<artifactId>javafx-maven-plugin</artifactId>
<version>0.0.1</version>
<configuration>
<mainClass>org.openjfx.App</mainClass>
<mainClass>hellofx/org.openjfx.App</mainClass>
</configuration>
</plugin>
```
Expand All @@ -54,11 +57,50 @@ To run the project:
mvn javafx:run
```

### Optional arguments:
For modular projects, to create and run a custom image:

```
mvn javafx:jlink
target/image/bin/java -m hellofx/org.openjfx.App
```

The plugin includes by default: `--module-path`, `--add-modules` and `-classpath`.
### javafx:compile options

Optionally, other VM arguments and runtime arguments can be set:
Optionally, when compiling with ``javafx:compile``, the source level,
target level and/or the release level for the Java compiler can be set.
The default value is 11.

This configuration changes these levels to 12, for instance:

```
<plugin>
<groupId>org.openjfx</groupId>
<artifactId>javafx-maven-plugin</artifactId>
<version>0.0.1</version>
<configuration>
<source>12</source>
<target>12</target>
<release>12</release>
<mainClass>org.openjfx.hellofx/org.openjfx.App</mainClass>
</configuration>
</plugin>
```

### javafx:run options

The plugin includes by default: `--module-path`, `--add-modules` and `-classpath` options.

Optionally, the configuration can be modified with:

- `mainClass`: The main class, fully qualified name, with or without module name
- `workingDirectory`: The current working directory
- `skip`: Skip the execution. Values: false (default), true
- `outputFile` File to redirect the process output
- `options`: A list of VM options passed to the executable.
- `commandlineArgs`: Arguments separated by space for the executed program

For instance, the following configuration adds some VM options and a command line argument:

```
<plugin>
Expand All @@ -76,18 +118,47 @@ Optionally, other VM arguments and runtime arguments can be set:
</plugin>
```

Optionally, when compiling with ``javafx:compile``, the source level,
target level and/or the release level for the Java compiler can be set:
### javafx:jlink options

The same command line options for `jlink` can be set:

- `stripDebug`: Strips debug information out. Values: false (default) or true
- `compress`: Compression level of the resources being used. Values: 0 (default), 1, 2.
- `noHeaderFiles`: Removes the `includes` directory in the resulting runtime image. Values: false (default) or true
- `noManPages`: Removes the `man` directory in the resulting runtime image. Values: false (default) or true
- `bindServices`: Adds the option to bind services. Values: false (default) or true
- `ignoreSigningInformation`: Adds the option to ignore signing information. Values: false (default) or true
- `jlinkVerbose`: Adds the verbose option. Values: false (default) or true
- `launcher`: Adds a launcher script with the given name
- `jlinkImageName`: The name of the folder with the resulting runtime image
- `jlinkZipName`: When set, creates a zip of the resulting runtime image
- `jlinkExecutable`: The `jlink` executable. It can be a full path or the name of the executable, if it is in the PATH.


For instance, with the following configuration:

```
<plugin>
<groupId>org.openjfx</groupId>
<artifactId>javafx-maven-plugin</artifactId>
<version>0.0.1</version>
<configuration>
<source>12</source>
<target>12</target>
<release>12</release>
<mainClass>org.openjfx.hellofx/org.openjfx.App</mainClass>
<stripDebug>true</stripDebug>
<compress>2</compress>
<noHeaderFiles>true</noHeaderFiles>
<noManPages>true</noManPages>
<launcher>hellofx</launcher>
<jlinkImageName>hello</jlinkImageName>
<jlinkZipName>hellozip</jlinkZipName>
<mainClass>hellofx/org.openjfx.MainApp</mainClass>
</configuration>
</plugin>
```

a custom image can be created and run as:

```
mvn clean javafx:jlink
target/hello/bin/hellofx
```
5 changes: 5 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,11 @@
<artifactId>plexus-java</artifactId>
<version>0.9.11</version>
</dependency>
<dependency>
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-archiver</artifactId>
<version>3.6.0</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-exec</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/openjfx/JavaFXBaseMojo.java
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ abstract class JavaFXBaseMojo extends AbstractMojo {
/**
* The current working directory. Optional. If not specified, basedir will be used.
*/
@Parameter(property = "javafx.workingdir")
@Parameter(property = "javafx.workingDirectory")
File workingDirectory;

@Parameter(defaultValue = "${project.compileClasspathElements}", readonly = true, required = true)
Expand Down
Loading

0 comments on commit b79541a

Please sign in to comment.