Skip to content
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

Defaults for jre.path and headerType #339

Merged

Conversation

Lilianne-Blaze
Copy link
Contributor

@Lilianne-Blaze Lilianne-Blaze commented Jan 7, 2024

Path defaults to %JAVA_HOME%;%PATH% which is probably what most users want

Header type defaults to console, unless the main class has "gui" in full name, then to gui.

Closes #338

Comment on lines 506 to 507
getLog().warn("headerType not set, defaulting to \"console\"");
headerType = "console";
Copy link
Collaborator

Choose a reason for hiding this comment

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

Wouldn't be better to make the headerType attribute required with a default value like this?

    @Parameter(required = true, defaultValue = "console")
    private String headerType;

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure, if you want a single default value with no 'magic' that's better

Comment on lines 499 to 503
if (classPath.mainClass.toLowerCase().contains("gui")) {
getLog().warn("headerType not set, defaulting to \"gui\" because the main class is named " + classPath.mainClass);
headerType = "gui";
return;
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

I don't like such magic, it's can be confusing to users why it behaves like this.

Comment on lines +512 to +520
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;
}
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

@lukaszlenart lukaszlenart merged commit 9e01ec4 into orphan-oss:master Jan 15, 2024
4 checks passed
@lukaszlenart
Copy link
Collaborator

I can issue a new release but I think it should be a new 2.5.x version instead of another 2.4.x version, do you agree?

@Lilianne-Blaze
Copy link
Contributor Author

Sure, I was thinking of suggesting that

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Please add sensible defaults for jre and header type (patch included)
2 participants