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
.
release:prepare
will replace-SNAPSHOT
dependencies with "future release" versions. – Consume