-
-
Notifications
You must be signed in to change notification settings - Fork 71
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow property overwrites for version fields, outfile and jar analogous to the ANT task #49
Conversation
It’s possible to overwrite the properties 'jar', 'outfile', 'fileVersion', 'txtFileVersion', 'productVersion', 'txtProductVersion' Example: <configuration> <infile>${project.build.sourceDir}/launch4j-config.xml</infile> <jar>${project.build.directory}/${my.finalJarName}.jar</jar> <outfile>${project.build.directory}/${my.finalShortName}.exe</outfile> <versionInfo> <fileVersion>${my.versionNumber.withBuildId}</fileVersion> <txtFileVersion>${my.versionNumber}</txtFileVersion> <productVersion>${my.versionNumber.withBuildId}</productVersion> <txtProductVersion>${my.versionNumber}</txtProductVersion> </versionInfo> </configuration> For ANT task analogy see https://sourceforge.net/p/launch4j/git/ci/master/tree/src/net/sf/launch4j/ant/Launch4jTask.java#l84
I would revert a bit logic here:
There can be one global variable With such approach you can override any property you want, instead re-defining put logic as now for wdyt? |
thanks for your feedback @lukaszlenart! I was trying to stick to the ANT logic as the Sure, we could provide the option to override ANY property, but not even launch4j provides this functionality. The problem I encountered here was, that several properties will never(!) evaluate to Since there are several other properties with default values one would need to check every of those for the default value at first:
Checking whether a value is the default value can eventually be pretty hard, as the default value is not stored in some maven configuration, accessible by Java. For @Parameter(defaultValue = "${project.build.directory}/${project.artifactId}.exe")
private File outfile;
...
@Parameter(defaultValue = "${project.build.directory}/${project.build.finalName}.jar")
private String jar;
...
String jarDefaultValue = project.getBuild().getDirectory() + "/" + project.getBuild().getFinalName() + ".jar";
File outFileDefaultValue = new File(project.getBuild().getDirectory() + "/" + project.getArtifactId() + ".exe"); I find it hard to describe this behaviour, but I hope you get what I mean... ;-) |
Hm... so maybe it would be good to add a flag |
Nice idea, but imagine the following configuration: <configuration>
<infile>path/to/launch4j-config.xml</infile>
<override>true</override>
<outfile>path/to/outfile.exe</outfile>
</configuration> You would expect that only the Just checking for if(override = true && property != null) {
config.property = property;
} property could never be null if it has a maven default value. And we have no chance to find out whether the not-null value is a maven default value or a user configuration property... |
I see your point but this can be simply fixed by using setters - anyway, let's start with this and then we can always refactor to much more proper solution :) |
Okay, great! I'm not a maven pro so I was probably a bit uncertain how to resolve that... If there's methods for that, sure, let's refactor that in a next step... :) Thanks for your review and thanks for the merge! |
…cific properties possible since 1.7.15 through changes committet in orphan-oss/launch4j-maven-plugin#49
PRs are welcome :) |
This PR fixes my Feature Request #48
The changes from this PR allow overwriting the version fields,
<outfile>
and<jar>
analogous to the ANT task when using an external configuration file with<infile>
.Example:
Overwrites are logged in the maven debug log.
Important note:
To be able to debug these code changes, I had to fix the debug logging method
printState()
so it also takes properties from the external configuration file into account.This has been missing in the original PR #32 by @adamdec