Skip to content

Commit

Permalink
Merge branch 'devel'
Browse files Browse the repository at this point in the history
  • Loading branch information
fvarrui committed Apr 5, 2022
2 parents d240244 + 6f3f6fd commit dd2fa51
Show file tree
Hide file tree
Showing 28 changed files with 250 additions and 104 deletions.
11 changes: 9 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ JavaPackager is a hybrid plugin for **Maven** and **Gradle** which provides an e

It was born while teaching to my students how to build and distribute their Java apps, and after seeing that a chain of several plugins was needed to achieve this task, I decided to develop a plugin :ring: to govern them all.

## Apps packaged with JavaPackager

- [Spektar Design Lab](https://spektar.io/)

## How to use this plugin

### Package your app with Maven
Expand All @@ -23,7 +27,7 @@ Add the following `plugin` tag to your `pom.xml`:
<plugin>
<groupId>io.github.fvarrui</groupId>
<artifactId>javapackager</artifactId>
<version>1.6.5</version>
<version>1.6.6</version>
<executions>
<execution>
<phase>package</phase>
Expand Down Expand Up @@ -71,7 +75,7 @@ buildscript {
mavenCentral()
}
dependencies {
classpath 'io.github.fvarrui:javapackager:1.6.5'
classpath 'io.github.fvarrui:javapackager:1.6.6'
}
}
Expand Down Expand Up @@ -151,6 +155,7 @@ By default it will generate next artifacts in `${outputDirectory} ` folder:
| `displayName` | :x: | `${project.name}` or `${name}` | App name to show. |
| `envPath` | :x: | | Defines PATH environment variable in GNU/Linux and Mac OS X startup scripts. |
| `extra` | :x: | | Map with extra properties to be used in customized Velocity templates, accesible through `$info.extra` variable. |
| `forceInstaller` | :x: | `false` | If `true`, skips operating system check when generating installers. |
| `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. |
| `jreDirectoryName` | :x: | `"jre"` | Bundled JRE directory name. |
Expand Down Expand Up @@ -319,6 +324,8 @@ And then, run (ommit `./` on Windows):

> Related [guide](https://plugins.gradle.org/docs/submit).


## Future features

Check the [TO-DO list](https://github.com/fvarrui/JavaPackager/projects/1#column-7704117) to know the features we plan to add to JavaPackager.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ dependencies {
}

group = 'io.github.fvarrui'
version = '1.6.5'
version = '1.6.6'
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 Down
40 changes: 19 additions & 21 deletions docs/windows-specific-properties.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,29 +76,27 @@

## Exe creation properties

| Property | Mandatory | Default value | Description |
| ------------------- | --------- | --------------------- | ---------------------------------------------------------------------- |
| `headerType` | :x: | `"gui"` | EXE header type: `console` or `gui`. |
| `wrapJar` | :x: | `true` | Wrap JAR file in native EXE. |
| `companyName` | :x: | `${organizationName}` | EXE company name. |
| `fileVersion` | :x: | `"1.0.0.0"` | EXE file version. |
| `txtFileVersion` | :x: | `${version}` | EXE txt file version. |
| `productVersion` | :x: | `"1.0.0.0"` | EXE product version. |
| `txtProductVersion` | :x: | `${version}` | EXE txt product version. |
| `fileDescription` | :x: | `${description}` | EXE file description. |
| `copyright` | :x: | `${organizationName}` | EXE copyright. |
| `productName` | :x: | `${name}` | EXE product name. |
| `internalName` | :x: | `${name}` | EXE internal name. |
| `originalFilename` | :x: | `${name}.exe` | EXE original filename. |
| `trademark` | :x: | | EXE trademark. |
| `language` | :x: | | EXE language. |
| `exeCreationTool` | :x: | `launch4j` | EXE creation tool: `launch    4j` or `winrun4j`. |
| `vmLocation` | :x: | | `jvm.dll` path relative to the bundled JRE. **Only for WinRun4J**. \*1 |
| Property | Mandatory | Default value | Description |
| ------------------- | --------- | --------------------- | -------------------------------------------------------------------------------------------------------------------- |
| `headerType` | :x: | `"gui"` | EXE header type: `console` or `gui`. |
| `wrapJar` | :x: | `true` | Wrap JAR file in native EXE. |
| `companyName` | :x: | `${organizationName}` | EXE company name. |
| `fileVersion` | :x: | `"1.0.0.0"` | EXE file version. |
| `txtFileVersion` | :x: | `${version}` | EXE txt file version. |
| `productVersion` | :x: | `"1.0.0.0"` | EXE product version. |
| `txtProductVersion` | :x: | `${version}` | EXE txt product version. |
| `fileDescription` | :x: | `${description}` | EXE file description. |
| `copyright` | :x: | `${organizationName}` | EXE copyright. |
| `productName` | :x: | `${name}` | EXE product name. |
| `internalName` | :x: | `${name}` | EXE internal name. |
| `originalFilename` | :x: | `${name}.exe` | EXE original filename. |
| `trademark` | :x: | | EXE trademark. |
| `language` | :x: | | EXE language. |
| `exeCreationTool` | :x: | `launch4j` | EXE creation tool: [`launch4j`](http://launch4j.sourceforge.net/) or [`winrun4j`](http://winrun4j.sourceforge.net/). |
| `vmLocation` | :x: | | `jvm.dll` path relative to the bundled JRE. **Only for WinRun4J**. \*1 |

> \*1: If a JRE is bundled and `vmLocation` is not specified, it uses `bin\client\jvm.dll` or `bin\server\jvm.dll` as VM location by default.


## Setup generation properties

| Property | Mandatory | Default value | Description |
Expand All @@ -110,7 +108,7 @@
| `disableFinishedPage` | :x: | `true` | If this is set to `true`, Setup will not show the **Setup Completed** wizard page. |
| `disableRunAfterInstall` | :x: | `true` | If this is set to `true`, Setup will not **launch the application** after install. |
| `disableWelcomePage` | :x: | `true` | If this is set to `true`, Setup will not show **Welcome Page**. |
| `createDesktopIconTask` | :x: | `true` | If this is set to `true`, Setup will not ask for **desktop icon creation**. |
| `createDesktopIconTask` | :x: | `true` | If this is set to `true`, Setup will ask for **desktop icon creation**. |
| `removeOldLibs` | :x: | `false` | If there's a previous installation, removes old `libs` folder before install. |

### SetupMode
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,18 @@ protected File doApply(WindowsPackager packager) throws Exception {
String jreDirectoryName = packager.getJreDirectoryName();
String jreMinVersion = packager.getJreMinVersion();
File jarFile = packager.getJarFile();
File appFolder = packager.getAppFolder();

createAssets(packager); // creates a folder only for launch4j assets

String jarPath = winConfig.isWrapJar() ? getGenericJar().getAbsolutePath() : jarFile.getName();
// copies JAR to app folder
String jarPath;
if (winConfig.isWrapJar()) {
jarPath = getGenericJar().getAbsolutePath();
} else {
FileUtils.copyFileToFolder(jarFile, appFolder);
jarPath = jarFile.getName();
}

Launch4jLibraryTask l4jTask = Context.getGradleContext().getLibraryTask();
l4jTask.getOutputs().upToDateWhen(task -> false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ protected Packager createPackager() throws Exception {
.envPath(extension.getEnvPath())
.extra(extension.getExtra())
.fileAssociations(extension.getFileAssociations())
.forceInstaller(extension.isForceInstaller())
.generateInstaller(extension.getGenerateInstaller())
.jdkPath(extension.getJdkPath())
.jreDirectoryName(extension.getJreDirectoryName())
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import java.io.File;

import io.github.fvarrui.javapackager.packagers.*;
import org.gradle.api.Project;
import org.gradle.api.internal.provider.Providers;
import org.gradle.api.logging.Logger;
Expand All @@ -12,11 +13,6 @@
import org.gradle.jvm.toolchain.JavaToolchainSpec;

import edu.sc.seis.launch4j.tasks.Launch4jLibraryTask;
import io.github.fvarrui.javapackager.packagers.AbstractCreateWindowsExe;
import io.github.fvarrui.javapackager.packagers.Context;
import io.github.fvarrui.javapackager.packagers.CreateWindowsExeWinRun4j;
import io.github.fvarrui.javapackager.packagers.Packager;
import io.github.fvarrui.javapackager.packagers.WindowsPackager;

/**
* Gradle context
Expand Down Expand Up @@ -118,6 +114,7 @@ public File createWindowsExe(WindowsPackager packager) throws Exception {
switch (packager.getWinConfig().getExeCreationTool()) {
case launch4j: createWindowsExe = new CreateWindowsExeLaunch4j(); break;
case winrun4j: createWindowsExe = new CreateWindowsExeWinRun4j(); break;
case why: createWindowsExe = new CreateWindowsExeWhy(); break;
default: return null;
}
if (!createWindowsExe.skip(packager)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ public PackagePluginExtension(Project project) {
this.winConfig = new WindowsConfig();
this.outputDirectory = project.getBuildDir();
this.scripts = new Scripts();
this.forceInstaller = false;
}

public LinuxConfig linuxConfig(Closure<LinuxConfig> closure) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,18 @@ public void setGenerateInstaller(Boolean generateInstaller) {
this.generateInstaller = generateInstaller;
}

@Input
@Optional
private Boolean forceInstaller;

public Boolean isForceInstaller() {
return forceInstaller;
}

public void setForceInstaller(Boolean forceInstaller) {
this.forceInstaller = forceInstaller;
}

@InputDirectory
@Optional
private File jdkPath;
Expand Down Expand Up @@ -577,6 +589,7 @@ protected Packager createPackager() throws Exception {
.envPath(defaultIfNull(envPath, extension.getEnvPath()))
.extra(defaultIfNull(extra, extension.getExtra()))
.fileAssociations(defaultIfNull(fileAssociations, extension.getFileAssociations()))
.forceInstaller(defaultIfNull(forceInstaller, extension.isForceInstaller()))
.generateInstaller(defaultIfNull(generateInstaller, extension.getGenerateInstaller()))
.jdkPath(defaultIfNull(jdkPath, extension.getJdkPath()))
.jreDirectoryName(defaultIfBlank(jreDirectoryName, extension.getJreDirectoryName()))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,18 @@ protected File doApply(WindowsPackager packager) throws Exception {
String classpath = packager.getClasspath();
String jreMinVersion = packager.getJreMinVersion();
File jarFile = packager.getJarFile();
File appFolder = packager.getAppFolder();

createAssets(packager);

String jarPath = winConfig.isWrapJar() ? getGenericJar().getAbsolutePath() : jarFile.getName();
// copies JAR to app folder
String jarPath;
if (winConfig.isWrapJar()) {
jarPath = getGenericJar().getAbsolutePath();
} else {
FileUtils.copyFileToFolder(jarFile, appFolder);
jarPath = jarFile.getName();
}

List<Element> optsElements = vmArgs.stream().map(arg -> element("opt", arg)).collect(Collectors.toList());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,10 @@

import java.io.File;

import io.github.fvarrui.javapackager.packagers.*;
import org.apache.maven.plugin.logging.Log;
import org.twdata.maven.mojoexecutor.MojoExecutor.ExecutionEnvironment;

import io.github.fvarrui.javapackager.packagers.AbstractCreateWindowsExe;
import io.github.fvarrui.javapackager.packagers.Context;
import io.github.fvarrui.javapackager.packagers.CreateWindowsExeWinRun4j;
import io.github.fvarrui.javapackager.packagers.Packager;
import io.github.fvarrui.javapackager.packagers.WindowsPackager;

/**
* Maven context
*/
Expand Down Expand Up @@ -73,6 +68,7 @@ public File createWindowsExe(WindowsPackager packager) throws Exception {
AbstractCreateWindowsExe createWindowsExe;
switch (packager.getWinConfig().getExeCreationTool()) {
case launch4j: createWindowsExe = new CreateWindowsExeLaunch4j(); break;
case why: createWindowsExe = new CreateWindowsExeWhy(); break;
case winrun4j: createWindowsExe = new CreateWindowsExeWinRun4j(); break;
default: return null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,12 @@ public class PackageMojo extends AbstractMojo {
@Parameter(defaultValue = "true", property = "generateInstaller", required = false)
private Boolean generateInstaller;

/**
* Forces installer generation.
*/
@Parameter(defaultValue = "false", property = "forceInstaller", required = false)
private Boolean forceInstaller;

/**
* Full path to your app main class.
*/
Expand Down Expand Up @@ -339,6 +345,7 @@ public void execute() throws MojoExecutionException {
.envPath(envPath)
.extra(extra)
.fileAssociations(fileAssociations)
.forceInstaller(forceInstaller)
.generateInstaller(generateInstaller)
.iconFile(iconFile)
.jdkPath(jdkPath)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@

public enum WindowsExeCreationTool {
launch4j,
why,
winrun4j;
}
Loading

0 comments on commit dd2fa51

Please sign in to comment.