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.
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
Convert PluginPropertiesExtension Groovy to Java #39605
Convert PluginPropertiesExtension Groovy to Java #39605
Changes from 11 commits
8f16ea0
8874a69
d376c1e
66e4a93
3b35c96
cdb746a
d01e612
d144e6a
a9aca3b
f00f100
03fa92f
8a0c6e3
441680d
4affbf5
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
This file was deleted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just realized this now, this is a problem present in the old code as well.
The way we assign this default makes it prone to ordering.
If the extension is created before
project.version
is assigned we won't pick it up.We should have a null check in the getter instead and return
project.version
ifversion
isnull
This is fine also in a subsequent PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can update the
PluginPropertiesExtension.getVersion()
to returnproject.getVersion().toString()
ifversion
is null 👍There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is not possible for version to be null. VersionProperties statically loads the version. BuildPlugin is initialized before any PluginPropertiesExtension, since it is applied by PluginBuildPlugin, which extends BuildPlugin. Adding null checks all over for version will only make the code more complicated to understand with no actual additional safety.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We do this early on in the root level
build.gradle
So indeed it's not possible for
project.version
to be null in our build,but all bets are off for external plugins, there's no guarantee that it won't be null.
We might not want to be lenient here and throw an exception if the version is null, but I still think we should do it rather than leave it be an NPE.
Alternatively, we could hard code this to
VersionProperties.elasticsearch
as we only test building plugins where the version of build-tools matches that of elasticsearch.External plugins can then have whatever project.version they like.
What do you think of this approach @rjernst