feat: requestedJavaVersion honored by init templates#2206
Merged
maxandersen merged 1 commit intojbangdev:mainfrom Sep 14, 2025
Merged
feat: requestedJavaVersion honored by init templates#2206maxandersen merged 1 commit intojbangdev:mainfrom
maxandersen merged 1 commit intojbangdev:mainfrom
Conversation
Collaborator
Author
|
btw. yes - this is up to the individual templates wether they want to honor this or not. but we already have templates setting specific java versions so i dont think there is much way around this. |
d3026ea to
82f6e30
Compare
82f6e30 to
33aebeb
Compare
Contributor
|
I like this change, and it is future proof. :-) |
Contributor
|
I think it's a good compromise. Merge it! :-) |
quintesse
approved these changes
Sep 14, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
alternative/replacement of #2143
in #2143 it was suggested to force add "//JAVA 25+" when compact source enabled (automatically enabled when Java > 25) but I turned it down as it was resulting in inconsistent behavior.
Since then I myself been caught by having done
jbang init --java 25 hello.javaand then when running./hello.javait didn't work because my environments java was less than Java 25.so this PR suggests introducing a
requestedJavaVersionproperty which will be set to null if no specific java version requested; and other set to the raw string of the arg value in--java <arg>Then use that to generate
//JAVA ${requestedJavaVersion}if requested version is present, and in the case of compact source files will get//JAVA 25+if you did not request a specific java file...meaning no matter how you get a compact source file - it will always have at least//JAVA 25+in it OR what you requested using--java <arg>In addition I updated the compact source to use
IO.println()to be able to cut out the import line.I also added
{#if requestedJavaVersion} //JAVA {requestedJavaVersion} {/if}to the templates I could see it being meaningful.
wdyt @wfouche and @quintesse - I think this should make us all more happy than annoyed ;)