Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Defaults for jre.path and headerType #339

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ public class Launch4jMojo extends AbstractMojo {
* in order to avoid opening a DOS window.
* Choosing gui also enables other options like taskbar icon and a splash screen.
*/
@Parameter
@Parameter(defaultValue = "console", required = true)
private String headerType;

/**
Expand Down Expand Up @@ -348,6 +348,8 @@ private void doExecute() throws MojoExecutionException {
getLog().debug("Skipping execution of the plugin");
return;
}

fillSensibleJreDefaults();

if (!disableVersionInfoDefaults) {
try {
Expand Down Expand Up @@ -489,6 +491,18 @@ private void doExecute() throws MojoExecutionException {
}
}
}

private void fillSensibleJreDefaults() throws MojoExecutionException {
if (jre == null) {
jre = new Jre();
}

if (jre.path == null) {
String pathDef = "%JAVA_HOME%;%PATH%";
getLog().warn("jre.path not set, defaulting to \"" + pathDef + "\"");
jre.path = pathDef;
}
Comment on lines +496 to +504
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

jre.path cannot be null if defined via pom.xml, the only case to have it null is when you create it by hand like this. I would enclose the whole logic with if:

        if (jre == null) {
            jre = new Jre();
            String pathDef = "%JAVA_HOME%;%PATH%";
            getLog().info("jre not defined, defaulting jre & jre.path to \"" + pathDef + "\"");
            jre.path = pathDef;
        }

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we keep it just in case? Better some unnecessary checks now than surprises later

}

/**
* Prepares a little directory for launch4j to do its thing. Launch4j needs a bunch of object files
Expand Down