Description
After several years of intending to try Launch4j, I've finally got around to testing it with your Maven plugin. I've just got things working, and your Maven plugin so far seems to make the process really snazzy.
In the spirit of Maven (and many of its plugins), which provides reasonable defaults for many properties, I'd like to propose that you provide reasonable defaults. For example for <errTitle>
you could default to
<errTitle>${project.name}</errTitle>
But most importantly defaults for <versionInfo>
would really help. After a bit of experimentation, let me suggest the following. (You may be able to improve upon these.)
<versionInfo>
<fileVersion>${project.baseVersion}.0</fileVersion>
<txtFileVersion>${project.version}</txtFileVersion>
<fileDescription>${project.description}</fileDescription>
<copyright>Copyright © ${project.inceptionYear}-${build.year} ${project.organization.name}. All rights reserved.</copyright>
<productName>${project.name}</productName>
<internalName>${project.artifactId}</internalName>
<productVersion>${project.baseVersion}.0</productVersion>
<txtProductVersion>${project.version}</txtProductVersion>
</versionInfo>
Versions
Note that Launch4j seems to require a version in the format x.x.x.x
, so we can't just use ${project.version}
(although we can use that for the text variations). So we have to take the base Maven project version and add an .0
to it. One can get the base version number using the following. (I'm sure your plugin can determine the whole thing programmatically internally without the need for an extra plugin.)
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<version>3.0.0</version>
<executions>
<execution>
<id>set-project-base-version</id>
<goals>
<goal>regex-property</goal>
</goals>
<configuration>
<name>project.baseVersion</name>
<value>${project.version}</value>
<regex>-SNAPSHOT</regex>
<failIfNoMatch>false</failIfNoMatch>
</configuration>
</execution>
</executions>
</plugin>
Note that this will only work if the project version has the format x.x.x
with optional -SNAPSHOT
. If the project version has fewer or more components, the final number of components won't be correct. But if you set this programmatically in the plugin, then none of this matters; you can ensure the correct number of components when building the default string, and won't even need this extra plugin in the POM.
Copyright
The copyright message was inspired by the Maven Javadoc Plugin, which uses a bottom copyright message of:
Copyright © {inceptionYear}–{currentYear} {organizationName}. All rights reserved.
There is no real need to escape the ©
symbol. Note that the en dash symbol –
doesn't show up well (at least on Windows 10 in the properties dialog details tab), so I (sadly) switched to using a normal dash -
symbol. I also had to update the other properties to use the latest Maven convention. And lastly in order to get ${build.year}
you'll need to set that property. You can do this with a separate plugin, but again, this is something you can undoubtedly do programmatically within your own plugin.
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<version>3.0.0</version>
<executions>
<execution>
<id>set-build-year</id>
<goals>
<goal>timestamp-property</goal>
</goals>
<configuration>
<locale>en</locale>
<name>build.year</name>
<pattern>yyyy</pattern>
</configuration>
</execution>
</executions>
</plugin>
Original Filename
For the <originalFilename>
, you should just use the last path segment of the <outfile>
configuration as the default value. Because after all, since that is the name of the file you are generating, that could reasonably be said to be the original filename. 😄