Skip to content

Commit f4ab009

Browse files
committed
Merge branch 'issue-115'
2 parents f655cc2 + 0dde45b commit f4ab009

File tree

15 files changed

+304
-323
lines changed

15 files changed

+304
-323
lines changed

README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ By default it will generate next artifacts in `${outputDirectory} ` folder:
131131

132132
> :warning: Installers generation will be ommited if target platform is different from current platform (see `platform` property).
133133
134-
> :warning: **DEB and RPM package generation in Gradle is not yet available. Coming soon!**
134+
> :warning: **RPM package generation in Gradle is not yet available. Coming soon!**
135135
136136
### Plugin configuration properties
137137

@@ -153,26 +153,26 @@ By default it will generate next artifacts in `${outputDirectory} ` folder:
153153
| `envPath` | :x: | | Defines PATH environment variable in GNU/Linux and Mac OS X startup scripts. |
154154
| `extra` | :x: | | Map with extra properties to be used in customized Velocity templates, accesible through `$info.extra` variable. |
155155
| `generateInstaller` | :x: | `true` | Generates an installer for the app. |
156-
| `iconFile` | :x: | | Path to the app icon file (PNG, XPM, ICO or ICNS). **:warning: Deprecated (see platform specific properties).** |
157156
| `jdkPath` | :x: | `${java.home}` | JDK used to generate a customized JRE. It allows to bundle customized JREs for different platforms. |
158157
| `jreDirectoryName` | :x: | `"jre"` | Bundled JRE directory name. |
159158
| `jreMinVersion` | :x: | | JRE minimum version. If an appropriate version cannot be found display error message. Disabled if a JRE is bundled. |
160159
| `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. |
161160
| `licenseFile` | :x: | `${project.licenses[0].url}` or `${basedir}/LICENSE` or `${projectdir}/LICENSE` | Path to project license file. |
162161
| `mainClass` | :heavy_check_mark: | `${exec.mainClass}` | Full path to your app main class. |
163162
| `manifest` | :x: | | [Allows adding additional entries to MANIFEST.MF file.](docs/manifest.md) |
164-
| `modules` | :x: | `[]` | Defines modules to customize the bundled JRE. Don't use `jdeps` to get module dependencies. |
163+
| `modules` | :x: | `[]` | Modules to customize the bundled JRE. Don't use `jdeps` to get module dependencies. |
165164
| `name` | :x: | `${project.name}` or `${project.artifactId}` | App name. |
166165
| `organizationName` | :x: | `${project.organization.name}` or `"ACME"` | Organization name. |
167166
| `organizationUrl` | :x: | `${project.organization.url}` | Organization website URL. |
168167
| `organizationEmail` | :x: | | Organization email. |
169168
| `outputDirectory` | :x: | `${project.build.directory}` or `${project.builddir}` | Output directory (where the artifacts will be generated). |
169+
| `packagingJdk` | :x: | `${java.home}` | JDK used in the execution of `jlink` and other JDK tools. |
170170
| `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. |
171171
| `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. |
172172
| `url` | :x: | | App website URL. |
173173
| `useResourcesAsWorkingDir` | :x: | `true` | Uses app resources folder as default working directory (always `true` on Mac OS). |
174-
| ` version` | :x: | `${project.version}` | Project version. |
175-
| `vmArgs` | :x: | `[]` | Adds VM arguments. |
174+
| ` version` | :x: | `${project.version}` | App version. |
175+
| `vmArgs` | :x: | `[]` | VM arguments. |
176176

177177
> Some default values depends on the used building tool.
178178

build.gradle

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,13 +46,15 @@ dependencies {
4646
implementation 'org.apache.maven:maven-plugin-api:3.6.0'
4747
implementation 'org.codehaus.plexus:plexus-utils:3.1.1'
4848
implementation 'org.twdata.maven:mojo-executor:2.3.0'
49-
implementation 'org.apache.commons:commons-lang3:3.9'
5049
implementation 'commons-io:commons-io:2.6'
50+
implementation 'org.apache.commons:commons-lang3:3.9'
5151
implementation 'org.apache.commons:commons-collections4:4.1'
52+
implementation 'org.apache.commons:commons-compress:1.21'
5253
implementation 'org.apache.velocity:velocity-engine-core:2.0'
5354
implementation 'io.github.fvarrui:gradle-launch4j:2.4.7'
54-
implementation 'com.netflix.nebula:gradle-ospackage-plugin:8.4.1'
55+
implementation 'org.vafer:jdeb:1.9'
5556
implementation 'net.jsign:jsign-core:3.1'
57+
implementation 'org.redline-rpm:redline:1.2.10'
5658

5759
testImplementation 'junit:junit:4.12'
5860

docs/linux-specific-properties.md

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,16 @@
66
<xpmFile>path/to/icon.xpm</xpmFile>
77
<generateDeb>true|false</generateDeb>
88
<generateRpm>true|false</generateRpm>
9+
<wrapJar>true|false</wrapJar>
910
</linuxConfig>
1011
```
1112

