Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Fully automate release procedure with release+versions plugins

Would be great if Maven guru community can help me with the following task.

I would like to automate the release process of Maven module in Hudson in a way that release process runs in batch mode (does not need anything to be asked from console). Currently I use common steps release:prepare (with <preparationGoals>versions:update-parent clean verify</preparationGoals> to update parent to latest version before commit) + release:perform. However I would like Maven to do the following:

Somewhen during preparation step:

  • For all dependencies which match the groupId of the current module and parent, replace -SNAPSHOT with released version (e.g. versions:use-releases -Dincludes=???).

Somewhen after release:

  • For all dependencies which match the groupId of the current module and parent, replace release version with -SNAPSHOT version (e.g. versions:use-latest-snapshots ...).

Example:

<parent>
    <groupId>org.mycompany.myproject</groupId>
    <artifactId>myproject-parent</artifactId>
    <version>1.0-SNAPSHOT</version>
</parent>

<dependency>
    <groupId>${project.groupId}</groupId>
    <artifactId>myproject-api</artifactId>
    <version>1.1-SNAPSHOT</version>         
</dependency>

before module is tagged is transformed into:

<parent>
    <groupId>org.mycompany.myproject</groupId>
    <artifactId>myproject-parent</artifactId>
    <version>1.0</version>
</parent>

<dependency>
    <groupId>${project.groupId}</groupId>
    <artifactId>myproject-api</artifactId>
    <version>1.1</version>          
</dependency>

and after release is succeeded is transformed into:

<parent>
    <groupId>org.mycompany.myproject</groupId>
    <artifactId>myproject-parent</artifactId>
    <version>1.1-SNAPSHOT</version>
</parent>

<dependency>
    <groupId>${project.groupId}</groupId>
    <artifactId>myproject-api</artifactId>
    <version>1.2-SNAPSHOT</version>         
</dependency>

I feel like it needs a mixture of

versions:use-releases scm:commit release:prepare release:perform versions:use-latest-snapshots scm:commit

but I am not sure what is the best way of doing this. Especially it would be nice to have as less commits as possible: the difficulty is that reparationGoals are run after -SNAPSHOT version check.

The described project is not a multi-module project in a sense that parent POM is not referring it's children via <modules>. SCM structure is the following:

 .
 |
 +-- myproject-parent
 |   +-- pom.xml
 +-- myproject-api
 |   +-- pom.xml
 +-- myproject-impl
     +-- pom.xml

Dependencies are:

myproject-api → myproject-parent
myproject-impl → myproject-parent
myproject-impl → myproject-api

The project's parent POM (myproject-parent) will be released rarely and thus will be released first. Then myproject-api (if necessary) and then myproject-impl.

like image 416
dma_k Avatar asked May 10 '12 19:05

dma_k


People also ask

What is release plugin?

Introduction. The main aim of the maven-release plugin is to provide a standard mechanism to release project artifacts outside the immediate development team. The plugin provides basic functionality to create a release and to update the project's SCM accordingly.

What is Maven release prepare?

release:prepare-with-pom Prepare for a release in SCM, and generate release POMs that record the fully resolved projects used. release:rollback Rollback a previous release.


1 Answers

The simple problem you have is that your parent has a different version number than your childs which is the wrong way for a mulit-module build. A multi-module build is intended to have a number of modules related which have the same release process from which follows to have the same version number. If you follow that guideline you don't need the versions plugin you only do the release via release:prepare and release:perform That's it.

Update: After the further discussion I would suggest to setup a new set of Hudson jobs which contain the dependencies between the modules (downstream/upstream deps.) and do a release on each hudson job which triggers the next in the string of the jobs and so on. This prerequisites to have separate modules and separate areas in the version control as well. Otherwise this fight will be lost with Maven and complicate the life.

like image 177
khmarbaise Avatar answered Sep 30 '22 08:09

khmarbaise