Skip to content

Commit a627bf9

Browse files
committed
Merge pull request #14 from fchopard/master
added support for restartOnCrash option
2 parents 197a4a2 + 8e1b22e commit a627bf9

File tree

1 file changed

+20
-11
lines changed

1 file changed

+20
-11
lines changed

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

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@
3333
import net.sf.launch4j.BuilderException;
3434
import net.sf.launch4j.config.Config;
3535
import net.sf.launch4j.config.ConfigPersister;
36-
3736
import org.apache.maven.artifact.Artifact;
3837
import org.apache.maven.artifact.factory.ArtifactFactory;
3938
import org.apache.maven.artifact.repository.ArtifactRepository;
@@ -66,7 +65,7 @@ public class Launch4jMojo extends AbstractMojo {
6665
* @readonly
6766
*/
6867
private Set dependencies;
69-
68+
7069
/**
7170
* The user's current project.
7271
*
@@ -110,11 +109,11 @@ public class Launch4jMojo extends AbstractMojo {
110109
* @component
111110
*/
112111
private ArtifactResolver resolver;
113-
112+
114113
/**
115-
* The dependencies of this plugin.
114+
* The dependencies of this plugin.
116115
* Used to get the Launch4j artifact version.
117-
*
116+
*
118117
* @parameter default-value="${plugin.artifacts}" */
119118
private java.util.List<Artifact> pluginArtifacts;
120119

@@ -218,7 +217,7 @@ public class Launch4jMojo extends AbstractMojo {
218217
*/
219218
private String priority;
220219

221-
220+
222221
/**
223222
* If true, the executable waits for the java application to finish before returning its exit code.
224223
* Defaults to false for gui applications. Has no effect for console applications, which always wait.
@@ -227,6 +226,14 @@ public class Launch4jMojo extends AbstractMojo {
227226
*/
228227
private boolean stayAlive;
229228

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+
230237
/**
231238
* The icon to use in the taskbar. Must be in ico format.
232239
*
@@ -284,7 +291,7 @@ public class Launch4jMojo extends AbstractMojo {
284291
* @parameter
285292
*/
286293
private Splash splash;
287-
294+
288295
/**
289296
* Lots of information you can attach to the windows process.
290297
*
@@ -324,8 +331,9 @@ public void execute() throws MojoExecutionException {
324331
c.setSupportUrl(supportUrl);
325332
c.setCmdLine(cmdLine);
326333
c.setChdir(chdir);
327-
c.setPriority(priority);
334+
c.setPriority(priority);
328335
c.setStayAlive(stayAlive);
336+
c.setRestartOnCrash(restartOnCrash);
329337
c.setManifest(manifest);
330338
c.setIcon(icon);
331339
c.setHeaderObjects(objs);
@@ -382,7 +390,7 @@ public void execute() throws MojoExecutionException {
382390
* unpack it. Then different systems won't contend for the same space. But then I'll need to hack
383391
* the l4j code so it permits passing in a work directory and doesn't always base it on
384392
* the location of its own jarfile.
385-
*
393+
*
386394
* @return the work directory.
387395
*/
388396
private File setupBuildEnvironment() throws MojoExecutionException {
@@ -522,7 +530,7 @@ private Artifact chooseBinaryBits() throws MojoExecutionException {
522530
getLaunch4jVersion(), "jar", "workdir-" + plat);
523531
}
524532

525-
533+
526534
private File getBaseDir() {
527535
return basedir;
528536
}
@@ -542,8 +550,9 @@ private void printState() {
542550
log.debug("supportUrl = " + supportUrl);
543551
log.debug("cmdLine = " + cmdLine);
544552
log.debug("chdir = " + chdir);
545-
log.debug("priority = " + priority);
553+
log.debug("priority = " + priority);
546554
log.debug("stayAlive = " + stayAlive);
555+
log.debug("restartOnCrash = " + restartOnCrash);
547556
log.debug("icon = " + icon);
548557
log.debug("objs = " + objs);
549558
log.debug("libs = " + libs);

0 commit comments

Comments
 (0)