12-
| Property | Mandatory | Default value | Description |
13-
| ------------- | --------- | ------------- | ------------------------------ |
14-
| `pngFile` | :x: | `null` | Icon file. |
15-
| `xpmFile` | :x: | `null` | Icon file for RPM generation. |
16-
| `generateDeb` | :x: | `true` | DEB package will be generated. |
17-
| `generateRpm` | :x: | `true` | RPM package will be generated. |
13+
14+
15+
| Property | Mandatory | Default value | Description |
16+
| ------------- | --------- | ------------- | ----------------------------------------------- |
17+
| `pngFile` | :x: | `null` | Icon file. |
18+
| `xpmFile` | :x: | `null` | Icon file for RPM generation. |
19+
| `generateDeb` | :x: | `true` | DEB package will be generated. |
20+
| `generateRpm` | :x: | `true` | RPM package will be generated. |
21+
| `wrapJar` | :x: | `true` | Wraps JAR file inside the executable if `true`. |

src/main/java/io/github/fvarrui/javapackager/gradle/GenerateDeb.java

Lines changed: 0 additions & 110 deletions
This file was deleted.
Lines changed: 48 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,74 @@
11
package io.github.fvarrui.javapackager.gradle;
22

33
import java.io.File;
4+
import java.io.IOException;
5+
import java.security.NoSuchAlgorithmException;
6+
7+
import org.redline_rpm.Builder;
8+
import org.redline_rpm.header.Architecture;
9+
import org.redline_rpm.header.Os;
10+
import org.redline_rpm.header.RpmType;
11+
import org.redline_rpm.payload.Directive;
412

513
import io.github.fvarrui.javapackager.packagers.ArtifactGenerator;
14+
import io.github.fvarrui.javapackager.packagers.LinuxPackager;
615
import io.github.fvarrui.javapackager.packagers.Packager;
16+
import io.github.fvarrui.javapackager.utils.FileUtils;
717
import io.github.fvarrui.javapackager.utils.Logger;
818

919
/**
10-
* Creates a RPM package file including all app folder's content only for
20+
* Creates a RPM package file including all app folder's content only for
1121
* GNU/Linux so app could be easily distributed on Gradle context
1222
*/
1323
public class GenerateRpm extends ArtifactGenerator {
1424

1525
public GenerateRpm() {
1626
super("RPM package");
1727
}
18-
28+
1929
@Override
2030
public boolean skip(Packager packager) {
2131
return !packager.getLinuxConfig().isGenerateRpm();
2232
}
23-
33+
2434
@Override
2535
protected File doApply(Packager packager) throws Exception {
26-
27-
Logger.warn("Sorry! " + getArtifactName() + " generation is not yet available");
2836

37+
Logger.warn("Sorry! " + getArtifactName() + " generation is not yet available");
2938
return null;
39+
40+
// LinuxPackager linuxPackager = (LinuxPackager) packager;
41+
//
42+
// File appFolder = linuxPackager.getAppFolder();
43+
// String name = linuxPackager.getName();
44+
// String version = linuxPackager.getVersion();
45+
// String description = linuxPackager.getDescription();
46+
// String organizationName = linuxPackager.getOrganizationName();
47+
// File outputDirectory = linuxPackager.getOutputDirectory();
48+
//
49+
// Builder builder = new Builder();
50+
// builder.setType(RpmType.BINARY);
51+
// builder.setPlatform(Architecture.X86_64, Os.LINUX);
52+
// builder.setPackage(name, version, "1");
53+
// builder.setPackager(organizationName);
54+
// builder.setDescription(description);
55+
// builder.setPrefixes("/opt/" + name);
56+
//
57+
// // TODO add directories tree and all app files
58+
// // builder.addDirectory(appFolder.getAbsolutePath());
59+
// // builder.addFile("HelloWorldMaven/HelloWorldMaven", new File(appFolder,
60+
// // "HelloWorldMaven"), 0755);
61+
//
62+
// builder.build(outputDirectory);
63+
//
64+
// File rpm = new File(outputDirectory, name + "-" + version + "-1.x86_64.rpm");
65+
// if (rpm.exists()) {
66+
// File rpmOutput = new File(outputDirectory, name + "_" + version + ".rpm");
67+
// FileUtils.rename(rpm, rpmOutput.getName());
68+
// return rpmOutput;
69+
// }
70+
//
71+
// return null;
3072
}
31-
73+
3274
}

