- Currently some code is smeared and repeated in several plugins.
- Try to consolidate this in here.
- The maven-release-plugin offers a limited choice of policies how it determines the next release and development version.
- By default,
-SNAPSHOT
is stripped to determine the release version, the last numeric part if this release version is increased and extended by-SNAPSHOT
again to get the next development version. ono-maven-shared
offers some additional policies.- To use these during
release
you need to include this component as dependency like this:
<project>
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-release-plugin</artifactId>
<version>${maven-release-plugin.version}</version>
<dependencies>
<dependency>
<groupId>net.oneandone.maven</groupId>
<artifactId>ono-maven-shared</artifactId>
<version>2.X</version>
</dependency>
</dependencies>
</plugin>
</plugins>
</pluginManagement>
</build>
</project>
- Say you have a schema, where you always want to use
MAJOR-SNAPSHOT
orMAJOR.MINOR-SNAPSHOT
and the next release version will always beMAJOR.MINOR
orMAJOR.MINOR.MICRO
, e.g. you already released1.54
and the next version should be1.55
. - ArtifactoryVersionPolicy
retrieves the number from Artifactory and sets the
releaseVersion
to the next number. The nextdevelopmentVersion
always stays the same until you change it yourself in the source. - When your SNAPSHOT version is bigger than the latest release version in Artifactory, it restarts with 0.
- Additionally the maven-release-plugin arguments
are extended with
-DONOArtifactoryVersionPolicy.latest=LATEST_FOUND_RELEASE
and as of 2.5-DONOCurrentVersion=LATEST_FOUND_RELEASE
. - As of version 2.4, you may provide a property
artifactory-version-policy-server-id
which is used for retrieving your credentials from~/.m2/settings.xml
. This only works with plain text or centrally secure passwords.
Latest deployed release is always 1.5.6
Development Version | Version of Next Release |
---|---|
1-SNAPSHOT | 1.5.7 |
1.0-SNAPSHOT | 1.5.7 |
1.5.6-SNAPSHOT | 1.5.7 |
1.5.7-SNAPSHOT | 1.5.7 |
1.6-SNAPSHOT | 1.6.0 |
2-SNAPSHOT | 2.0 |
2.0-SNAPSHOT | 2.0.0 |
When no version of the Artifact could be found, the latest version is always 0.
Development Version | Version of Next Release | Latest Version |
---|---|---|
1.6-SNAPSHOT | 1.6.0 | 0 |
2-SNAPSHOT | 2.0 | 0 |
2.0-SNAPSHOT | 2.0.0 | 0 |
- Include shared library as
dependency
tomaven-release-plugin
. - Set
projectVersionPolicyId
toONOArtifactoryVersionPolicy
. - Optionally set:
artifactory-version-policy-http
: Base-URL of Artifactory (without trailing slash, defaults to http://repo.jfrog.org/artifactory)artifactory-version-policy-repositories
: Comma separated list of repositories to search (defaults to: repo1)
<project>
<properties>
<projectVersionPolicyId>ONOArtifactoryVersionPolicy</projectVersionPolicyId>
<!-- for inhouse repositories -->
<artifactory-version-policy-http>http://artifactory.example.com/artifactory</artifactory-version-policy-http>
<!-- for inhouse repositories -->
<artifactory-version-policy-repositories>first-repo,second-repo</artifactory-version-policy-repositories>
</properties>
<!-- do not forget to include ono-maven-shared as dependency as stated above -->
</project>
- Say you have a schema, where you always want to use
MAJOR-SNAPSHOT
orMAJOR.MINOR-SNAPSHOT
and the next release version will always beMAJOR.MINOR
orMAJOR.MINOR.MICRO
and you want to use theBUILD_NUMBER
available from your CI job to be used as variable. - BuildNumberVersionPolicy
attaches the
BUILD_NUMBER
asMINOR
orMICRO
version. The nextdevelopmentVersion
always stays the same until you change it yourself in the source. - Include shared library as
dependency
tomaven-release-plugin
. - Set
projectVersionPolicyId
toONOBuildNumberVersionPolicy
. - Optionally set
<buildnumber-version-policy-identifier>
when the environment name of your build number is something else, e.g.TRAVIS_BUILD_NUMBER
. - See #2 as well.
<project>
<properties>
<projectVersionPolicyId>ONOBuildNumberVersionPolicy</projectVersionPolicyId>
<buildnumber-version-policy-identifier>TRAVIS_BUILD_NUMBER</buildnumber-version-policy-identifier>
</properties>
<!-- do not forget to include ono-maven-shared as dependency as stated above -->
</project>
- Since 2.6
- Say you want to use your
src/changes/changes.xml
as leading document while releasing. - The topmost release found in
src/changes/changes.xml
will be used asreleaseVersion
. - Additionally the maven-release-plugin arguments
are extended with
-DONOCurrentVersion=LATEST_FOUND_RELEASE
. - The next
developmentVersion
always stays the same until you change it yourself in the source. - Include shared library as
dependency
tomaven-release-plugin
. - Set
projectVersionPolicyId
toONOChangesVersionPolicy
. - See #10 as well.
<project>
<properties>
<projectVersionPolicyId>ONOChangesVersionPolicy</projectVersionPolicyId>
</properties>
<!-- do not forget to include ono-maven-shared as dependency as stated above -->
</project>
- Since 2.7
- Reuses code from ONOChangesVersionPolicy.
- Sets the following properties in the reactor:
developmentVersion
- formaven-release-plugin
releaseVersion
- formaven-release-plugin
newVersion
- forversions-maven-plugin
ONOCurrentVersion
- formaven-changes-plugin
tag
- formaven-scm-plugin
changes.version
- formaven-changes-plugin
- Say you do not want to use the
maven-release-plugin
. - Run
mvn ono-maven-shared:changes-version versions:set deploy -DperformRelease=true