Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 13 additions & 29 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ Add the following `plugin` tag to your `pom.xml`:
<plugin>
<groupId>io.github.fvarrui</groupId>
<artifactId>javapackager</artifactId>
<version>1.7.0</version>
<version>1.7.0-SNAPSHOT</version>
<executions>
<execution>
<phase>package</phase>
Expand Down Expand Up @@ -88,17 +88,15 @@ apply plugin: 'io.github.fvarrui.javapackager.plugin'
Create your packaging task:

```groovy
task packageMyApp(type: io.github.fvarrui.javapackager.GradlePackageTask, dependsOn: build) {
javapackager{
// mandatory
mainClass = 'path.to.your.mainClass'
// optional
bundleJre = true|false
generateInstaller = true|false
administratorRequired = true|false
platform = auto|linux|mac|windows
additionalResources = [ file('file path'), file('folder path'), ... ]
}
task packageMyApp(type: io.github.fvarrui.javapackager.gradle.PackageTask, dependsOn: build) {
// mandatory
mainClass = 'path.to.your.mainClass'
// optional
bundleJre = true|false
generateInstaller = true|false
administratorRequired = true|false
platform = auto|linux|mac|windows
additionalResources = [ file('file path'), file('folder path'), ... ]
linuxConfig {
...
}
Expand All @@ -108,12 +106,6 @@ task packageMyApp(type: io.github.fvarrui.javapackager.GradlePackageTask, depend
winConfig {
...
}
manifest {
....
}
scripts {
...
}
...
}
```
Expand All @@ -126,10 +118,6 @@ And execute the next command in project's root folder:
gradle packageMyApp
```

### Package your app via CI

- **GitHub:** You can find an example workflow file [here](https://github.com/fvarrui/JavaPackager/blob/pr-248/test/hello-world-maven/.github/workflows/package.yml).

### Generated artifacts

By default it will generate next artifacts in `${outputDirectory} ` folder:
Expand Down Expand Up @@ -173,25 +161,21 @@ By default it will generate next artifacts in `${outputDirectory} ` folder:
| `extra` | :x: | | Map with extra properties to be used in customized Velocity templates, accesible through `$info.extra` variable. |
| `fileAssociations` | :x: | [`FileAssociation[]`](https://github.com/fvarrui/JavaPackager/blob/master/src/main/java/io/github/fvarrui/javapackager/model/FileAssociation.java) | Associate file extensions or MIME types to the app. |
| `forceInstaller` | :x: | `false` | If `true`, skips operating system check when generating installers. |
| `nativeImage` | :x: | `false` | If `true`, generates a native image for the current operating system. Note that `jdkVendor` must be set to `graalvm` for this to work. |
| `sharedLibrary` | :x: | `false` | If `true`, generates a shared library for the current operating system. Note that `jdkVendor` must be set to `graalvm` for this to work. |
| `generateInstaller` | :x: | `true` | Generates an installer for the app. |
| `jdkVersion` | :x: | `latest` | JDK version to download and use. The latest version is used by default. See all available versions here: [adoptium](https://api.adoptium.net/v3/info/available_releases). |
| `jdkVendor` | :x: | `graalvm` | JDK vendor to download the JDK from. Currently supported: `adoptium, graalvm` |
| `jdkPath` | :x: | `null` | If null downloads (if necessary and also updates it if needed) the right JDK for the selected platform and sets this value to `<temp-dir>/jdk/win` or `<temp-dir>/jdk/linux` or `<temp-dir>/jdk/mac`. The downloaded JDK will be used to generate a customized JRE. |
| `jdkPath` | :x: | `${java.home}` | JDK used to generate a customized JRE. It allows to bundle customized JREs for different platforms. |
| `jreDirectoryName` | :x: | `"jre"` | Bundled JRE directory name. |
| `jreMinVersion` | :x: | | JRE minimum version. If an appropriate version cannot be found display error message. Disabled if a JRE is bundled. |
| `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. |
| `licenseFile` | :x: | `${project.licenses[0].url}` or `${basedir}/LICENSE` or `${projectdir}/LICENSE` | Path to project license file. |
| `mainClass` | :heavy_check_mark: | `${exec.mainClass}` | Full path to your app main class. |
| `manifest` | :x: | | [Allows adding additional entries to MANIFEST.MF file.](docs/manifest.md) |
| `modules` | :x: | `[]` | Modules to customize the bundled JRE. Don't use `jdeps` to get module dependencies. |
| `appName` | :x: | `${project.name}` or `${project.artifactId}` | App name. |
| `name` | :x: | `${project.name}` or `${project.artifactId}` | App name. |
| `organizationName` | :x: | `${project.organization.name}` or `"ACME"` | Organization name. |
| `organizationUrl` | :x: | `${project.organization.url}` | Organization website URL. |
| `organizationEmail` | :x: | | Organization email. |
| `outputDirectory` | :x: | `${project.build.directory}` or `${project.builddir}` | Output directory (where the artifacts will be generated). |
| `packagingJdk` | :x: | `null` or same as `jdkPath` | JDK used in the execution of `jlink` and other JDK tools. If null `jdkPath` will be used. |
| `packagingJdk` | :x: | `${java.home}` | JDK used in the execution of `jlink` and other JDK tools. |
| `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. |
| `runnableJar` | :x: | | 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. |
| `scripts` | :x: | | Specify bootstrap script. **Pre and post-install scripts comming soon!** |
Expand Down
19 changes: 5 additions & 14 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ plugins {
repositories {
mavenLocal()
mavenCentral()
maven {
maven {
url 'https://plugins.gradle.org/m2/'
}
}
Expand Down Expand Up @@ -55,31 +55,22 @@ dependencies {
implementation 'net.jsign:jsign-core:3.1'
implementation 'org.redline-rpm:redline:1.2.10'
implementation 'io.github.fvarrui:launch4j:2.5.2'
implementation 'com.google.code.gson:gson:2.9.0'
implementation 'com.squareup.okhttp3:okhttp:4.10.0'
implementation 'org.rauschig:jarchivelib:1.2.0'
implementation 'com.squareup:javapoet:1.13.0'

testImplementation 'org.junit.jupiter:junit-jupiter:5.9.0'
testImplementation 'org.apache.maven.shared:maven-invoker:3.2.0'
testImplementation 'junit:junit:4.13.1'

compileOnly 'org.apache.maven.plugin-tools:maven-plugin-annotations:3.6.0'

mavenEmbedder 'org.apache.maven:maven-embedder:3.6.0'
mavenEmbedder 'org.apache.maven:maven-compat:3.6.0'
mavenEmbedder 'org.apache.maven:maven-compat:3.6.0'
mavenEmbedder 'org.slf4j:slf4j-simple:1.7.30'
mavenEmbedder 'org.eclipse.aether:aether-connector-basic:1.1.0'
mavenEmbedder 'org.eclipse.aether:aether-transport-wagon:1.1.0'
mavenEmbedder 'org.apache.maven.wagon:wagon-http:3.4.1'
mavenEmbedder 'org.apache.maven.wagon:wagon-provider-api:3.4.1'
}

test {
useJUnitPlatform()
}

group = 'io.github.fvarrui'
version = '1.7.0'
version = '1.7.0-SNAPSHOT'
description = 'Hybrid Maven/Gradle plugin to package Java applications as native Windows, Mac OS X or GNU/Linux executables and create installers for them'

sourceCompatibility = JavaVersion.VERSION_1_8
Expand All @@ -97,7 +88,7 @@ publishing {

java {
withSourcesJar()
// and/or analogously use "withJavadocJar()" to get a "javadocJar" task
// and/or analogously use “withJavadocJar()� to get a “javadocJar� task
}

install.repositories.mavenInstaller.pom.with {
Expand Down
92 changes: 38 additions & 54 deletions docs/gradle/plugin-configuration-samples.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,8 @@
Add next task to your `build.gradle` file:

```groovy
task packageMyApp(type: io.github.fvarrui.javapackager.GradlePackageTask, dependsOn: build) {
javapackager{
mainClass = 'fvarrui.sample.Main'
}
task packageMyApp(type: io.github.fvarrui.javapackager.gradle.PackageTask, dependsOn: build) {
mainClass = 'fvarrui.sample.Main'
}
```

Expand All @@ -32,11 +30,9 @@ And run `gradle package`.
## Bundle with a customized JRE

```groovy
task packageMyApp(type: io.github.fvarrui.javapackager.GradlePackageTask, dependsOn: build) {
javapackager{
mainClass = 'fvarrui.sample.Main'
bundleJre = true
}
task packageMyApp(type: io.github.fvarrui.javapackager.gradle.PackageTask, dependsOn: build) {
mainClass = 'fvarrui.sample.Main'
bundleJre = true
}
```

Expand All @@ -45,37 +41,31 @@ task packageMyApp(type: io.github.fvarrui.javapackager.GradlePackageTask, depend
## Bundle with a full JRE

```groovy
task packageMyApp(type: io.github.fvarrui.javapackager.GradlePackageTask, dependsOn: build) {
javapackager{
mainClass = 'fvarrui.sample.Main'
bundleJre = true
customizedJre = false
}
task packageMyApp(type: io.github.fvarrui.javapackager.gradle.PackageTask, dependsOn: build) {
mainClass = 'fvarrui.sample.Main'
bundleJre = true
customizedJre = false
}
```

## Bundle with an existing JRE

```groovy
task packageMyApp(type: io.github.fvarrui.javapackager.GradlePackageTask, dependsOn: build) {
javapackager{
mainClass = 'fvarrui.sample.Main'
bundleJre = true
jrePath = file('C:\Program Files\Java\jre1.8.0_231')
}
task packageMyApp(type: io.github.fvarrui.javapackager.gradle.PackageTask, dependsOn: build) {
mainClass = 'fvarrui.sample.Main'
bundleJre = true
jrePath = file('C:\Program Files\Java\jre1.8.0_231')
}
```

## Bundle your own fat JAR

```groovy
task packageMyApp(type: io.github.fvarrui.javapackager.GradlePackageTask, dependsOn: build) {
javapackager{
mainClass = 'fvarrui.sample.Main'
bundleJre = true
runnableJar = file('path/to/your/own/fat.jar')
copyDependencies = false
}
task packageMyApp(type: io.github.fvarrui.javapackager.gradle.PackageTask, dependsOn: build) {
mainClass = 'fvarrui.sample.Main'
bundleJre = true
runnableJar = file('path/to/your/own/fat.jar')
copyDependencies = false
}
```

Expand All @@ -86,17 +76,13 @@ javapackager {
// common configuration
mainClass = 'fvarrui.sample.Main'
}
task packageMyAppWithJRE(type: io.github.fvarrui.javapackager.GradlePackageTask, dependsOn: build) {
javapackager{
name = 'Sample'
bundleJre = true
}
task packageMyAppWithJRE(type: io.github.fvarrui.javapackager.gradle.PackageTask, dependsOn: build) {
name = 'Sample'
bundleJre = true
}
task packageMyAppWithoutJRE(type: io.github.fvarrui.javapackager.GradlePackageTask, dependsOn: build) {
javapackager{
name = 'Sample-nojre'
bundleJre = false
}
task packageMyAppWithoutJRE(type: io.github.fvarrui.javapackager.gradle.PackageTask, dependsOn: build) {
name = 'Sample-nojre'
bundleJre = false
}
task packageMyApp(dependsOn: [ 'packageMyAppWithJRE', 'packageMyAppWithoutJRE' ])
```
Expand All @@ -114,23 +100,19 @@ javapackager {
bundleJre = true
generateInstaller = false
}
task packageMyAppForLinux(type: io.github.fvarrui.javapackager.GradlePackageTask, dependsOn: build) {
javapackager{
platform = linux
createTarball = true
}
task packageMyAppForLinux(type: io.github.fvarrui.javapackager.gradle.PackageTask, dependsOn: build) {
platform = linux
createTarball = true
jdkPath = file('X:\\path\to\linux\jdk')
}
task packageMyAppForMac(type: io.github.fvarrui.javapackager.GradlePackageTask, dependsOn: build) {
javapackager{
platform = mac
createTarball = true
}
task packageMyAppForMac(type: io.github.fvarrui.javapackager.gradle.PackageTask, dependsOn: build) {
platform = mac
createTarball = true
jdkPath = file('X:\\path\to\mac\jdk')
}
task packageMyAppForWindows(type: io.github.fvarrui.javapackager.GradlePackageTask, dependsOn: build) {
javapackager{
platform = windows
createZipball = true
}
task packageMyAppForWindows(type: io.github.fvarrui.javapackager.gradle.PackageTask, dependsOn: build) {
platform = windows
createZipball = true
}
task packageMyApp(dependsOn: [ 'packageMyAppForLinux', 'packageMyAppForMac', 'packageMyAppForWindows' ])
```
Expand All @@ -139,4 +121,6 @@ E.g. on Windows, running `packageMyApp` task will generate next artifacts:

* `${name}_${version}-linux.tar.gz` with the GNU/Linux application including a customized JRE.
* `${name}_${version}-mac.tar.gz` with the Mac OS X application including a customized JRE.
* `${name}_${version}-windows.zip` with the Windows application including a customized JRE.
* `${name}_${version}-windows.zip` with the Windows application including a customized JRE.

As last sample is running on Windows, it's not necessary to specify a JDK when bundling for Windows (it uses current JDK by default). Otherwise, if running on GNU/Linux or Mac OS X, you have to specify a JDK for Windows.
Loading