src/main/java/io/github/fvarrui/javapackager/gradle/GradleContext.java

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,13 @@
33
import java.io.File;
44

55
import org.gradle.api.Project;
6+
import org.gradle.api.internal.provider.Providers;
67
import org.gradle.api.logging.Logger;
8+
import org.gradle.api.plugins.JavaPluginExtension;
9+
import org.gradle.api.provider.Provider;
10+
import org.gradle.jvm.toolchain.JavaLauncher;
11+
import org.gradle.jvm.toolchain.JavaToolchainService;
12+
import org.gradle.jvm.toolchain.JavaToolchainSpec;
713

814
import edu.sc.seis.launch4j.tasks.Launch4jLibraryTask;
915
import io.github.fvarrui.javapackager.packagers.Context;
@@ -23,7 +29,6 @@ public GradleContext(Project project) {
2329
this.project = project;
2430

2531
// gradle dependant generators
26-
this.getLinuxInstallerGenerators().add(new GenerateDeb());
2732
this.getLinuxInstallerGenerators().add(new GenerateRpm());
2833

2934
}
@@ -79,5 +84,23 @@ public Launch4jLibraryTask getLibraryTask() {
7984
public void setLibraryTask(Launch4jLibraryTask libraryTask) {
8085
this.libraryTask = libraryTask;
8186
}
87+
88+
/**
89+
* Returns project's default toolchain
90+
* @return Default toolchain
91+
*/
92+
public File getDefaultToolchain() {
93+
// Default toolchain
94+
JavaToolchainSpec toolchain = project.getExtensions().getByType(JavaPluginExtension.class).getToolchain();
95+
96+
// acquire a provider that returns the launcher for the toolchain
97+
JavaToolchainService service = project.getExtensions().getByType(JavaToolchainService.class);
98+
Provider<JavaLauncher> defaultLauncher = service.launcherFor(toolchain).orElse(Providers.notDefined());
99+
100+
if (defaultLauncher.isPresent()) {
101+
return defaultLauncher.get().getMetadata().getInstallationPath().getAsFile();
102+
}
103+
return super.getDefaultToolchain();
104+
}
82105

83106
}

src/main/java/io/github/fvarrui/javapackager/gradle/PackagePluginExtension.java

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,6 @@
55
import java.util.HashMap;
66

77
import org.gradle.api.Project;
8-
import org.gradle.api.internal.provider.Providers;
9-
import org.gradle.api.plugins.JavaPluginExtension;
10-
import org.gradle.api.provider.Provider;
11-
import org.gradle.jvm.toolchain.JavaLauncher;
12-
import org.gradle.jvm.toolchain.JavaToolchainService;
13-
import org.gradle.jvm.toolchain.JavaToolchainSpec;
148

159
import groovy.lang.Closure;
1610
import io.github.fvarrui.javapackager.model.LinuxConfig;
@@ -55,7 +49,6 @@ public PackagePluginExtension(Project project) {
5549
this.vmArgs = new ArrayList<>();
5650
this.winConfig = new WindowsConfig();
5751
this.outputDirectory = project.getBuildDir();
58-
this.packagingJdk = getDefaultToolchain(project);
5952
}
6053

6154
public LinuxConfig linuxConfig(Closure<LinuxConfig> closure) {
@@ -81,24 +74,5 @@ public Manifest manifest(Closure<Manifest> closure) {
8174
project.configure(manifest, closure);
8275
return manifest;
8376
}
84-
85-
/**
86-
* Returns project's default toolchain
87-
* @param project Gradle project
88-
* @return Default toolchain
89-
*/
90-
public File getDefaultToolchain(Project project) {
91-
// Default toolchain
92-
JavaToolchainSpec toolchain = project.getExtensions().getByType(JavaPluginExtension.class).getToolchain();
93-
94-
// acquire a provider that returns the launcher for the toolchain
95-
JavaToolchainService service = project.getExtensions().getByType(JavaToolchainService.class);
96-
Provider<JavaLauncher> defaultLauncher = service.launcherFor(toolchain).orElse(Providers.notDefined());
97-
98-
if (defaultLauncher.isPresent()) {
99-
return defaultLauncher.get().getMetadata().getInstallationPath().getAsFile();
100-
}
101-
return new File(System.getProperty("java.home")); // Use java.home as fallback
102-
}
10377

10478
}

0 commit comments

Comments
 (0)