Skip to content

Commit

Permalink
Merge pull request #200 from orphan-oss/launch4j-350
Browse files Browse the repository at this point in the history
Upgrades to Launch4j 3.50
  • Loading branch information
lukaszlenart authored Nov 21, 2022
2 parents 31b87c1 + 775b73a commit 0a7d1f0
Show file tree
Hide file tree
Showing 9 changed files with 338 additions and 29 deletions.
49 changes: 43 additions & 6 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,28 +22,30 @@
<groupId>com.akathist.maven.plugins.launch4j</groupId>
<artifactId>launch4j-maven-plugin</artifactId>
<packaging>maven-plugin</packaging>
<version>2.1.4-SNAPSHOT</version>
<version>2.2.0-SNAPSHOT</version>

<name>Maven Launch4j Plugin</name>
<description>This plugin creates Windows executables from Java jar files using the Launch4j utility.</description>
<url>http://9stmaryrd.com/tools/launch4j-maven-plugin/</url>
<url>https://orphan.software/</url>

<properties>
<launch4j.version>3.14</launch4j.version>
<launch4j.version>3.50</launch4j.version>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>

<licenses>
<license>
<name>GNU General Public License</name>
<url>http://www.gnu.org/licenses/gpl.txt</url>
<name>Apache 2.0 License</name>
<url>https://www.apache.org/licenses/LICENSE-2.0</url>
<distribution>repo</distribution>
</license>
</licenses>

<scm>
<developerConnection>scm:git:[email protected]:lukaszlenart/launch4j-maven-plugin.git</developerConnection>
<connection>scm:git:[email protected]:orphan-oss/launch4j-maven-plugin.git</connection>
<url>[email protected]:orphan-oss/launch4j-maven-plugin.git</url>
<developerConnection>scm:git:[email protected]:orphan-oss/launch4j-maven-plugin.git</developerConnection>
<tag>HEAD</tag>
</scm>

Expand All @@ -62,27 +64,49 @@
<artifactId>abeille</artifactId>
<groupId>net.java.abeille</groupId>
</exclusion>
<exclusion>
<groupId>com.thoughtworks.xstream</groupId>
<artifactId>xstream</artifactId>
</exclusion>
<exclusion>
<groupId>org.apache.ant</groupId>
<artifactId>ant</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.apache.ant</groupId>
<artifactId>ant</artifactId>
<version>1.10.12</version>
</dependency>
<dependency>
<groupId>com.thoughtworks.xstream</groupId>
<artifactId>xstream</artifactId>
<version>1.4.19</version>
</dependency>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-plugin-api</artifactId>
<version>3.8.6</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-model</artifactId>
<version>3.8.6</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-artifact</artifactId>
<version>3.8.6</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-core</artifactId>
<version>3.8.6</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.maven.plugin-tools</groupId>
Expand All @@ -99,6 +123,19 @@
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.13.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.maven.plugin-testing</groupId>
<artifactId>maven-plugin-testing-harness</artifactId>
<version>3.3.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-compat</artifactId>
<version>3.8.2</version>
<scope>test</scope>
</dependency>
</dependencies>

Expand Down
79 changes: 62 additions & 17 deletions src/main/java/com/akathist/maven/plugins/launch4j/Jre.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

import java.util.List;

import org.apache.maven.plugin.logging.Log;
import org.apache.maven.plugins.annotations.Parameter;

/**
Expand All @@ -28,29 +29,44 @@
public class Jre {

/**
* Use this property when you are bundling a jre with your application. It holds the path to the jre.
* If relative, this path is from the executable.
* <p>
* If you specify path only and not minVersion, then the executable will show an error if the jre is not found.
* <p>
* If you specify path along with minVersion, then the executable will check the path first, and if no jre
* is found there, it will search the local system for a jre matching minVersion. If it still doesn't
* find anything, it will show the java download page. You may also specify maxVersion to further
* constrain the search.
* The <path> property is used to specify absolute or relative JRE paths, it does not rely
* on the current directory or <chdir>.
* Note: the path is not checked until the actual application execution.
* The <path> is now required and always used for searching before the registry,
* to ensure compatibility with the latest runtimes, which by default
* do not add registry keys during installation.
*/
@Parameter(required = true)
String path;

/**
* Sets jre's bundledJre64Bit flag
*
* @deprecated Replaced with <requires64Bit> which works during path and registry search.
* @since using Launch4j 3.50
*/
@Parameter(defaultValue = "false")
boolean bundledJre64Bit;
@Deprecated
String bundledJre64Bit;

