Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
59 commits
Select commit Hold shift + click to select a range
edd95e5
Update README.md
fvarrui Jul 19, 2022
77ab94b
unified gradle and maven configs so that only one file needs to be ch…
Osiris-Team Aug 1, 2022
053c222
cleanup imports
Osiris-Team Aug 1, 2022
bc9e475
removed redundant PackagePluginExtension that was replaced with Gradl…
Osiris-Team Aug 1, 2022
4ead00e
added java updater
Osiris-Team Aug 1, 2022
b81460e
buildId
Osiris-Team Aug 1, 2022
114b5e3
added check for java vendor
Osiris-Team Aug 2, 2022
fea9507
readme
Osiris-Team Aug 2, 2022
bca30f0
reset stuff I don't understand
Osiris-Team Aug 2, 2022
b5057d0
added new settings
Osiris-Team Aug 2, 2022
644b44c
moved defaults to right place
Osiris-Team Aug 2, 2022
a1a42c9
added test and fix jdk path
Osiris-Team Aug 3, 2022
49ef8de
added all platform tests
Osiris-Team Aug 3, 2022
b579ce8
implemented gradle and maven hello world projects into test
Osiris-Team Aug 3, 2022
1aeb33a
removed bloat from hello world projects
Osiris-Team Aug 3, 2022
9c7c8db
unified maven and gradle tasks
Osiris-Team Aug 3, 2022
b15b1aa
fixed small booleans
Osiris-Team Aug 3, 2022
59f3a22
gradle: updated Packagers
Osiris-Team Aug 4, 2022
c5d5a30
renamed name and display name; and fixed plugin extension
Osiris-Team Aug 4, 2022
3a8878b
updated docs and readme
Osiris-Team Aug 4, 2022
8e323a3
removed it folder
Osiris-Team Aug 4, 2022
f7aea3a
update to java 17
Osiris-Team Aug 4, 2022
349088c
updated jdk id
Osiris-Team Aug 4, 2022
ff71bf0
fixed packagingJdk path not getting set
Osiris-Team Aug 4, 2022
8ff3b08
fix maven java home and version issues
Osiris-Team Aug 4, 2022
861d3f2
fix maven java home and version issues
Osiris-Team Aug 4, 2022
516b198
enhanced tests
Osiris-Team Aug 4, 2022
40d7d67
maven is pain...
Osiris-Team Aug 5, 2022
81cd72c
comment
Osiris-Team Aug 5, 2022
dc88aa4
Merge branch 'pr-248' into master
fvarrui Aug 6, 2022
67a67aa
Merge pull request #248 from Osiris-Team/master
fvarrui Aug 6, 2022
16868fb
resolve MacPackager issues
Osiris-Team Aug 6, 2022
96e278d
Merge pull request #253 from Osiris-Team/master
Osiris-Team Aug 6, 2022
297165a
fix dependencies missing
Osiris-Team Aug 6, 2022
6dc084d
added available versions to readme
Osiris-Team Aug 7, 2022
18cd808
moved real test
Osiris-Team Aug 7, 2022
a9d71af
removed snapshot tag since then tests wont work,
Osiris-Team Aug 12, 2022
6e26297
work on new generator
Osiris-Team Aug 13, 2022
acda434
work on new generator
Osiris-Team Aug 13, 2022
8b76fb8
avoid mojoexecution exception
Osiris-Team Aug 19, 2022
b6dd093
fix gradle issues
Osiris-Team Aug 19, 2022
cc96eeb
fix maven
Osiris-Team Aug 19, 2022
93956a4
update docs
Osiris-Team Aug 19, 2022
740caf4
added comments and added GLOBAL_EXTENSION
Osiris-Team Aug 19, 2022
798854f
comment
Osiris-Team Aug 19, 2022
811646b
code cleanup
Osiris-Team Aug 19, 2022
7395f21
Update README.md
Osiris-Team Aug 21, 2022
980f0ef
moved PackagerFactory to packagers
Osiris-Team Aug 21, 2022
49eb4c3
Merge remote-tracking branch 'origin/pr-248' into pr-248
Osiris-Team Aug 21, 2022
fb4987b
update readme
Osiris-Team Aug 24, 2022
813fdef
added nativeImage option to config and readme
Osiris-Team Sep 18, 2022
d25dab9
start work on GenerateNativeImage
Osiris-Team Sep 18, 2022
1b4dd9a
fix version issues with AdoptV3API
Osiris-Team Sep 18, 2022
cb2912c
replaced default jdkVersion 17 with latest
Osiris-Team Sep 18, 2022
4dcd9b7
jdk updater now supports graalvm
Osiris-Team Sep 18, 2022
8185fbc
fix
Osiris-Team Sep 18, 2022
f38b837
cleanup
Osiris-Team Sep 18, 2022
41657da
changed default jdk from adoptium to graalvm
Osiris-Team Nov 3, 2022
a3f6710
graalvm native image and shared library
Osiris-Team Nov 3, 2022
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: 29 additions & 13 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-SNAPSHOT</version>
<version>1.7.0</version>
<executions>
<execution>
<phase>package</phase>
Expand Down Expand Up @@ -88,15 +88,17 @@ apply plugin: 'io.github.fvarrui.javapackager.plugin'
Create your packaging task:

```groovy
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'), ... ]
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'), ... ]
}
linuxConfig {
...
}
Expand All @@ -106,6 +108,12 @@ task packageMyApp(type: io.github.fvarrui.javapackager.gradle.PackageTask, depen
winConfig {
...
}
manifest {
....
}
scripts {
...
}
...
}
```
Expand All @@ -118,6 +126,10 @@ 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 @@ -161,21 +173,25 @@ 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. |
| `jdkPath` | :x: | `${java.home}` | JDK used to generate a customized JRE. It allows to bundle customized JREs for different platforms. |
| `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. |
| `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. |
| `name` | :x: | `${project.name}` or `${project.artifactId}` | App name. |
| `appName` | :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: | `${java.home}` | JDK used in the execution of `jlink` and other JDK tools. |
| `packagingJdk` | :x: | `null` or same as `jdkPath` | JDK used in the execution of `jlink` and other JDK tools. If null `jdkPath` will be used. |
| `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: 14 additions & 5 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,22 +55,31 @@ 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 'junit:junit:4.13.1'
testImplementation 'org.junit.jupiter:junit-jupiter:5.9.0'
testImplementation 'org.apache.maven.shared:maven-invoker:3.2.0'

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-SNAPSHOT'
version = '1.7.0'
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 @@ -88,7 +97,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: 54 additions & 38 deletions docs/gradle/plugin-configuration-samples.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,10 @@
Add next task to your `build.gradle` file:

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

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

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

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

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

## Bundle with an existing JRE

```groovy
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')
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')
}
}
```

## Bundle your own fat JAR

```groovy
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
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
}
}
```

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

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.
* `${name}_${version}-windows.zip` with the Windows application including a customized JRE.
Loading