Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
…en-plugin

* 'master' of https://github.com/lukaszlenart/launch4j-maven-plugin: (31 commits)
  Adds ability to save config into a file
  Drops languageIndex as this just a fallback, using language itself should be sufficient
  Adds 1.7.15 version notes
  [maven-release-plugin] prepare for next development iteration
  [maven-release-plugin] prepare release launch4j-maven-plugin-1.7.15
  Updates version notes to add info about 1.7.14
  [maven-release-plugin] prepare for next development iteration
  [maven-release-plugin] prepare release launch4j-maven-plugin-1.7.14
  Fixes issue with setting Language Index Closes orphan-oss#50
  overwrite several properties analogous to the ANT task
  fix debug logging / also take config options from InFile into account
  Fixes small typo
  Adds version notes about 1.7.13
  [maven-release-plugin] prepare for next development iteration
  [maven-release-plugin] prepare release launch4j-maven-plugin-1.7.13
  [pom] Update assembly goal to single
  [pom] Update maven-surefire-plugin to 2.19.1
  [pom] Update maven-javadoc-plugin to 2.10.4
  [pom] Update maven-compiler-plugin to 3.6.0
  [pom] Update maven-assembly-plugin to 3.0.0
  ...
  • Loading branch information
thomas3 committed Mar 5, 2017
2 parents 26e2cf0 + e8b5854 commit b3a443a
Show file tree
Hide file tree
Showing 5 changed files with 231 additions and 66 deletions.
34 changes: 34 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,33 @@ Originally hosted at http://9stmaryrd.com/tools/launch4j-maven-plugin/
[![Build Status](https://travis-ci.org/lukaszlenart/launch4j-maven-plugin.svg)](https://travis-ci.org/lukaszlenart/launch4j-maven-plugin)
[![Maven Central](https://maven-badges.herokuapp.com/maven-central/com.akathist.maven.plugins.launch4j/launch4j-maven-plugin/badge.svg)](https://maven-badges.herokuapp.com/maven-central/com.akathist.maven.plugins.launch4j/launch4j-maven-plugin/)

- [Documentation](#documentation)
- [Version Notes](#version-notes)
- [FAQ](#faq)

# Documentation

Please check [this](src/main/resources/README.adoc) document for more detailed info on how to use the plugin. Please also check [Launch4j's Configuration file](http://launch4j.sourceforge.net/docs.html#Configuration_file) page.

# Version Notes

## Version notes 1.7.15
- allows override some properties loaded from an extrnal Launch4j config file, see [#49](../../issues/49)

## Version notes 1.7.14
- fixes issue with setting `language`, see [#50](../../issues/50)

## Version notes 1.7.13
- upgrades maven plugins to latest versions, see [#47](../../issues/47)

## Version notes 1.7.12
- adds support for missing options, see [#45](../../issues/45)
- `language` - please use one of the values as defined for the `<language/>` tag
- `trademarks` - a free text used as a trademarks

## Version notes 1.7.11
- upgrades to Launch4j version 3.9

## Version notes 1.7.10
- fixes broken `<configuration/>` when not using `<infile/>`

Expand Down Expand Up @@ -97,3 +118,16 @@ A: Use the Sonatype OSS repo
</repository>
</repositories>
```

Q: Can I use Launch4j on 64bit OS?

A: Yes but you will have to install these libs to avoid problems:

- lib32z1
- lib32ncurses5
- lib32bz2-1.0 ( (has been ia32-libs in older Ubuntu versions)
- zlib.i686
- ncurses-libs.i686
- bzip2-libs.i686

See [#4](../../issues/4) for more details.
14 changes: 7 additions & 7 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,14 @@
<groupId>com.akathist.maven.plugins.launch4j</groupId>
<artifactId>launch4j-maven-plugin</artifactId>
<packaging>maven-plugin</packaging>
<version>1.7.11-SNAPSHOT</version>
<version>1.7.16-SNAPSHOT</version>

<name>Maven Launch4j Plugin</name>
<description>This plugin creates Windows executables from Java jar files using the Launch4j utility.</description>
<url>http://9stmaryrd.com/tools/launch4j-maven-plugin/</url>

<properties>
<launch4j.version>3.8.0</launch4j.version>
<launch4j.version>3.9</launch4j.version>
<maven.compiler.source>1.7</maven.compiler.source>
<maven.compiler.target>1.7</maven.compiler.target>
</properties>
Expand Down Expand Up @@ -103,12 +103,12 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.5.3</version>
<version>3.0.0</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.2</version>
<version>3.6.0</version>
</plugin>
</plugins>
</pluginManagement>
Expand All @@ -122,7 +122,7 @@
<id>dist-src</id>
<phase>package</phase>
<goals>
<goal>attached</goal>
<goal>single</goal>
</goals>
<configuration>
<descriptors>
Expand Down Expand Up @@ -217,12 +217,12 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>2.10.1</version>
<version>2.10.4</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-report-plugin</artifactId>
<version>2.18.1</version>
<version>2.19.1</version>
</plugin>
</plugins>
</reporting>
Expand Down
182 changes: 126 additions & 56 deletions src/main/java/com/akathist/maven/plugins/launch4j/Launch4jMojo.java
Original file line number Diff line number Diff line change
Expand Up @@ -286,15 +286,24 @@ public class Launch4jMojo extends AbstractMojo {
@Parameter
private File manifest;

/**
* If set to true it will save final config into a XML file
*/
@Parameter(defaultValue = "false")
private boolean saveConfig = false;

/**
* If {@link #saveConfig} is set to true, config will be written to this file
*/
@Parameter(defaultValue = "${project.build.directory}/launch4j-config.xml")
private File configOutfile;

private File getJar() {
return new File(jar);
}

@Override
public void execute() throws MojoExecutionException {
if (getLog().isDebugEnabled()) {
printState();
}

final File workDir = setupBuildEnvironment();
if (infile != null) {
Expand All @@ -303,7 +312,50 @@ public void execute() throws MojoExecutionException {
if (getLog().isDebugEnabled()) {
getLog().debug("Trying to load Launch4j native configuration using file=" + infile.getAbsolutePath());
}
// load launch4j configfile from <infile>
ConfigPersister.getInstance().load(infile);

// overwrite several properties analogous to the ANT task
// https://sourceforge.net/p/launch4j/git/ci/master/tree/src/net/sf/launch4j/ant/Launch4jTask.java#l84

// retreive the loaded configuration for manipulation
Config c = ConfigPersister.getInstance().getConfig();

String jarDefaultValue = project.getBuild().getDirectory() + "/" + project.getBuild().getFinalName() + ".jar";
if (jar != null && !jar.equals(jarDefaultValue)) {
getLog().debug("Overwriting config file property 'jar' (='"+c.getJar().getAbsolutePath()+"') with local value '"+getJar().getAbsolutePath()+"'");
// only overwrite when != defaultValue (should be != null anytime because of the default value)
c.setJar(getJar());
}

File outFileDefaultValue = new File(project.getBuild().getDirectory() + "/" + project.getArtifactId() + ".exe");
if (outfile != null && !outfile.getAbsolutePath().equals(outFileDefaultValue.getAbsolutePath())) {
// only overwrite when != defaultValue (should be != null anytime because of the default value)
getLog().debug("Overwriting config file property 'outfile' (='"+c.getOutfile().getAbsolutePath()+"') with local value '"+outfile.getAbsolutePath()+"'");
c.setOutfile(outfile);
}

if (versionInfo != null) {
if (versionInfo.fileVersion != null) {
getLog().debug("Overwriting config file property 'versionInfo.fileVersion' (='"+c.getVersionInfo().getFileVersion()+"') with local value '"+versionInfo.fileVersion+"'");
c.getVersionInfo().setFileVersion(versionInfo.fileVersion);
}
if (versionInfo.txtFileVersion != null) {
getLog().debug("Overwriting config file property 'versionInfo.txtFileVersion' (='"+c.getVersionInfo().getTxtFileVersion()+"') with local value '"+versionInfo.txtFileVersion+"'");
c.getVersionInfo().setTxtFileVersion(versionInfo.txtFileVersion);
}
if (versionInfo.productVersion != null) {
getLog().debug("Overwriting config file property 'versionInfo.productVersion' (='"+c.getVersionInfo().getProductVersion()+"') with local value '"+versionInfo.productVersion+"'");
c.getVersionInfo().setProductVersion(versionInfo.productVersion);
}
if (versionInfo.txtProductVersion != null) {
getLog().debug("Overwriting config file property 'versionInfo.txtProductVersion' (='"+c.getVersionInfo().getTxtProductVersion()+"') with local value '"+versionInfo.txtProductVersion+"'");
c.getVersionInfo().setTxtProductVersion(versionInfo.txtProductVersion);
}
}

ConfigPersister.getInstance().setAntConfig(c, infile.getParentFile());

} catch (ConfigPersisterException e) {
getLog().error(e);
throw new MojoExecutionException("Could not load Launch4j native configuration file", e);
Expand Down Expand Up @@ -353,13 +405,25 @@ public void execute() throws MojoExecutionException {
ConfigPersister.getInstance().setAntConfig(c, getBaseDir());
}

if (getLog().isDebugEnabled()) {
printState();
}

final Builder builder = new Builder(new MavenLog(getLog()), workDir);
try {
builder.build();
} catch (BuilderException e) {
getLog().error(e);
throw new MojoExecutionException("Failed to build the executable; please verify your configuration.", e);
}

if (saveConfig) {
try {
ConfigPersister.getInstance().save(configOutfile);
} catch (ConfigPersisterException e) {
throw new MojoExecutionException("Cannot save config into a XML file", e);
}
}
}

/**
Expand Down Expand Up @@ -563,79 +627,85 @@ private File getBaseDir() {
*/
private void printState() {
Log log = getLog();

log.debug("headerType = " + headerType);
log.debug("outfile = " + outfile);
log.debug("jar = " + jar);
log.debug("dontWrapJar = " + dontWrapJar);
log.debug("errTitle = " + errTitle);
log.debug("downloadUrl = " + downloadUrl);
log.debug("supportUrl = " + supportUrl);
log.debug("cmdLine = " + cmdLine);
log.debug("chdir = " + chdir);
log.debug("priority = " + priority);
log.debug("stayAlive = " + stayAlive);
log.debug("restartOnCrash = " + restartOnCrash);
log.debug("icon = " + icon);
log.debug("objs = " + objs);
log.debug("libs = " + libs);
log.debug("vars = " + vars);
if (singleInstance != null) {
log.debug("singleInstance.mutexName = " + singleInstance.mutexName);
log.debug("singleInstance.windowTitle = " + singleInstance.windowTitle);
Config c = ConfigPersister.getInstance().getConfig();

log.debug("headerType = " + c.getHeaderType());
log.debug("outfile = " + c.getOutfile());
log.debug("jar = " + c.getJar());
log.debug("dontWrapJar = " + c.isDontWrapJar());
log.debug("errTitle = " + c.getErrTitle());
log.debug("downloadUrl = " + c.getDownloadUrl());
log.debug("supportUrl = " + c.getSupportUrl());
log.debug("cmdLine = " + c.getCmdLine());
log.debug("chdir = " + c.getChdir());
log.debug("priority = " + c.getPriority());
log.debug("stayAlive = " + c.isStayAlive());
log.debug("restartOnCrash = " + c.isRestartOnCrash());
log.debug("icon = " + c.getIcon());
log.debug("objs = " + c.getHeaderObjects());
log.debug("libs = " + c.getLibs());
log.debug("vars = " + c.getVariables());
if (c.getSingleInstance() != null) {
log.debug("singleInstance.mutexName = " + c.getSingleInstance().getMutexName());
log.debug("singleInstance.windowTitle = " + c.getSingleInstance().getWindowTitle());
} else {
log.debug("singleInstance = null");
}
if (jre != null) {
log.debug("jre.path = " + jre.path);
log.debug("jre.minVersion = " + jre.minVersion);
log.debug("jre.maxVersion = " + jre.maxVersion);
log.debug("jre.jdkPreference = " + jre.jdkPreference);
log.debug("jre.initialHeapSize = " + jre.initialHeapSize);
log.debug("jre.initialHeapPercent = " + jre.initialHeapPercent);
log.debug("jre.maxHeapSize = " + jre.maxHeapSize);
log.debug("jre.maxHeapPercent = " + jre.maxHeapPercent);
log.debug("jre.opts = " + jre.opts);
if (c.getJre() != null) {
log.debug("jre.path = " + c.getJre().getPath());
log.debug("jre.minVersion = " + c.getJre().getMinVersion());
log.debug("jre.maxVersion = " + c.getJre().getMaxVersion());
log.debug("jre.jdkPreference = " + c.getJre().getJdkPreference());
log.debug("jre.initialHeapSize = " + c.getJre().getInitialHeapSize());
log.debug("jre.initialHeapPercent = " + c.getJre().getInitialHeapPercent());
log.debug("jre.maxHeapSize = " + c.getJre().getMaxHeapSize());
log.debug("jre.maxHeapPercent = " + c.getJre().getMaxHeapPercent());
log.debug("jre.opts = " + c.getJre().getOptions());
} else {
log.debug("jre = null");
}
if (c.getClassPath() != null) {
log.debug("classPath.mainClass = " + c.getClassPath().getMainClass());
}
if (classPath != null) {
log.debug("classPath.mainClass = " + classPath.mainClass);
log.debug("classPath.addDependencies = " + classPath.addDependencies);
log.debug("classPath.jarLocation = " + classPath.jarLocation);
log.debug("classPath.preCp = " + classPath.preCp);
log.debug("classPath.postCp = " + classPath.postCp);
} else {
log.info("classpath = null");
}
if (splash != null) {
log.debug("splash.file = " + splash.file);
log.debug("splash.waitForWindow = " + splash.waitForWindow);
log.debug("splash.timeout = " + splash.timeout);
log.debug("splash.timoutErr = " + splash.timeoutErr);
if (c.getSplash() != null) {
log.debug("splash.file = " + c.getSplash().getFile());
log.debug("splash.waitForWindow = " + c.getSplash().getWaitForWindow());
log.debug("splash.timeout = " + c.getSplash().getTimeout());
log.debug("splash.timoutErr = " + c.getSplash().isTimeoutErr());
} else {
log.debug("splash = null");
}
if (versionInfo != null) {
log.debug("versionInfo.fileVersion = " + versionInfo.fileVersion);
log.debug("versionInfo.txtFileVersion = " + versionInfo.txtFileVersion);
log.debug("versionInfo.fileDescription = " + versionInfo.fileDescription);
log.debug("versionInfo.copyright = " + versionInfo.copyright);
log.debug("versionInfo.productVersion = " + versionInfo.productVersion);
log.debug("versionInfo.txtProductVersion = " + versionInfo.txtProductVersion);
log.debug("versionInfo.productName = " + versionInfo.productName);
log.debug("versionInfo.companyName = " + versionInfo.companyName);
log.debug("versionInfo.internalName = " + versionInfo.internalName);
log.debug("versionInfo.originalFilename = " + versionInfo.originalFilename);
if (c.getVersionInfo() != null) {
log.debug("versionInfo.fileVersion = " + c.getVersionInfo().getFileVersion());
log.debug("versionInfo.txtFileVersion = " + c.getVersionInfo().getTxtFileVersion());
log.debug("versionInfo.fileDescription = " + c.getVersionInfo().getFileDescription());
log.debug("versionInfo.copyright = " + c.getVersionInfo().getCopyright());
log.debug("versionInfo.productVersion = " + c.getVersionInfo().getProductVersion());
log.debug("versionInfo.txtProductVersion = " + c.getVersionInfo().getTxtProductVersion());
log.debug("versionInfo.productName = " + c.getVersionInfo().getProductName());
log.debug("versionInfo.companyName = " + c.getVersionInfo().getCompanyName());
log.debug("versionInfo.internalName = " + c.getVersionInfo().getInternalName());
log.debug("versionInfo.originalFilename = " + c.getVersionInfo().getOriginalFilename());
log.debug("versionInfo.language = " + c.getVersionInfo().getLanguage());
log.debug("versionInfo.languageIndex = " + c.getVersionInfo().getLanguageIndex());
log.debug("versionInfo.trademarks = " + c.getVersionInfo().getTrademarks());
} else {
log.debug("versionInfo = null");
}
if (messages != null) {
log.debug("messages.startupErr = " + messages.startupErr);
log.debug("messages.bundledJreErr = " + messages.bundledJreErr);
log.debug("messages.jreVersionErr = " + messages.jreVersionErr);
log.debug("messages.launcherErr = " + messages.launcherErr);
log.debug("messages.instanceAlreadyExistsMsg = " + messages.instanceAlreadyExistsMsg);
if (c.getMessages() != null) {
log.debug("messages.startupErr = " + c.getMessages().getStartupErr());
log.debug("messages.bundledJreErr = " + c.getMessages().getBundledJreErr());
log.debug("messages.jreVersionErr = " + c.getMessages().getJreVersionErr());
log.debug("messages.launcherErr = " + c.getMessages().getLauncherErr());
log.debug("messages.instanceAlreadyExistsMsg = " + c.getMessages().getInstanceAlreadyExistsMsg());
} else {
log.debug("messages = null");
}
Expand Down
Loading

0 comments on commit b3a443a

Please sign in to comment.