/**
* Sets jre's bundledJreAsFallback flag
*
* @deprecated Removed, path search is always first and registry search second
* in order to improve compatibility with modern runtimes
* @since using Launch4j 3.50
*/
@Parameter(defaultValue = "false")
@Deprecated
String bundledJreAsFallback;

/**
* When set to "true", limits the runtimes to 64-Bit only, "false" will use 64-Bit or 32-Bit
* depending on which is found. This option works with path and registry search.
* @since version 2.2.0
*/
@Parameter(defaultValue = "false")
boolean bundledJreAsFallback;
boolean requires64Bit;

/**
* Use this property if you want the executable to search the system for a jre.
Expand Down Expand Up @@ -93,10 +109,22 @@ public class Jre {
* <td>Always use a private JDK runtime (fails if there is no JDK installed)</td>
* </tr>
* </table>
*
* @deprecated Replaces with <requiresJdk> which works during path and registry search.
* @since using Launch4j 3.50
*/
@Parameter(defaultValue = "preferJre")
@Deprecated
String jdkPreference;

/**
* When set to "true" only a JDK will be used for execution. An additional check will be performed
* if javac is available during path and registry search.
* @since version 2.2.0
*/
@Parameter(defaultValue = "false")
boolean requiresJdk;

/**
* Sets java's initial heap size in MB, like the -Xms flag.
*/
Expand Down Expand Up @@ -133,25 +161,27 @@ public class Jre {
* Sets JVM version to use: 32 bits, 64 bits or 64/32 bits
* Possible values: 32, 64, 64/32 - it will fallback to default value if different option was used
* Default value is: 64/32
*
* @deprecated Replaced with <requires64Bit> which works during path and registry search.
* @since using Launch4j 3.50
*/
@Parameter(defaultValue = "64/32")
@Deprecated
String runtimeBits;

net.sf.launch4j.config.Jre toL4j() {
net.sf.launch4j.config.Jre ret = new net.sf.launch4j.config.Jre();

ret.setPath(path);
ret.setBundledJre64Bit(bundledJre64Bit);
ret.setBundledJreAsFallback(bundledJreAsFallback);
ret.setRequires64Bit(requires64Bit);
ret.setMinVersion(minVersion);
ret.setMaxVersion(maxVersion);
ret.setJdkPreference(jdkPreference);
ret.setRequiresJdk(requiresJdk);
ret.setInitialHeapSize(initialHeapSize);
ret.setInitialHeapPercent(initialHeapPercent);
ret.setMaxHeapSize(maxHeapSize);
ret.setMaxHeapPercent(maxHeapPercent);
ret.setOptions(opts);
ret.setRuntimeBits(runtimeBits);

return ret;
}
Expand All @@ -160,15 +190,30 @@ net.sf.launch4j.config.Jre toL4j() {
public String toString() {
return "Jre{" +
"path='" + path + '\'' +
", requires64Bit=" + requires64Bit +
", minVersion='" + minVersion + '\'' +
", maxVersion='" + maxVersion + '\'' +
", jdkPreference='" + jdkPreference + '\'' +
", requiresJdk=" + requiresJdk +
", initialHeapSize=" + initialHeapSize +
", initialHeapPercent=" + initialHeapPercent +
", maxHeapSize=" + maxHeapSize +
", maxHeapPercent=" + maxHeapPercent +
", opts=" + opts +
", runtimeBits='" + runtimeBits + '\'' +
'}';
}

public void deprecationWarning(Log log) {
if (this.bundledJreAsFallback != null) {
log.warn("<bundledJreAsFallback/> has been removed! It has no effect!");
}
if (this.bundledJre64Bit != null) {
log.warn("<bundledJre64Bit/> is deprecated, use <requires64Bit/> instead!");
}
if (this.runtimeBits != null) {
log.warn("<runtimeBits/> is deprecated, use <requires64Bit/> instead!");
}
if (this.jdkPreference != null) {
log.warn("<jdkPreference/> is deprecated, use <requiresJdk/> instead!");
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ public class Launch4jMojo extends AbstractMojo {
* Details about the classpath your application should have.
* This is required if you are not wrapping a jar.
*/
@Parameter
@Parameter()
private ClassPath classPath;

/**
Expand Down Expand Up @@ -423,6 +423,7 @@ private void doExecute() throws MojoExecutionException {
c.setClassPath(classPath.toL4j(dependencies));
}
if (jre != null) {
jre.deprecationWarning(getLog());
c.setJre(jre.toL4j());
}
if (singleInstance != null) {
Expand All @@ -435,6 +436,9 @@ private void doExecute() throws MojoExecutionException {
c.setVersionInfo(versionInfo.toL4j());
}
if (messages != null) {
if (messages.bundledJreErr != null) {
getLog().warn("<bundledJreErr/> is deprecated, use <jreNotFoundErr/> instead!");
}
c.setMessages(messages.toL4j());
}
ConfigPersister.getInstance().setAntConfig(c, getBaseDir());
Expand Down Expand Up @@ -708,7 +712,8 @@ private void printState() {
log.debug("jre.path = " + c.getJre().getPath());
log.debug("jre.minVersion = " + c.getJre().getMinVersion());
log.debug("jre.maxVersion = " + c.getJre().getMaxVersion());
log.debug("jre.jdkPreference = " + c.getJre().getJdkPreference());
log.debug("jre.requiresJdk = " + c.getJre().getRequiresJdk());
log.debug("jre.requires64Bit = " + c.getJre().getRequires64Bit());
log.debug("jre.initialHeapSize = " + c.getJre().getInitialHeapSize());
log.debug("jre.initialHeapPercent = " + c.getJre().getInitialHeapPercent());
log.debug("jre.maxHeapSize = " + c.getJre().getMaxHeapSize());
Expand Down Expand Up @@ -755,7 +760,7 @@ private void printState() {
}
if (c.getMessages() != null) {
log.debug("messages.startupErr = " + c.getMessages().getStartupErr());
log.debug("messages.bundledJreErr = " + c.getMessages().getBundledJreErr());
log.debug("messages.jreNotFoundErr = " + c.getMessages().getJreNotFoundErr());
log.debug("messages.jreVersionErr = " + c.getMessages().getJreVersionErr());
log.debug("messages.launcherErr = " + c.getMessages().getLauncherErr());
log.debug("messages.instanceAlreadyExistsMsg = " + c.getMessages().getInstanceAlreadyExistsMsg());
Expand Down Expand Up @@ -804,4 +809,37 @@ private boolean skipExecution() {
return skip || System.getProperty("skipLaunch4j") != null;
}

@Override
public String toString() {
return "Launch4jMojo{" +
"headerType='" + headerType + '\'' +
", infile=" + infile +
", outfile=" + outfile +
", jar='" + jar + '\'' +
", dontWrapJar=" + dontWrapJar +
", errTitle='" + errTitle + '\'' +
", downloadUrl='" + downloadUrl + '\'' +
", supportUrl='" + supportUrl + '\'' +
", cmdLine='" + cmdLine + '\'' +
", chdir='" + chdir + '\'' +
", priority='" + priority + '\'' +
", stayAlive=" + stayAlive +
", restartOnCrash=" + restartOnCrash +
", icon=" + icon +
", objs=" + objs +
", libs=" + libs +
", vars=" + vars +
", jre=" + jre +
", classPath=" + classPath +
", singleInstance=" + singleInstance +
", splash=" + splash +
", versionInfo=" + versionInfo +
", messages=" + messages +
", manifest=" + manifest +
", saveConfig=" + saveConfig +
", configOutfile=" + configOutfile +
", parallelExecution=" + parallelExecution +
", skip=" + skip +
'}';
}
}
23 changes: 21 additions & 2 deletions src/main/java/com/akathist/maven/plugins/launch4j/Messages.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,34 +19,53 @@
package com.akathist.maven.plugins.launch4j;

import net.sf.launch4j.config.Msg;

import org.apache.maven.plugins.annotations.Parameter;

/**
* Details about messages you can pass.
*/
public class Messages {

@Parameter
String startupErr;

@Parameter
@Deprecated
String bundledJreErr;

@Parameter
String jreVersionErr;

@Parameter
String launcherErr;

@Parameter
String instanceAlreadyExistsMsg;

@Parameter
String jreNotFoundErr;

Msg toL4j() {
Msg ret = new Msg();

ret.setStartupErr(startupErr);
ret.setBundledJreErr(bundledJreErr);
ret.setJreVersionErr(jreVersionErr);
ret.setLauncherErr(launcherErr);
ret.setInstanceAlreadyExistsMsg(instanceAlreadyExistsMsg);

/* since Launch4j 3.50 */
ret.setJreNotFoundErr(jreNotFoundErr);
return ret;
}

@Override
public String toString() {
return "Messages{" +
"startupErr='" + startupErr + '\'' +
", jreVersionErr='" + jreVersionErr + '\'' +
", launcherErr='" + launcherErr + '\'' +
", instanceAlreadyExistsMsg='" + instanceAlreadyExistsMsg + '\'' +
", jreNotFoundErr='" + jreNotFoundErr + '\'' +
'}';
}
}
Loading

0 comments on commit 0a7d1f0

Please sign in to comment.