versions:use-releases for properties

2020-06-25 04:39发布

问题:

As I understand, versions:use-releases does not update properties that are used to define versions in dependencies.

Is it possible to update these properties as well? I saw that we have a versions:update-properties, but it is meant to update versions to the latest versions, not just replace Snapshots by releases.

An example:

Assume you have dependency like

<dependency>
    <groupId>de.something</groupId>
    <artifactId>coutil</artifactId>
    <version>${coutil.version}</version>
</dependency>

and coutil.version is defined to be 7.0.0-SNAPSHOT.

Without the property (i.e. with 7.0.0-SNAPSHOT directly in the version tag), versions:use-releases would replace 7.0.0-SNAPSHOT by 7.0.0 (if this exists). Now with the indirection of the property, this no longer happens.

I tried to solve the problem by using versions:update-properties where I disallowed major, minor and incremental updates (-DallowMajorUpdates=false etc.), but it had the unexpected consequence of replacing 7.0.0-SNAPSHOT by 7.0.1-RC0002 instead of 7.0.0.

回答1:

You can update any property with relative fresh version of versions plugin. (I guess, you need at least vetsion 2.5 ) e.g:

mvn org.codehaus.mojo:versions-maven-plugin:2.7:set-property -Dproperty=MyProperty -DnewVersion=MyValue org.codehaus.mojo:versions-maven-plugin:2.7:commit