Skip to content

Commit e8b5854

Browse files
committed
Adds ability to save config into a file
1 parent da91443 commit e8b5854

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

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

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -286,6 +286,18 @@ public class Launch4jMojo extends AbstractMojo {
286286
@Parameter
287287
private File manifest;
288288

289+
/**
290+
* If set to true it will save final config into a XML file
291+
*/
292+
@Parameter(defaultValue = "false")
293+
private boolean saveConfig = false;
294+
295+
/**
296+
* If {@link #saveConfig} is set to true, config will be written to this file
297+
*/
298+
@Parameter(defaultValue = "${project.build.directory}/launch4j-config.xml")
299+
private File configOutfile;
300+
289301
private File getJar() {
290302
return new File(jar);
291303
}
@@ -404,6 +416,14 @@ public void execute() throws MojoExecutionException {
404416
getLog().error(e);
405417
throw new MojoExecutionException("Failed to build the executable; please verify your configuration.", e);
406418
}
419+
420+
if (saveConfig) {
421+
try {
422+
ConfigPersister.getInstance().save(configOutfile);
423+
} catch (ConfigPersisterException e) {
424+
throw new MojoExecutionException("Cannot save config into a XML file", e);
425+
}
426+
}
407427
}
408428

409429
/**

0 commit comments

Comments
 (0)