Skip to content

Commit 8438f45

Browse files
authored
Merge pull request #270 from fvarrui/revert-258-pr-248
Revert "Simplifies/Unifies settings + JUnit tests + auto JDK download "
2 parents f56cc70 + 0e40e6c commit 8438f45

File tree

104 files changed

+2548
-5419
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

104 files changed

+2548
-5419
lines changed

README.md

Lines changed: 13 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ Add the following `plugin` tag to your `pom.xml`:
3030
<plugin>
3131
<groupId>io.github.fvarrui</groupId>
3232
<artifactId>javapackager</artifactId>
33-
<version>1.7.0</version>
33+
<version>1.7.0-SNAPSHOT</version>
3434
<executions>
3535
<execution>
3636
<phase>package</phase>
@@ -88,17 +88,15 @@ apply plugin: 'io.github.fvarrui.javapackager.plugin'
8888
Create your packaging task:
8989

9090
```groovy
91-
task packageMyApp(type: io.github.fvarrui.javapackager.GradlePackageTask, dependsOn: build) {
92-
javapackager{
93-
// mandatory
94-
mainClass = 'path.to.your.mainClass'
95-
// optional
96-
bundleJre = true|false
97-
generateInstaller = true|false
98-
administratorRequired = true|false
99-
platform = auto|linux|mac|windows
100-
additionalResources = [ file('file path'), file('folder path'), ... ]
101-
}
91+
task packageMyApp(type: io.github.fvarrui.javapackager.gradle.PackageTask, dependsOn: build) {
92+
// mandatory
93+
mainClass = 'path.to.your.mainClass'
94+
// optional
95+
bundleJre = true|false
96+
generateInstaller = true|false
97+
administratorRequired = true|false
98+
platform = auto|linux|mac|windows
99+
additionalResources = [ file('file path'), file('folder path'), ... ]
102100
linuxConfig {
103101
...
104102
}
@@ -108,12 +106,6 @@ task packageMyApp(type: io.github.fvarrui.javapackager.GradlePackageTask, depend
108106
winConfig {
109107
...
110108
}
111-
manifest {
112-
....
113-
}
114-
scripts {
115-
...
116-
}
117109
...
118110
}
119111
```
@@ -126,10 +118,6 @@ And execute the next command in project's root folder:
126118
gradle packageMyApp
127119
```
128120

129-
### Package your app via CI
130-
131-
- **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).
132-
133121
### Generated artifacts
134122

135123
By default it will generate next artifacts in `${outputDirectory} ` folder:
@@ -173,25 +161,21 @@ By default it will generate next artifacts in `${outputDirectory} ` folder:
173161
| `extra` | :x: | | Map with extra properties to be used in customized Velocity templates, accesible through `$info.extra` variable. |
174162
| `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. |
175163
| `forceInstaller` | :x: | `false` | If `true`, skips operating system check when generating installers. |
176-
| `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. |
177-
| `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. |
178164
| `generateInstaller` | :x: | `true` | Generates an installer for the app. |
179-
| `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). |
180-
| `jdkVendor` | :x: | `graalvm` | JDK vendor to download the JDK from. Currently supported: `adoptium, graalvm` |
181-
| `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. |
165+
| `jdkPath` | :x: | `${java.home}` | JDK used to generate a customized JRE. It allows to bundle customized JREs for different platforms. |
182166
| `jreDirectoryName` | :x: | `"jre"` | Bundled JRE directory name. |
183167
| `jreMinVersion` | :x: | | JRE minimum version. If an appropriate version cannot be found display error message. Disabled if a JRE is bundled. |
184168
| `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. |
185169
| `licenseFile` | :x: | `${project.licenses[0].url}` or `${basedir}/LICENSE` or `${projectdir}/LICENSE` | Path to project license file. |
186170
| `mainClass` | :heavy_check_mark: | `${exec.mainClass}` | Full path to your app main class. |
187171
| `manifest` | :x: | | [Allows adding additional entries to MANIFEST.MF file.](docs/manifest.md) |
188172
| `modules` | :x: | `[]` | Modules to customize the bundled JRE. Don't use `jdeps` to get module dependencies. |
189-
| `appName` | :x: | `${project.name}` or `${project.artifactId}` | App name. |
173+
| `name` | :x: | `${project.name}` or `${project.artifactId}` | App name. |
190174
| `organizationName` | :x: | `${project.organization.name}` or `"ACME"` | Organization name. |
191175
| `organizationUrl` | :x: | `${project.organization.url}` | Organization website URL. |
192176
| `organizationEmail` | :x: | | Organization email. |
193177
| `outputDirectory` | :x: | `${project.build.directory}` or `${project.builddir}` | Output directory (where the artifacts will be generated). |
194-
| `packagingJdk` | :x: | `null` or same as `jdkPath` | JDK used in the execution of `jlink` and other JDK tools. If null `jdkPath` will be used. |
178+
| `packagingJdk` | :x: | `${java.home}` | JDK used in the execution of `jlink` and other JDK tools. |
195179
| `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. |
196180
| `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. |
197181
| `scripts` | :x: | | Specify bootstrap script. **Pre and post-install scripts comming soon!** |

build.gradle

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ plugins {
1212
repositories {
1313
mavenLocal()
1414
mavenCentral()
15-
maven {
15+
maven {
1616
url 'https://plugins.gradle.org/m2/'
1717
}
1818
}
@@ -55,31 +55,22 @@ dependencies {
5555
implementation 'net.jsign:jsign-core:3.1'
5656
implementation 'org.redline-rpm:redline:1.2.10'
5757
implementation 'io.github.fvarrui:launch4j:2.5.2'
58-
implementation 'com.google.code.gson:gson:2.9.0'
59-
implementation 'com.squareup.okhttp3:okhttp:4.10.0'
60-
implementation 'org.rauschig:jarchivelib:1.2.0'
61-
implementation 'com.squareup:javapoet:1.13.0'
6258

63-
testImplementation 'org.junit.jupiter:junit-jupiter:5.9.0'
64-
testImplementation 'org.apache.maven.shared:maven-invoker:3.2.0'
59+
testImplementation 'junit:junit:4.13.1'
6560

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

6863
mavenEmbedder 'org.apache.maven:maven-embedder:3.6.0'
69-
mavenEmbedder 'org.apache.maven:maven-compat:3.6.0'
64+
mavenEmbedder 'org.apache.maven:maven-compat:3.6.0'
7065
mavenEmbedder 'org.slf4j:slf4j-simple:1.7.30'
7166
mavenEmbedder 'org.eclipse.aether:aether-connector-basic:1.1.0'
7267
mavenEmbedder 'org.eclipse.aether:aether-transport-wagon:1.1.0'
7368
mavenEmbedder 'org.apache.maven.wagon:wagon-http:3.4.1'
7469
mavenEmbedder 'org.apache.maven.wagon:wagon-provider-api:3.4.1'
7570
}
7671

77-
test {
78-
useJUnitPlatform()
79-
}
80-
8172
group = 'io.github.fvarrui'
82-
version = '1.7.0'
73+
version = '1.7.0-SNAPSHOT'
8374
description = 'Hybrid Maven/Gradle plugin to package Java applications as native Windows, Mac OS X or GNU/Linux executables and create installers for them'
8475

8576
sourceCompatibility = JavaVersion.VERSION_1_8
@@ -97,7 +88,7 @@ publishing {
9788

9889
java {
9990
withSourcesJar()
100-
// and/or analogously use "withJavadocJar()" to get a "javadocJar" task
91+
// and/or analogously use “withJavadocJar()� to get a “javadocJar� task
10192
}
10293

10394
install.repositories.mavenInstaller.pom.with {

docs/gradle/plugin-configuration-samples.md

Lines changed: 38 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,8 @@
99
Add next task to your `build.gradle` file:
1010

1111
```groovy
12-
task packageMyApp(type: io.github.fvarrui.javapackager.GradlePackageTask, dependsOn: build) {
13-
javapackager{
14-
mainClass = 'fvarrui.sample.Main'
15-
}
12+
task packageMyApp(type: io.github.fvarrui.javapackager.gradle.PackageTask, dependsOn: build) {
13+
mainClass = 'fvarrui.sample.Main'
1614
}
1715
```
1816

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

3432
```groovy
35-
task packageMyApp(type: io.github.fvarrui.javapackager.GradlePackageTask, dependsOn: build) {
36-
javapackager{
37-
mainClass = 'fvarrui.sample.Main'
38-
bundleJre = true
39-
}
33+
task packageMyApp(type: io.github.fvarrui.javapackager.gradle.PackageTask, dependsOn: build) {
34+
mainClass = 'fvarrui.sample.Main'
35+
bundleJre = true
4036
}
4137
```
4238

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

4743
```groovy
48-
task packageMyApp(type: io.github.fvarrui.javapackager.GradlePackageTask, dependsOn: build) {
49-
javapackager{
50-
mainClass = 'fvarrui.sample.Main'
51-
bundleJre = true
52-
customizedJre = false
53-
}
44+
task packageMyApp(type: io.github.fvarrui.javapackager.gradle.PackageTask, dependsOn: build) {
45+
mainClass = 'fvarrui.sample.Main'
46+
bundleJre = true
47+
customizedJre = false
5448
}
5549
```
5650

5751
## Bundle with an existing JRE
5852

5953
```groovy
60-
task packageMyApp(type: io.github.fvarrui.javapackager.GradlePackageTask, dependsOn: build) {
61-
javapackager{
62-
mainClass = 'fvarrui.sample.Main'
63-
bundleJre = true
64-
jrePath = file('C:\Program Files\Java\jre1.8.0_231')
65-
}
54+
task packageMyApp(type: io.github.fvarrui.javapackager.gradle.PackageTask, dependsOn: build) {
55+
mainClass = 'fvarrui.sample.Main'
56+
bundleJre = true
57+
jrePath = file('C:\Program Files\Java\jre1.8.0_231')
6658
}
6759
```
6860

6961
## Bundle your own fat JAR
7062

7163
```groovy
72-
task packageMyApp(type: io.github.fvarrui.javapackager.GradlePackageTask, dependsOn: build) {
73-
javapackager{
74-
mainClass = 'fvarrui.sample.Main'
75-
bundleJre = true
76-
runnableJar = file('path/to/your/own/fat.jar')
77-
copyDependencies = false
78-
}
64+
task packageMyApp(type: io.github.fvarrui.javapackager.gradle.PackageTask, dependsOn: build) {
65+
mainClass = 'fvarrui.sample.Main'
66+
bundleJre = true
67+
runnableJar = file('path/to/your/own/fat.jar')
68+
copyDependencies = false
7969
}
8070
```
8171

@@ -86,17 +76,13 @@ javapackager {
8676
// common configuration
8777
mainClass = 'fvarrui.sample.Main'
8878
}
89-
task packageMyAppWithJRE(type: io.github.fvarrui.javapackager.GradlePackageTask, dependsOn: build) {
90-
javapackager{
91-
name = 'Sample'
92-
bundleJre = true
93-
}
79+
task packageMyAppWithJRE(type: io.github.fvarrui.javapackager.gradle.PackageTask, dependsOn: build) {
80+
name = 'Sample'
81+
bundleJre = true
9482
}
95-
task packageMyAppWithoutJRE(type: io.github.fvarrui.javapackager.GradlePackageTask, dependsOn: build) {
96-
javapackager{
97-
name = 'Sample-nojre'
98-
bundleJre = false
99-
}
83+
task packageMyAppWithoutJRE(type: io.github.fvarrui.javapackager.gradle.PackageTask, dependsOn: build) {
84+
name = 'Sample-nojre'
85+
bundleJre = false
10086
}
10187
task packageMyApp(dependsOn: [ 'packageMyAppWithJRE', 'packageMyAppWithoutJRE' ])
10288
```
@@ -114,23 +100,19 @@ javapackager {
114100
bundleJre = true
115101
generateInstaller = false
116102
}
117-
task packageMyAppForLinux(type: io.github.fvarrui.javapackager.GradlePackageTask, dependsOn: build) {
118-
javapackager{
119-
platform = linux
120-
createTarball = true
121-
}
103+
task packageMyAppForLinux(type: io.github.fvarrui.javapackager.gradle.PackageTask, dependsOn: build) {
104+
platform = linux
105+
createTarball = true
106+
jdkPath = file('X:\\path\to\linux\jdk')
122107
}
123-
task packageMyAppForMac(type: io.github.fvarrui.javapackager.GradlePackageTask, dependsOn: build) {
124-
javapackager{
125-
platform = mac
126-
createTarball = true
127-
}
108+
task packageMyAppForMac(type: io.github.fvarrui.javapackager.gradle.PackageTask, dependsOn: build) {
109+
platform = mac
110+
createTarball = true
111+
jdkPath = file('X:\\path\to\mac\jdk')
128112
}
129-
task packageMyAppForWindows(type: io.github.fvarrui.javapackager.GradlePackageTask, dependsOn: build) {
130-
javapackager{
131-
platform = windows
132-
createZipball = true
133-
}
113+
task packageMyAppForWindows(type: io.github.fvarrui.javapackager.gradle.PackageTask, dependsOn: build) {
114+
platform = windows
115+
createZipball = true
134116
}
135117
task packageMyApp(dependsOn: [ 'packageMyAppForLinux', 'packageMyAppForMac', 'packageMyAppForWindows' ])
136118
```
@@ -139,4 +121,6 @@ E.g. on Windows, running `packageMyApp` task will generate next artifacts:
139121

140122
* `${name}_${version}-linux.tar.gz` with the GNU/Linux application including a customized JRE.
141123
* `${name}_${version}-mac.tar.gz` with the Mac OS X application including a customized JRE.
142-
* `${name}_${version}-windows.zip` with the Windows application including a customized JRE.
124+
* `${name}_${version}-windows.zip` with the Windows application including a customized JRE.
125+
126+
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.

0 commit comments

Comments
 (0)