-
Notifications
You must be signed in to change notification settings - Fork 41.2k
Allow individual build info properties to be excluded #27412
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
Conversation
Thanks for the PR, @vpavic. This looks good on the Gradle side. For Maven, I can't see how group, artifact, and version can be omitted. Have I missed something? |
Thanks for the quick feedback @wilkinsona - please see #27092 (comment). Things don't seem to be not quite consistent between Gradle and Maven plugins. To be more precise, I doesn't seem that the Maven plugin allows customization of build info properties ( This is because Gradle plugin has Lines 64 to 68 in 9f001ef
Lines 91 to 92 in 9f001ef
It seems to me that it's a separate enhancement to get Maven plugin the capability to pull the core build info properties (i.e. |
Sorry, Vedran, #27092 (comment) got lost in my notifications. I agree with your analysis there. To fully implement #27092, I think we need to add |
I can do this as a part of this PR if that works for you. It's just that it seemed to me that from the project's perspective it would be better to track the new capabilities of Maven plugin separately, rather than having them hidden under something called Allow build info properties to be disabled. |
Thanks. The primary, perhaps even only at this point, reason for making the properties configurable with Maven is to allow them to be disabled so I think it's fine to roll it all under a single issue/PR. |
OK then. I'll update this PR accordingly in the following days. |
I've updated the PR with needed changes on the Maven side. I also updated the docs. Note that the empty tag approach didn't work as such configuration was ignored and resulted in the default values being written to the |
At present, BuildPropertiesWriter can fail with a NPE if build properties (group, artifact, name, version) are set to null. This is specifically problematic with the Gradle plugin, since its DSL can be used to set group, name and version properties to null in an attempt to remove them from the generated build-info.properties. Additionally, setting artifact property to null results in the value "unspecified". This commit updates BuildPropertiesWriter to write the properties only if they are not null and have non-whitespace characters. Closes spring-projectsgh-27092
I've looked at the end result and I am wondering if that's the right call. While I don't deny that being able to disable certain properties is useful, I find the addition of new top-level properties for the only purpose of being able to set them to I think we need to take a step back and rather offer a way for users to take full control. The plugin has a |
@philwebb Sorry for the ping, but is this on track to be included in 2.6? I'm asking because it's a bit unclear to me - there's no milestone assigned here, the issue is labeled as |
Sorry for the confusion. We discussed it on the call and wanted to experiment some more with the Maven plugin configuration. The git info maven plugin has an <configuration>
<generateGitPropertiesFile>true</generateGitPropertiesFile>
<generateGitPropertiesFilename>${project.build.outputDirectory}/git.properties</generateGitPropertiesFilename>
<includeOnlyProperties>
<includeOnlyProperty>^git.build.(time|version)$</includeOnlyProperty>
<includeOnlyProperty>^git.commit.id.(abbrev|full)$</includeOnlyProperty>
</includeOnlyProperties>
<commitIdGenerationMode>full</commitIdGenerationMode>
</configuration> We wondered if something similar might work here but we didn't get as far as really designing anything. I'll mark the other issue as superseded and put this one in 2.6.x. |
Update Maven and Gradle plugins to allow build info properties to be excluded. Prior to this commit, the `BuildPropertiesWriter` would fail with an NPE if the group, artifact, name or version properties were `null`. This was specifically problematic with the Gradle plugin, since its DSL allows `null` properties which would either be passed to the writer or, in the case of `artifact`, converted into a string value of "unspecified". See gh-27412
Update the Maven plugin to use an alternative syntax to exclude the info properties and apply some minor polishing. See gh-27412
Thanks very much for PR @vpavic (and for your patience)! I've merged this into |
At present,
BuildPropertiesWriter
can fail with a NPE if build properties (group
,artifact
,name
,version
) are set tonull
.This is specifically problematic with the Gradle plugin, since its DSL can be used to set
group
,name
andversion
properties tonull
in an attempt to remove them from the generatedbuild-info.properties
. Additionally, settingartifact
property tonull
results in the valueunspecified
.This PR updates
BuildPropertiesWriter
to write the properties only if they are not null and have non-whitespace characters.This closes #27092