Skip to content

Commit 0a7d1f0

Browse files
authored
Merge pull request #200 from orphan-oss/launch4j-350
Upgrades to Launch4j 3.50
2 parents 31b87c1 + 775b73a commit 0a7d1f0

File tree

9 files changed

+338
-29
lines changed

9 files changed

+338
-29
lines changed

pom.xml

Lines changed: 43 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,28 +22,30 @@
2222
<groupId>com.akathist.maven.plugins.launch4j</groupId>
2323
<artifactId>launch4j-maven-plugin</artifactId>
2424
<packaging>maven-plugin</packaging>
25-
<version>2.1.4-SNAPSHOT</version>
25+
<version>2.2.0-SNAPSHOT</version>
2626

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

3131
<properties>
32-
<launch4j.version>3.14</launch4j.version>
32+
<launch4j.version>3.50</launch4j.version>
3333
<maven.compiler.source>1.8</maven.compiler.source>
3434
<maven.compiler.target>1.8</maven.compiler.target>
3535
</properties>
3636

3737
<licenses>
3838
<license>
39-
<name>GNU General Public License</name>
40-
<url>http://www.gnu.org/licenses/gpl.txt</url>
39+
<name>Apache 2.0 License</name>
40+
<url>https://www.apache.org/licenses/LICENSE-2.0</url>
4141
<distribution>repo</distribution>
4242
</license>
4343
</licenses>
4444

4545
<scm>
46-
<developerConnection>scm:git:[email protected]:lukaszlenart/launch4j-maven-plugin.git</developerConnection>
46+
<connection>scm:git:[email protected]:orphan-oss/launch4j-maven-plugin.git</connection>
47+
<url>[email protected]:orphan-oss/launch4j-maven-plugin.git</url>
48+
<developerConnection>scm:git:[email protected]:orphan-oss/launch4j-maven-plugin.git</developerConnection>
4749
<tag>HEAD</tag>
4850
</scm>
4951

@@ -62,27 +64,49 @@
6264
<artifactId>abeille</artifactId>
6365
<groupId>net.java.abeille</groupId>
6466
</exclusion>
67+
<exclusion>
68+
<groupId>com.thoughtworks.xstream</groupId>
69+
<artifactId>xstream</artifactId>
70+
</exclusion>
71+
<exclusion>
72+
<groupId>org.apache.ant</groupId>
73+
<artifactId>ant</artifactId>
74+
</exclusion>
6575
</exclusions>
6676
</dependency>
77+
<dependency>
78+
<groupId>org.apache.ant</groupId>
79+
<artifactId>ant</artifactId>
80+
<version>1.10.12</version>
81+
</dependency>
82+
<dependency>
83+
<groupId>com.thoughtworks.xstream</groupId>
84+
<artifactId>xstream</artifactId>
85+
<version>1.4.19</version>
86+
</dependency>
6787
<dependency>
6888
<groupId>org.apache.maven</groupId>
6989
<artifactId>maven-plugin-api</artifactId>
7090
<version>3.8.6</version>
91+
<scope>provided</scope>
7192
</dependency>
7293
<dependency>
7394
<groupId>org.apache.maven</groupId>
7495
<artifactId>maven-model</artifactId>
7596
<version>3.8.6</version>
97+
<scope>provided</scope>
7698
</dependency>
7799
<dependency>
78100
<groupId>org.apache.maven</groupId>
79101
<artifactId>maven-artifact</artifactId>
80102
<version>3.8.6</version>
103+
<scope>provided</scope>
81104
</dependency>
82105
<dependency>
83106
<groupId>org.apache.maven</groupId>
84107
<artifactId>maven-core</artifactId>
85108
<version>3.8.6</version>
109+
<scope>provided</scope>
86110
</dependency>
87111
<dependency>
88112
<groupId>org.apache.maven.plugin-tools</groupId>
@@ -99,6 +123,19 @@
99123
<groupId>junit</groupId>
100124
<artifactId>junit</artifactId>
101125
<version>4.13.2</version>
126+
<scope>test</scope>
127+
</dependency>
128+
<dependency>
129+
<groupId>org.apache.maven.plugin-testing</groupId>
130+
<artifactId>maven-plugin-testing-harness</artifactId>
131+
<version>3.3.0</version>
132+
<scope>test</scope>
133+
</dependency>
134+
<dependency>
135+
<groupId>org.apache.maven</groupId>
136+
<artifactId>maven-compat</artifactId>
137+
<version>3.8.2</version>
138+
<scope>test</scope>
102139
</dependency>
103140
</dependencies>
104141

src/main/java/com/akathist/maven/plugins/launch4j/Jre.java

Lines changed: 62 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020

2121
import java.util.List;
2222

23+
import org.apache.maven.plugin.logging.Log;
2324
import org.apache.maven.plugins.annotations.Parameter;
2425

2526
/**
@@ -28,29 +29,44 @@
2829
public class Jre {
2930

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

4342
/**
4443
* Sets jre's bundledJre64Bit flag
44+
*
45+
* @deprecated Replaced with <requires64Bit> which works during path and registry search.
46+
* @since using Launch4j 3.50
4547
*/
4648
@Parameter(defaultValue = "false")
47-
boolean bundledJre64Bit;
49+
@Deprecated
50+
String bundledJre64Bit;
4851

4952
/**
5053
* Sets jre's bundledJreAsFallback flag
54+
*
55+
* @deprecated Removed, path search is always first and registry search second
56+
* in order to improve compatibility with modern runtimes
57+
* @since using Launch4j 3.50
58+
*/
59+
@Parameter(defaultValue = "false")
60+
@Deprecated
61+
String bundledJreAsFallback;
62+
63+
/**
64+
* When set to "true", limits the runtimes to 64-Bit only, "false" will use 64-Bit or 32-Bit
65+
* depending on which is found. This option works with path and registry search.
66+
* @since version 2.2.0
5167
*/
5268
@Parameter(defaultValue = "false")
53-
boolean bundledJreAsFallback;
69+
boolean requires64Bit;
5470

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

120+
/**
121+
* When set to "true" only a JDK will be used for execution. An additional check will be performed
122+
* if javac is available during path and registry search.
123+
* @since version 2.2.0
124+
*/
125+
@Parameter(defaultValue = "false")
126+
boolean requiresJdk;
127+
100128
/**
101129
* Sets java's initial heap size in MB, like the -Xms flag.
102130
*/
@@ -133,25 +161,27 @@ public class Jre {
133161
* Sets JVM version to use: 32 bits, 64 bits or 64/32 bits
134162
* Possible values: 32, 64, 64/32 - it will fallback to default value if different option was used
135163
* Default value is: 64/32
164+
*
165+
* @deprecated Replaced with <requires64Bit> which works during path and registry search.
166+
* @since using Launch4j 3.50
136167
*/
137168
@Parameter(defaultValue = "64/32")
169+
@Deprecated
138170
String runtimeBits;
139171

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

143175
ret.setPath(path);
144-
ret.setBundledJre64Bit(bundledJre64Bit);
145-
ret.setBundledJreAsFallback(bundledJreAsFallback);
176+
ret.setRequires64Bit(requires64Bit);
146177
ret.setMinVersion(minVersion);
147178
ret.setMaxVersion(maxVersion);
148-
ret.setJdkPreference(jdkPreference);
179+
ret.setRequiresJdk(requiresJdk);
149180
ret.setInitialHeapSize(initialHeapSize);
150181
ret.setInitialHeapPercent(initialHeapPercent);
151182
ret.setMaxHeapSize(maxHeapSize);
152183
ret.setMaxHeapPercent(maxHeapPercent);
153184
ret.setOptions(opts);
154-
ret.setRuntimeBits(runtimeBits);
155185

156186
return ret;
157187
}
@@ -160,15 +190,30 @@ net.sf.launch4j.config.Jre toL4j() {
160190
public String toString() {
161191
return "Jre{" +
162192
"path='" + path + '\'' +
193+
", requires64Bit=" + requires64Bit +
163194
", minVersion='" + minVersion + '\'' +
164195
", maxVersion='" + maxVersion + '\'' +
165-
", jdkPreference='" + jdkPreference + '\'' +
196+
", requiresJdk=" + requiresJdk +
166197
", initialHeapSize=" + initialHeapSize +
167198
", initialHeapPercent=" + initialHeapPercent +
168199
", maxHeapSize=" + maxHeapSize +
169200
", maxHeapPercent=" + maxHeapPercent +
170201
", opts=" + opts +
171-
", runtimeBits='" + runtimeBits + '\'' +
172202
'}';
173203
}
204+
205+
public void deprecationWarning(Log log) {
206+
if (this.bundledJreAsFallback != null) {
207+
log.warn("<bundledJreAsFallback/> has been removed! It has no effect!");
208+
}
209+
if (this.bundledJre64Bit != null) {
210+
log.warn("<bundledJre64Bit/> is deprecated, use <requires64Bit/> instead!");
211+
}
212+
if (this.runtimeBits != null) {
213+
log.warn("<runtimeBits/> is deprecated, use <requires64Bit/> instead!");
214+
}
215+
if (this.jdkPreference != null) {
216+
log.warn("<jdkPreference/> is deprecated, use <requiresJdk/> instead!");
217+
}
218+
}
174219
}

