1-and-1 :: FOSS Libraries useable by Apache Maven

Additional policies for use with the maven-release-plugin.

License

License

Categories

Categories

Maven Build Tools Net
GroupId

GroupId

net.oneandone.maven
ArtifactId

ArtifactId

ono-maven-shared
Last Version

Last Version

2.7
Release Date

Release Date

Type

Type

jar
Description

Description

1-and-1 :: FOSS Libraries useable by Apache Maven
Additional policies for use with the maven-release-plugin.
Project Organization

Project Organization

1&1
Source Code Management

Source Code Management

https://github.com/1and1/ono-maven-shared/

Download ono-maven-shared

How to add to project

<!-- https://jarcasting.com/artifacts/net.oneandone.maven/ono-maven-shared/ -->
<dependency>
    <groupId>net.oneandone.maven</groupId>
    <artifactId>ono-maven-shared</artifactId>
    <version>2.7</version>
</dependency>
// https://jarcasting.com/artifacts/net.oneandone.maven/ono-maven-shared/
implementation 'net.oneandone.maven:ono-maven-shared:2.7'
// https://jarcasting.com/artifacts/net.oneandone.maven/ono-maven-shared/
implementation ("net.oneandone.maven:ono-maven-shared:2.7")
'net.oneandone.maven:ono-maven-shared:jar:2.7'
<dependency org="net.oneandone.maven" name="ono-maven-shared" rev="2.7">
  <artifact name="ono-maven-shared" type="jar" />
</dependency>
@Grapes(
@Grab(group='net.oneandone.maven', module='ono-maven-shared', version='2.7')
)
libraryDependencies += "net.oneandone.maven" % "ono-maven-shared" % "2.7"
[net.oneandone.maven/ono-maven-shared "2.7"]

Dependencies

compile (7)

Group / Artifact Type Version
org.apache.maven : maven-core jar 3.3.3
org.apache.maven : maven-settings jar 3.3.3
org.apache.maven.release : maven-release-api jar 2.5.2
org.apache.maven.release : maven-release-manager jar 2.5.2
org.apache.maven.shared : maven-shared-utils jar 0.7
org.codehaus.plexus : plexus-component-annotations jar 1.6
org.codehaus.plexus : plexus-utils jar 3.0.22

provided (1)

Group / Artifact Type Version
org.apache.maven.plugin-tools : maven-plugin-annotations jar 3.3

test (4)

Group / Artifact Type Version
org.spockframework : spock-core jar 1.0-groovy-2.4
org.codehaus.groovy : groovy-all jar 2.4.3
cglib : cglib jar 3.1
org.objenesis : objenesis jar 2.4

Project Modules

There are no modules declared in this project.

1-and-1 :: FOSS Libraries useable by Apache Maven

  • Currently some code is smeared and repeated in several plugins.
  • Try to consolidate this in here.

Build Status Build Status Release GitHub license

VersionPolicies

Introduction

  • 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>

ONOArtifactoryVersionPolicy

  • Say you have a schema, where you always want to use MAJOR-SNAPSHOT or MAJOR.MINOR-SNAPSHOT and the next release version will always be MAJOR.MINOR or MAJOR.MINOR.MICRO, e.g. you already released 1.54 and the next version should be 1.55.
  • ArtifactoryVersionPolicy retrieves the number from Artifactory and sets the releaseVersion to the next number. The next developmentVersion 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.

Behaviour when the Artifact already exists

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

Behaviour when the Artifact does not exist

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

Usage

  • Include shared library as dependency to maven-release-plugin.
  • Set projectVersionPolicyId to ONOArtifactoryVersionPolicy.
  • 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>

ONOBuildNumberVersionPolicy

  • Say you have a schema, where you always want to use MAJOR-SNAPSHOT or MAJOR.MINOR-SNAPSHOT and the next release version will always be MAJOR.MINOR or MAJOR.MINOR.MICRO and you want to use the BUILD_NUMBER available from your CI job to be used as variable.
  • BuildNumberVersionPolicy attaches the BUILD_NUMBER as MINOR or MICRO version. The next developmentVersion always stays the same until you change it yourself in the source.
  • Include shared library as dependency to maven-release-plugin.
  • Set projectVersionPolicyId to ONOBuildNumberVersionPolicy.
  • 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>

ONOChangesVersionPolicy

  • 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 as releaseVersion.
  • 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 to maven-release-plugin.
  • Set projectVersionPolicyId to ONOChangesVersionPolicy.
  • See #10 as well.
    <project>
        <properties>
            <projectVersionPolicyId>ONOChangesVersionPolicy</projectVersionPolicyId>
        </properties>
        <!-- do not forget to include ono-maven-shared as dependency as stated above -->
    </project>

ChangesVersionMojo

  • Since 2.7
  • Reuses code from ONOChangesVersionPolicy.
  • Sets the following properties in the reactor:
    • developmentVersion - for maven-release-plugin
    • releaseVersion - for maven-release-plugin
    • newVersion - for versions-maven-plugin
    • ONOCurrentVersion - for maven-changes-plugin
    • tag - for maven-scm-plugin
    • changes.version - for maven-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
net.oneandone.maven

1&1

Open Source by 1&1 Group.

Versions

Version
2.7
2.6
2.4
2.3
2.2
2.1
2.0
1.0