Generate automatically a marker file for a maven profile depending on java level to use #578
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.
(This idea came up as a discussion during the Jenkins contributor summit, based on the IDE problems experienced during the transition between Java 8 and 11 support)
This effectively reverts #403, reinstating #323, as well as adding a new mechanism for better IDE support.
The logic of setting
maven.compiler.release
dynamically works fine for the Maven CLI. However IDE support (at least IntelliJ) doesn't work well with this and happily ignores what the plugin set dynamically. Indeed, it has its own logic to parse the pom and apply profiles, but doesn't call any maven lifecycle doing so.Instead, it picks up the default value set through the plugin pom that defaults to the minimum java version supported (currently 11), instead of the version inferred from Java bytecode version obtained from Jenkins core.
Generating markerfiles allows to enable maven profiles that will set the java release to the correct version when loaded in IDE, as long as they are able to read activated profiles.
Testing done
-Dmaven.compiler.release=17
Then in a plugin (I used
parallel-test-executor
as an example)maven-hpi-plugin
snapshotplugin-pom
snapshotjenkins.version
property to the snapshot built abovemvn validate
Submitter checklist