src/main/java/com/akathist/maven/plugins/launch4j/Launch4jMojo.java

Lines changed: 41 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,7 @@ public class Launch4jMojo extends AbstractMojo {
262262
* Details about the classpath your application should have.
263263
* This is required if you are not wrapping a jar.
264264
*/
265-
@Parameter
265+
@Parameter()
266266
private ClassPath classPath;
267267

268268
/**
@@ -423,6 +423,7 @@ private void doExecute() throws MojoExecutionException {
423423
c.setClassPath(classPath.toL4j(dependencies));
424424
}
425425
if (jre != null) {
426+
jre.deprecationWarning(getLog());
426427
c.setJre(jre.toL4j());
427428
}
428429
if (singleInstance != null) {
@@ -435,6 +436,9 @@ private void doExecute() throws MojoExecutionException {
435436
c.setVersionInfo(versionInfo.toL4j());
436437
}
437438
if (messages != null) {
439+
if (messages.bundledJreErr != null) {
440+
getLog().warn("<bundledJreErr/> is deprecated, use <jreNotFoundErr/> instead!");
441+
}
438442
c.setMessages(messages.toL4j());
439443
}
440444
ConfigPersister.getInstance().setAntConfig(c, getBaseDir());
@@ -708,7 +712,8 @@ private void printState() {
708712
log.debug("jre.path = " + c.getJre().getPath());
709713
log.debug("jre.minVersion = " + c.getJre().getMinVersion());
710714
log.debug("jre.maxVersion = " + c.getJre().getMaxVersion());
711-
log.debug("jre.jdkPreference = " + c.getJre().getJdkPreference());
715+
log.debug("jre.requiresJdk = " + c.getJre().getRequiresJdk());
716+
log.debug("jre.requires64Bit = " + c.getJre().getRequires64Bit());
712717
log.debug("jre.initialHeapSize = " + c.getJre().getInitialHeapSize());
713718
log.debug("jre.initialHeapPercent = " + c.getJre().getInitialHeapPercent());
714719
log.debug("jre.maxHeapSize = " + c.getJre().getMaxHeapSize());
@@ -755,7 +760,7 @@ private void printState() {
755760
}
756761
if (c.getMessages() != null) {
757762
log.debug("messages.startupErr = " + c.getMessages().getStartupErr());
758-
log.debug("messages.bundledJreErr = " + c.getMessages().getBundledJreErr());
763+
log.debug("messages.jreNotFoundErr = " + c.getMessages().getJreNotFoundErr());
759764
log.debug("messages.jreVersionErr = " + c.getMessages().getJreVersionErr());
760765
log.debug("messages.launcherErr = " + c.getMessages().getLauncherErr());
761766
log.debug("messages.instanceAlreadyExistsMsg = " + c.getMessages().getInstanceAlreadyExistsMsg());
@@ -804,4 +809,37 @@ private boolean skipExecution() {
804809
return skip || System.getProperty("skipLaunch4j") != null;
805810
}
806811

812+
@Override
813+
public String toString() {
814+
return "Launch4jMojo{" +
815+
"headerType='" + headerType + '\'' +
816+
", infile=" + infile +
817+
", outfile=" + outfile +
818+
", jar='" + jar + '\'' +
819+
", dontWrapJar=" + dontWrapJar +
820+
", errTitle='" + errTitle + '\'' +
821+
", downloadUrl='" + downloadUrl + '\'' +
822+
", supportUrl='" + supportUrl + '\'' +
823+
", cmdLine='" + cmdLine + '\'' +
824+
", chdir='" + chdir + '\'' +
825+
", priority='" + priority + '\'' +
826+
", stayAlive=" + stayAlive +
827+
", restartOnCrash=" + restartOnCrash +
828+
", icon=" + icon +
829+
", objs=" + objs +
830+
", libs=" + libs +
831+
", vars=" + vars +
832+
", jre=" + jre +
833+
", classPath=" + classPath +
834+
", singleInstance=" + singleInstance +
835+
", splash=" + splash +
836+
", versionInfo=" + versionInfo +
837+
", messages=" + messages +
838+
", manifest=" + manifest +
839+
", saveConfig=" + saveConfig +
840+
", configOutfile=" + configOutfile +
841+
", parallelExecution=" + parallelExecution +
842+
", skip=" + skip +
843+
'}';
844+
}
807845
}

src/main/java/com/akathist/maven/plugins/launch4j/Messages.java

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,34 +19,53 @@
1919
package com.akathist.maven.plugins.launch4j;
2020

2121
import net.sf.launch4j.config.Msg;
22-
22+
import org.apache.maven.plugins.annotations.Parameter;
2323

2424
/**
2525
* Details about messages you can pass.
2626
*/
2727
public class Messages {
2828

29+
@Parameter
2930
String startupErr;
3031

32+
@Parameter
33+
@Deprecated
3134
String bundledJreErr;
3235

36+
@Parameter
3337
String jreVersionErr;
3438

39+
@Parameter
3540
String launcherErr;
3641

42+
@Parameter
3743
String instanceAlreadyExistsMsg;
3844

45+
@Parameter
46+
String jreNotFoundErr;
3947

4048
Msg toL4j() {
4149
Msg ret = new Msg();
4250

4351
ret.setStartupErr(startupErr);
44-
ret.setBundledJreErr(bundledJreErr);
4552
ret.setJreVersionErr(jreVersionErr);
4653
ret.setLauncherErr(launcherErr);
4754
ret.setInstanceAlreadyExistsMsg(instanceAlreadyExistsMsg);
4855

56+
/* since Launch4j 3.50 */
57+
ret.setJreNotFoundErr(jreNotFoundErr);
4958
return ret;
5059
}
5160

61+
@Override
62+
public String toString() {
63+
return "Messages{" +
64+
"startupErr='" + startupErr + '\'' +
65+
", jreVersionErr='" + jreVersionErr + '\'' +
66+
", launcherErr='" + launcherErr + '\'' +
67+
", instanceAlreadyExistsMsg='" + instanceAlreadyExistsMsg + '\'' +
68+
", jreNotFoundErr='" + jreNotFoundErr + '\'' +
69+
'}';
70+
}
5271
}

0 commit comments

Comments
 (0)