Last active
November 8, 2015 06:44
-
-
Save Makopo/1d58c51429440da2aac7 to your computer and use it in GitHub Desktop.
It creates runnable Java application that has a .dmg extension on osx. For windows, you'll need to change <executable> path and -appclass value.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | |
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | |
<modelVersion>4.0.0</modelVersion> | |
<groupId>com.company</groupId> | |
<artifactId>Executable</artifactId> | |
<version>1.0-SNAPSHOT</version> | |
<packaging>jar</packaging> | |
<name>Create-Executable</name> | |
<properties> | |
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> | |
<mainClass>com.company.App</mainClass> | |
</properties> | |
<build> | |
<plugins> | |
<!-- https://maven.apache.org/plugins/maven-shade-plugin/examples/executable-jar.html --> | |
<plugin> | |
<groupId>org.apache.maven.plugins</groupId> | |
<artifactId>maven-shade-plugin</artifactId> | |
<version>2.4.2</version> | |
<executions> | |
<execution> | |
<phase>package</phase> | |
<goals> | |
<goal>shade</goal> | |
</goals> | |
<configuration> | |
<transformers> | |
<transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer"> | |
<mainClass>${mainClass}</mainClass> | |
</transformer> | |
</transformers> | |
</configuration> | |
</execution> | |
</executions> | |
</plugin> | |
<!-- https://dzone.com/articles/creating-executable-uber-jar’s --> | |
<plugin> | |
<groupId>org.codehaus.mojo</groupId> | |
<artifactId>exec-maven-plugin</artifactId> | |
<version>1.4.0</version> | |
<executions> | |
<execution> | |
<phase>package</phase> | |
<goals> | |
<goal>exec</goal> | |
</goals> | |
<configuration> | |
<executable> | |
${java.home}/../bin/javapackager <!-- for osx. --> | |
</executable> | |
<arguments> | |
<argument>-deploy</argument> | |
<argument>-Bruntime=${java.home}</argument> | |
<argument>-native</argument> | |
<argument>image</argument> | |
<argument>-appclass</argument> | |
<argument>${mainClass}</argument> | |
<argument>-srcfiles</argument> | |
<argument>${project.build.directory}/${artifactId}-${version}.jar</argument> | |
<argument>-outdir</argument> | |
<argument>${project.build.directory}</argument> | |
<argument>-outfile</argument> | |
<argument>${project.artifactId}-${project.version}-app</argument> | |
<argument>-v</argument> | |
</arguments> | |
</configuration> | |
</execution> | |
</executions> | |
</plugin> | |
</plugins> | |
</build> | |
</project> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment