From 5f51c836d682d1d83eae8a030f9f0f9b6ebf3806 Mon Sep 17 00:00:00 2001 From: Tom Suworof Date: Tue, 13 Jan 2026 10:13:15 +0300 Subject: [PATCH] Added support for WIN64 build and JRE mode selection --- pom.xml | 4 ++-- .../akathist/maven/plugins/launch4j/Jre.java | 9 ++++++++ .../maven/plugins/launch4j/Launch4jMojo.java | 23 +++++++++++++++++-- .../plugins/launch4j/Launch4jMojoTest.java | 2 ++ .../launch4j-full-plugin-config.xml | 2 ++ 5 files changed, 36 insertions(+), 4 deletions(-) diff --git a/pom.xml b/pom.xml index 473582d8..7f86884b 100644 --- a/pom.xml +++ b/pom.xml @@ -24,7 +24,7 @@ A complete copy of this license may be found in src/main/legal/LICENSE.txt of th --> 4.0.0 - + com.akathist.maven.plugins.launch4j launch4j-maven-plugin maven-plugin @@ -37,7 +37,7 @@ A complete copy of this license may be found in src/main/legal/LICENSE.txt of th UTF-8 - 3.50 + 3.51 17 17 diff --git a/src/main/java/com/akathist/maven/plugins/launch4j/Jre.java b/src/main/java/com/akathist/maven/plugins/launch4j/Jre.java index dd94ca6f..94819b03 100644 --- a/src/main/java/com/akathist/maven/plugins/launch4j/Jre.java +++ b/src/main/java/com/akathist/maven/plugins/launch4j/Jre.java @@ -21,6 +21,7 @@ import java.util.List; +import net.sf.launch4j.config.JreMode; import org.apache.maven.plugin.logging.Log; import org.apache.maven.plugins.annotations.Parameter; @@ -40,6 +41,12 @@ public class Jre { @Parameter(required = true) String path; + /** + * JRE mode: "server" or "client". + */ + @Parameter(defaultValue = "CLIENT") + String mode; + /** * Sets jre's bundledJre64Bit flag * @@ -174,6 +181,7 @@ net.sf.launch4j.config.Jre toL4j() { net.sf.launch4j.config.Jre ret = new net.sf.launch4j.config.Jre(); ret.setPath(path); + ret.setMode(JreMode.valueOf(mode.toUpperCase())); ret.setRequires64Bit(requires64Bit); ret.setMinVersion(minVersion); ret.setMaxVersion(maxVersion); @@ -191,6 +199,7 @@ net.sf.launch4j.config.Jre toL4j() { public String toString() { return "Jre{" + "path='" + path + '\'' + + ", mode=" + mode + ", requires64Bit=" + requires64Bit + ", minVersion='" + minVersion + '\'' + ", maxVersion='" + maxVersion + '\'' + diff --git a/src/main/java/com/akathist/maven/plugins/launch4j/Launch4jMojo.java b/src/main/java/com/akathist/maven/plugins/launch4j/Launch4jMojo.java index cd85de56..eb446089 100644 --- a/src/main/java/com/akathist/maven/plugins/launch4j/Launch4jMojo.java +++ b/src/main/java/com/akathist/maven/plugins/launch4j/Launch4jMojo.java @@ -22,6 +22,7 @@ import com.akathist.maven.plugins.launch4j.tools.ResourceIO; import net.sf.launch4j.Builder; import net.sf.launch4j.BuilderException; +import net.sf.launch4j.config.Architecture; import net.sf.launch4j.config.Config; import net.sf.launch4j.config.ConfigPersister; import net.sf.launch4j.config.ConfigPersisterException; @@ -140,7 +141,7 @@ public class Launch4jMojo extends AbstractMojo { /** * Whether you want a gui or console app. - * Valid values are "gui" and "console." + * Valid values are "gui", "console", "jniGui", "jniConsole". * If you say gui, then launch4j will run your app from javaw instead of java * in order to avoid opening a DOS window. * Choosing gui also enables other options like taskbar icon and a splash screen. @@ -162,6 +163,13 @@ public class Launch4jMojo extends AbstractMojo { @Parameter(defaultValue = "${project.build.directory}/${project.artifactId}.exe") private File outfile; + /** + * The architecture of executable you want launch4j to produce. + * Default is WIN32. + */ + @Parameter(defaultValue = "WIN32") + private Architecture outfileArch; + /** * The jar to bundle inside the executable. * The path, if relative, is relative to the pom.xml. @@ -411,6 +419,10 @@ private void doExecute() throws MojoExecutionException { c.setOutfile(outfile); } + if (outfileArch != null) { + c.setOutfileArch(outfileArch); + } + if (icon != null) { c.setIcon(icon); } @@ -448,6 +460,7 @@ private void doExecute() throws MojoExecutionException { c.setHeaderType(headerType); c.setOutfile(outfile); + c.setOutfileArch(outfileArch); c.setJar(getJar()); c.setDontWrapJar(dontWrapJar); c.setErrTitle(errTitle); @@ -771,7 +784,11 @@ private Artifact chooseBinaryBits() throws MojoExecutionException { // See here for possible values of os.name: // http://lopica.sourceforge.net/os.html if (os.startsWith("Windows")) { - plat = "win32"; + if ("amd64".equals(arch)) { + plat = "win64"; + } else { + plat = "win32"; + } } else if ("Linux".equals(os)) { if ("amd64".equals(arch)) { plat = "linux64"; @@ -809,6 +826,7 @@ private void printState() { log.debug("headerType = " + c.getHeaderType()); log.debug("outfile = " + c.getOutfile()); + log.debug("outfileArch = " + c.getOutfileArch()); log.debug("jar = " + c.getJar()); log.debug("dontWrapJar = " + c.isDontWrapJar()); log.debug("errTitle = " + c.getErrTitle()); @@ -940,6 +958,7 @@ public String toString() { "headerType='" + headerType + '\'' + ", infile=" + infile + ", outfile=" + outfile + + ", outfileArch=" + outfileArch + ", jar='" + jar + '\'' + ", dontWrapJar=" + dontWrapJar + ", errTitle='" + errTitle + '\'' + diff --git a/src/test/java/com/akathist/maven/plugins/launch4j/Launch4jMojoTest.java b/src/test/java/com/akathist/maven/plugins/launch4j/Launch4jMojoTest.java index 3a32ae74..3725dded 100644 --- a/src/test/java/com/akathist/maven/plugins/launch4j/Launch4jMojoTest.java +++ b/src/test/java/com/akathist/maven/plugins/launch4j/Launch4jMojoTest.java @@ -34,6 +34,7 @@ public void testPrintOutFulfilledConfiguration() throws Exception { "headerType='gui', " + "infile=null, " + "outfile=${project.build.directory}" + File.separator + "app.exe, " + + "outfileArch=WIN32, " + "jar='${project.build.directory}/${project.artifactId}-${project.version}.jar', " + "dontWrapJar=false, " + "errTitle='null', " + @@ -51,6 +52,7 @@ public void testPrintOutFulfilledConfiguration() throws Exception { "vars=null, " + "jre=Jre{" + "path='%JAVA_HOME%;%PATH%', " + + "mode=client, " + "requires64Bit=false, " + "minVersion='1.8', " + "maxVersion='null', " + diff --git a/src/test/resources/unit/launch4j-config/launch4j-full-plugin-config.xml b/src/test/resources/unit/launch4j-config/launch4j-full-plugin-config.xml index 94c18bac..af6381c3 100644 --- a/src/test/resources/unit/launch4j-config/launch4j-full-plugin-config.xml +++ b/src/test/resources/unit/launch4j-config/launch4j-full-plugin-config.xml @@ -38,6 +38,7 @@ gui ${project.build.directory}/${project.artifactId}-${project.version}.jar ${project.build.directory}/app.exe + WIN32 https://java.com/download pl.org.lenart.launch4j.App @@ -45,6 +46,7 @@ %JAVA_HOME%;%PATH% + client 1.8 true preferJre