Skip to content

Commit

Permalink
Upgrades to Launch4j 3.50
Browse files Browse the repository at this point in the history
Closes #199
  • Loading branch information
lukaszlenart committed Nov 19, 2022
1 parent 31b87c1 commit 6549451
Show file tree
Hide file tree
Showing 4 changed files with 81 additions and 22 deletions.
9 changes: 7 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,14 @@
<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>

<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>
Expand Down Expand Up @@ -68,21 +68,25 @@
<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 +103,7 @@
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.13.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 not 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 @@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ public class Messages {

String startupErr;

@Deprecated
String bundledJreErr;

String jreVersionErr;
Expand All @@ -36,16 +37,19 @@ public class Messages {

String instanceAlreadyExistsMsg;

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;
}

Expand Down

0 comments on commit 6549451

Please sign in to comment.