33
33
import net .sf .launch4j .BuilderException ;
34
34
import net .sf .launch4j .config .Config ;
35
35
import net .sf .launch4j .config .ConfigPersister ;
36
-
37
36
import org .apache .maven .artifact .Artifact ;
38
37
import org .apache .maven .artifact .factory .ArtifactFactory ;
39
38
import org .apache .maven .artifact .repository .ArtifactRepository ;
@@ -66,7 +65,7 @@ public class Launch4jMojo extends AbstractMojo {
66
65
* @readonly
67
66
*/
68
67
private Set dependencies ;
69
-
68
+
70
69
/**
71
70
* The user's current project.
72
71
*
@@ -110,11 +109,11 @@ public class Launch4jMojo extends AbstractMojo {
110
109
* @component
111
110
*/
112
111
private ArtifactResolver resolver ;
113
-
112
+
114
113
/**
115
- * The dependencies of this plugin.
114
+ * The dependencies of this plugin.
116
115
* Used to get the Launch4j artifact version.
117
- *
116
+ *
118
117
* @parameter default-value="${plugin.artifacts}" */
119
118
private java .util .List <Artifact > pluginArtifacts ;
120
119
@@ -218,7 +217,7 @@ public class Launch4jMojo extends AbstractMojo {
218
217
*/
219
218
private String priority ;
220
219
221
-
220
+
222
221
/**
223
222
* If true, the executable waits for the java application to finish before returning its exit code.
224
223
* Defaults to false for gui applications. Has no effect for console applications, which always wait.
@@ -227,6 +226,14 @@ public class Launch4jMojo extends AbstractMojo {
227
226
*/
228
227
private boolean stayAlive ;
229
228
229
+ /**
230
+ * If true, when the application exits, any exit code other than 0 is considered a crash and
231
+ * the application will be started again.
232
+ *
233
+ * @parameter default-value=false
234
+ */
235
+ private boolean restartOnCrash ;
236
+
230
237
/**
231
238
* The icon to use in the taskbar. Must be in ico format.
232
239
*
@@ -284,7 +291,7 @@ public class Launch4jMojo extends AbstractMojo {
284
291
* @parameter
285
292
*/
286
293
private Splash splash ;
287
-
294
+
288
295
/**
289
296
* Lots of information you can attach to the windows process.
290
297
*
@@ -324,8 +331,9 @@ public void execute() throws MojoExecutionException {
324
331
c .setSupportUrl (supportUrl );
325
332
c .setCmdLine (cmdLine );
326
333
c .setChdir (chdir );
327
- c .setPriority (priority );
334
+ c .setPriority (priority );
328
335
c .setStayAlive (stayAlive );
336
+ c .setRestartOnCrash (restartOnCrash );
329
337
c .setManifest (manifest );
330
338
c .setIcon (icon );
331
339
c .setHeaderObjects (objs );
@@ -382,7 +390,7 @@ public void execute() throws MojoExecutionException {
382
390
* unpack it. Then different systems won't contend for the same space. But then I'll need to hack
383
391
* the l4j code so it permits passing in a work directory and doesn't always base it on
384
392
* the location of its own jarfile.
385
- *
393
+ *
386
394
* @return the work directory.
387
395
*/
388
396
private File setupBuildEnvironment () throws MojoExecutionException {
@@ -522,7 +530,7 @@ private Artifact chooseBinaryBits() throws MojoExecutionException {
522
530
getLaunch4jVersion (), "jar" , "workdir-" + plat );
523
531
}
524
532
525
-
533
+
526
534
private File getBaseDir () {
527
535
return basedir ;
528
536
}
@@ -542,8 +550,9 @@ private void printState() {
542
550
log .debug ("supportUrl = " + supportUrl );
543
551
log .debug ("cmdLine = " + cmdLine );
544
552
log .debug ("chdir = " + chdir );
545
- log .debug ("priority = " + priority );
553
+ log .debug ("priority = " + priority );
546
554
log .debug ("stayAlive = " + stayAlive );
555
+ log .debug ("restartOnCrash = " + restartOnCrash );
547
556
log .debug ("icon = " + icon );
548
557
log .debug ("objs = " + objs );
549
558
log .debug ("libs = " + libs );
0 commit comments