Martin
Martin

Reputation: 180

Version of parent module in child modules specified in profiles not getting updated by Maven-release-plugin

I have a multimodule project with one module that is slow to build and only used when releasing (release-only). In the an aggregate pom i have all modules specified besides the release-only module. The release-only module is specified in a seperate profile which i activate with the maven-release-plugin and it builds it and release it fine.

The problem is the version of the parent module in the release-only module does not get updated when i run release:prepare, meaning while all other modules build (in both prepare, and perform) with the parent artifact version set correctly, the release-only module still has -SNAPSHOT in the version.

I found this what seems to be related issue. But no sollution. https://issues.apache.org/jira/browse/MRELEASE-843

Some simplyfied code from the aggregate pom, explaining the structure.

<profile>
<id>build-rpm</id>
 <modules>
   <module>release-only</module>
 </modules>
</profile>

<plugin>
<artifactId>maven-release-plugin</artifactId>
 <configuration>
   <releaseProfiles>build-rpm</releaseProfiles>
 </configuration>
</plugin>

<modules>
  <module>module1</module>
  <module>module2</module>
</modules>

When running mvn release:prepare i want the versions in all my modules to be updated. (Like the normal mvn versions:set -DnewVersion=xxx which work as expected)

neither mvn release:update-versions and mvn release:prepare update the versions as expected.

Upvotes: 0

Views: 252

Answers (2)

khmarbaise
khmarbaise

Reputation: 97359

The simple trick is not to exclude the module by a profile instead you should make a profile inside the module. That will prevent you from such issues.

Upvotes: 1

J Fabian Meier
J Fabian Meier

Reputation: 35795

I would suggest to remove the "slow module" from the multi-module build. Instead, create a pipeline in your build server (Jenkins, Bamboo, whatever) that first builds your multi-module project and then (in the case of a release) builds the "slow module".

This way, you avoid all the hassle with modules in profiles and switching modules off and on.

Upvotes: 1

Related Questions