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

Implement maven pom javac release option hint (JEP 247). #4802

Merged
merged 1 commit into from
Oct 19, 2022

Conversation

mbien
Copy link
Member

@mbien mbien commented Oct 17, 2022

  • converts matching source/target options to the release option
  • supports properties and the standard maven-compiler-plugin
  • offers only hints when source/release is set to at least 9+ (could be improved in future once I figure out how to query the JDK version of the project)

It is fairly basic and has a small cosmetic issue. I don't know how to replace elements in-place, so it simply adds the release element to the end of the list if the hint is applied, no matter where source/target was.

I also don't know how to apply hints in the junit tests. When I tried to do that it complained that the model was read only (org.netbeans.modules.xml.xam.dom.ReadOnlyAccess). I suppose its a dummy model.

How to test:
create a new java project and it should already show the hint. It only looks for properties and the config of the standard javac plugin.

@mbien mbien added Java [ci] enable extra Java tests (java.completion, java.source.base, java.hints, refactoring.java, form) Maven [ci] enable "build tools" tests hints labels Oct 17, 2022
@mbien mbien added this to the NB16 milestone Oct 17, 2022
@mbien
Copy link
Member Author

mbien commented Oct 17, 2022

oops. forgot the license headers. Let me fix this :)

@mbien mbien force-pushed the maven-release-flag-hint branch from 38ab661 to e59154d Compare October 17, 2022 12:21
@ebarboni
Copy link
Contributor

if maven-compiler-plugin version is <3.6 it would not be able to use the release parameter.

@mbien mbien force-pushed the maven-release-flag-hint branch from e59154d to 2680d68 Compare October 17, 2022 14:08
@mbien
Copy link
Member Author

mbien commented Oct 17, 2022

if maven-compiler-plugin version is <3.6 it would not be able to use the release parameter.

@ebarboni good to know! How do I compare versions? Is there a utility for this?

there would be this:
https://maven.apache.org/ref/3.6.3/maven-artifact/apidocs/org/apache/maven/artifact/versioning/ComparableVersion.html
but this module does not use that API.

edit: added a little utility method which checks compatibility

@mbien mbien force-pushed the maven-release-flag-hint branch 2 times, most recently from 648b2e4 to b479f7b Compare October 17, 2022 15:16
@mbien
Copy link
Member Author

mbien commented Oct 18, 2022

@matthiasblaesing do you have any remaining concerns integrating this in the current form or should we move it to NB17?

@mbien mbien force-pushed the maven-release-flag-hint branch from b479f7b to dfe3c5a Compare October 18, 2022 16:44
@mbien
Copy link
Member Author

mbien commented Oct 18, 2022

fixed potential NPE when artifactID is null

@matthiasblaesing
Copy link
Contributor

@matthiasblaesing do you have any remaining concerns integrating this in the current form or should we move it to NB17?

No problem - with the reasoning that 8 is dead and thus release will always be there, we are only missing a corner-case. The approach for the properties seems reasonable.

@mbien mbien force-pushed the maven-release-flag-hint branch from dfe3c5a to 9e3ca57 Compare October 18, 2022 19:27
 - converts matching source/target options to the release option
 - supports properties and the standard maven-compiler-plugin
 - offers only hints when source/release is set to at least 9+
@mbien mbien force-pushed the maven-release-flag-hint branch from 9e3ca57 to 21510a8 Compare October 18, 2022 20:02
@mbien
Copy link
Member Author

mbien commented Oct 19, 2022

@neilcsmith-net is master already branched? Or can I still merge?

@neilcsmith-net
Copy link
Member

@mbien you have about 10 minutes! 😄

@mbien mbien merged commit d99b193 into apache:master Oct 19, 2022
@mbien
Copy link
Member Author

mbien commented Oct 19, 2022

awesome merged. Usually I would wait for approval but I think I addressed all review comments and implemented everything. If there is an issue left, it probably not going to be a big one and I can fix it during RC.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
hints Java [ci] enable extra Java tests (java.completion, java.source.base, java.hints, refactoring.java, form) Maven [ci] enable "build tools" tests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants