22
33[ ![ Maven Central] ( https://maven-badges.herokuapp.com/maven-central/io.github.fvarrui/javapackager/badge.svg )] ( https://maven-badges.herokuapp.com/maven-central/io.github.fvarrui/javapackager )
44
5- JavaPackager is a Maven plugin which provides an easy way to package Java applications in native Windows, Mac OS X, or GNU/Linux executables, and generates installers for them.
5+ JavaPackager is a hybrid plugin for ** Maven ** and ** Gradle ** which provides an easy way to package Java applications in native Windows, Mac OS X or GNU/Linux executables, and generates installers for them.
66
7- > SNAPSHOT versions are not released to Maven Central, so you have to [ install them manually] ( #how-to-build-and-install-the-plugin ) .
7+ > SNAPSHOT version are not released to Maven Central, so you have to [ install them manually] ( #how-to-build-and-install-the-plugin ) .
8+
9+ > :eyes : See [ JavaPackager changes and fixes] ( https://github.com/fvarrui/JavaPackager/releases ) .
810
911## How to use this plugin
1012
11- ### Config your project
13+ ### Config your project and package your app with Maven
1214
1315Add the following ` plugin ` tag to your ` pom.xml ` :
1416
1517``` xml
1618<plugin >
17- <groupId >io.github.fvarrui</groupId >
18- <artifactId >javapackager</artifactId >
19- <version >1.1.0|1.2.0-SNAPSHOT</version >
20- <executions >
21- <execution >
22- <phase >package</phase >
23- <goals >
24- <goal >package</goal >
25- </goals >
26- <configuration >
27- <!-- mandatory -->
28- <mainClass >path.to.your.mainClass</mainClass >
29- <!-- optional -->
30- <bundleJre >true|false</bundleJre >
31- <generateInstaller >true|false</generateInstaller >
32- <administratorRequired >true|false</administratorRequired >
33- <platform >auto|linux|mac|windows</platform >
34- <additionalResources >
35- <additionalResource >file path</additionalResource >
36- <additionalResource >folder path</additionalResource >
37- <additionalResource >...</additionalResource >
38- </additionalResources >
39- <linuxConfig >...</linuxConfig >
40- <macConfig >...</macConfig >
41- <winConfig >...</winConfig >
42- [...]
43- </configuration >
44- </execution >
45- </executions >
19+ <groupId >io.github.fvarrui</groupId >
20+ <artifactId >javapackager</artifactId >
21+ <version >1.2.0</version >
22+ <executions >
23+ <execution >
24+ <phase >package</phase >
25+ <goals >
26+ <goal >package</goal >
27+ </goals >
28+ <configuration >
29+ <!-- mandatory -->
30+ <mainClass >path.to.your.mainClass</mainClass >
31+ <!-- optional -->
32+ <bundleJre >true|false</bundleJre >
33+ <generateInstaller >true|false</generateInstaller > <administratorRequired >true|false</administratorRequired >
34+ <platform >auto|linux|mac|windows</platform >
35+ <additionalResources >
36+ <additionalResource >file path</additionalResource >
37+ <additionalResource >folder path</additionalResource >
38+ <additionalResource >...</additionalResource >
39+ </additionalResources >
40+ <linuxConfig >...</linuxConfig >
41+ <macConfig >...</macConfig >
42+ <winConfig >...</winConfig >
43+ [...]
44+ </configuration >
45+ </execution >
46+ </executions >
4647</plugin >
4748```
4849
49- > See [ plugin configuration samples] ( docs/plugin-configuration-samples.md ) to know more.
50-
51- ### Package your app
50+ > See [ Maven plugin configuration samples] ( docs/maven-plugin-configuration-samples.md ) to know more.
5251
53- Execute the next command in project's root folder:
52+ And execute the next command in project's root folder:
5453
5554``` bash
5655mvn package
5756```
5857
59- And by default it will generate next artifacts in ` target ` folder:
58+ ### Config your project and package your app with Gradle
59+
60+ Apply JavaPackager plugin in ` build.gradle ` using legacy mode (because at the moment it's only available in Maven Central repository):
61+
62+ ``` groovy
63+ buildscript {
64+ repositories {
65+ mavenCentral()
66+ }
67+ dependencies {
68+ classpath 'io.github.fvarrui:javapackager:1.2.0'
69+ }
70+ }
71+
72+ apply plugin: 'io.github.fvarrui.javapackager.plugin'
73+ ```
74+
75+ Create your packaging task:
76+
77+ ``` groovy
78+ task packageMyApp(type: io.github.fvarrui.javapackager.gradle.PackageTask, dependsOn: build) {
79+ // mandatory
80+ mainClass = 'path.to.your.mainClass'
81+ // optional
82+ bundleJre = true|false
83+ generateInstaller = true|false
84+ administratorRequired = true|false
85+ platform = auto|linux|mac|windows
86+ additionalResources = [ file('file path'), file('folder path'), ... ]
87+ linuxConfig {
88+ ...
89+ }
90+ macConfig {
91+ ...
92+ }
93+ winConfig {
94+ ...
95+ }
96+ ...
97+ }
98+ ```
99+
100+ > See [ Gradle plugin configuration samples] ( docs/gradle-plugin-configuration-samples.md ) to know more.
101+
102+ And execute the next command in project's root folder:
103+
104+ ``` bash
105+ gradle packageMyApp
106+ ```
107+
108+ ### Generated artifacts
109+
110+ By default it will generate next artifacts in ` ${outputDirectory} ` folder:
60111
61112| Artifact | Description |
62113| --------------------------------------- | ------------------------------------------------------------ |
@@ -69,19 +120,20 @@ And by default it will generate next artifacts in `target ` folder:
69120| ` ${name}_${version}.dmg ` | Disk image file if it's executed on Mac OS X (requires ** hdiutil** ). |
70121| ` ${name}_${version}.pkg ` | PKG installer file if it's executed on Mac OS X (requires ** pkgbuild** ) |
71122| ` ${name}-${version}-${platform}.zip ` | Zipball containing generated directory ` ${name} ` . |
72- | ` ${name}-${version}-${platform}.tar ` | Tarball containing generated directory ` ${name} ` . |
73123| ` ${name}-${version}-${platform}.tar.gz ` | Compressed tarball containing generated directory ` ${name} ` . |
74124
75125> :warning : Installers generation will be ommited if target platform is different from current platform (see ` platform ` property).
76126
127+ > :warning : ** DEB and RPM package generation in Gradle is not yet available. Coming soon!**
128+
77129### Plugin configutation properties
78130
79131| Property | Mandatory | Default value | Description |
80132| -------------------------- | ------------------ | ------------------------------------------------------------ | ------------------------------------------------------------ |
81133| ` additionalModules ` | :x : | ` [] ` | Additional modules to the ones identified by ` jdeps ` or the specified with ` modules ` property. |
82134| ` additionalResources ` | :x : | ` [] ` | Additional files and folders to include in the bundled app. |
83135| ` administratorRequired ` | :x : | ` false ` | App will run as administrator (with elevated privileges). |
84- | ` assetsDir ` | :x : | ` ${basedir}/assets ` | Assets location (icons and custom Velocity templates). |
136+ | ` assetsDir ` | :x : | ` ${basedir}/assets ` or ` ${projectdir}/assets ` | Assets location (icons and custom Velocity templates). |
85137| ` bundleJre ` | :x : | ` false ` | Embeds a customized JRE with the app. |
86138| ` copyDependencies ` | :x : | ` true ` | Bundles all dependencies (JAR files) with the app. |
87139| ` createTarball ` | :x : | ` false ` | Bundles app folder in tarball. |
@@ -96,20 +148,23 @@ And by default it will generate next artifacts in `target ` folder:
96148| ` jdkPath ` | :x : | ` ${java.home} ` | JDK used to generate a customized JRE. It allows to bundle customized JREs for different platforms. |
97149| ` jreDirectoryName ` | :x : | ` "jre" ` | Bundled JRE directory name. |
98150| ` jrePath ` | :x : | ` "" ` | Path to JRE folder. If specified, it will bundle this JRE with the app, and won't generate a customized JRE. For Java 8 version or least. |
99- | ` licenseFile ` | :x : | ` ${project.licenses[0].url} ` or ` ${project. basedir}/LICENSE ` | Path to project license file. |
151+ | ` licenseFile ` | :x : | ` ${project.licenses[0].url} ` or ` ${basedir}/LICENSE ` or ` ${projectdir }/LICENSE` | Path to project license file. |
100152| ` mainClass ` | :heavy_check_mark : | ` ${exec.mainClass} ` | Full path to your app main class. |
101153| ` modules ` | :x : | ` [] ` | Defines modules to customize the bundled JRE. Don't use ` jdeps ` to get module dependencies. |
102154| ` name ` | :x : | ` ${project.name} ` or ` ${project.artifactId} ` | App name. |
103155| ` organizationName ` | :x : | ` ${project.organization.name} ` or ` "ACME" ` | Organization name. |
104156| ` organizationUrl ` | :x : | ` ${project.organization.url} ` | Organization website URL. |
105157| ` organizationEmail ` | :x : | ` null ` | Organization email. |
158+ | ` outputDirectory ` | :x : | ` ${project.build.directory} ` or ` ${project.builddir} ` | Output directory (where the artifacts will be generated). |
106159| ` platform ` | :x : | ` auto ` | Defines the target platform, which could be different to the execution platform. Possible values: ` auto ` , ` mac ` , ` linux ` , ` windows ` . Use ` auto ` for using execution platform as target. |
107160| ` runnableJar ` | :x : | ` null ` | Defines your own JAR file to be bundled. If it's ommited, the plugin packages your code in a runnable JAR and bundle it with the app. |
108161| ` url ` | :x : | ` null ` | App website URL. |
109162| ` useResourcesAsWorkingDir ` | :x : | ` true ` | Uses app resources folder as default working directory. |
110163| ` version ` | :x : | ` ${project.version} ` | Project version. |
111164| ` vmArgs ` | :x : | ` [] ` | Adds VM arguments. |
112165
166+ > Some default values depends on the used building tool.
167+
113168** Platform specific properties**
114169
115170| Property | Mandatory | Default | Description |
@@ -160,18 +215,20 @@ It is possible to use your own customized templates. You just have to put one of
160215```
161216${assetsDir}/
162217├── linux/
163- | ├── control.vtl # DEB control template
164- | ├── desktop.vtl # Desktop template
165- │ └── startup.sh.vtl # Startup script template
218+ | ├── assembly.xml.vtl # maven-assembly-plugin template to generate ZIP/TGZ bundles for GNU/Linux
219+ | ├── control.vtl # DEB control template
220+ | ├── desktop.vtl # Desktop template
221+ │ └── startup.sh.vtl # Startup script template
166222├── mac/
167- | ├── customize-dmg.applescript.vtl # DMG customization Applescript template
168- | ├── Info.plist.vtl # Info.plist template
169- │ └── startup.vtl # Startup script template
170- ├── windows/
171- | ├── exe.manifest.vtl # exe.manifest template
172- | ├── iss.vtl # Inno Setup Script template
173- │ └── wxs.vtl # WiX Toolset WXS template
174- └── assembly.xml.vtl # maven-assembly-plugin template used to generate ZIP/TGZ bundles
223+ | ├── assembly.xml.vtl # maven-assembly-plugin template to generate ZIP/TGZ bundles for Mac OS X
224+ | ├── customize-dmg.applescript.vtl # DMG customization Applescript template
225+ | ├── Info.plist.vtl # Info.plist template
226+ │ └── startup.vtl # Startup script template
227+ └── windows/
228+ ├── assembly.xml.vtl # maven-assembly-plugin template to generate ZIP/TGZ bundles for Windows
229+ ├── exe.manifest.vtl # exe.manifest template
230+ ├── iss.vtl # Inno Setup Script template
231+ └── wxs.vtl # WiX Toolset WXS template
175232```
176233
177234> Use [ default templates] ( https://github.com/fvarrui/JavaPackager/tree/master/src/main/resources ) as examples.
@@ -194,25 +251,42 @@ cd JavaPackager
1942512 . Compile, package and install the plugin in your local repository (ommit ` ./ ` on Windows):
195252
196253``` bash
197- ./gradlew clean build publishToMavenLocal
254+ ./gradlew publishToMavenLocal
198255```
199256
200257## How to release the plugin to Maven Central
201258
202259Run next command after [ build and publish the plugin locally] ( #how-to-build-and-install-the-plugin ) (ommit ` ./ ` on Windows):
203260
204261``` bash
205- ./gradlew -Prelease uploadArchives closeAndPromoteRepository
262+ ./gradlew -Prelease uploadArchives closeAndReleaseRepository
206263```
207264
208265> Related [ guide] ( https://nemerosa.ghost.io/2015/07/01/publishing-to-the-maven-central-using-gradle/ ) .
209266
267+ ## How to release the plugin to Gradle plugin portal
268+
269+ First time, you have to run next command:
270+
271+ ``` bash
272+ ./gradlew login
273+ ```
274+
275+ Run next command after [ build and publish the plugin locally] ( #how-to-build-and-install-the-plugin ) (ommit ` ./ ` on Windows):
276+
277+ ``` bash
278+ ./gradlew publishPlugins
279+ ```
280+
281+ > Related [ guide] ( https://plugins.gradle.org/docs/submit ) .
282+
210283## Future features
211284
212285Check the [ TO-DO list] ( https://github.com/fvarrui/JavaPackager/projects/1#column-7704117 ) to know the features we plan to add to JavaPackager.
213286
214287## Older documentation
215288
289+ - [ v1.1.0] ( https://github.com/fvarrui/JavaPackager/blob/v1.1.0/README.md )
216290- [ v1.0.3] ( https://github.com/fvarrui/JavaPackager/blob/v1.0.3/README.md )
217291- [ v1.0.2] ( https://github.com/fvarrui/JavaPackager/blob/v1.0.2/README.md )
218292- [ v1.0.1] ( https://github.com/fvarrui/JavaPackager/blob/v1.0.1/README.md )
0 commit comments