views:

23

answers:

2

Hello,

I am trying to perform a release using a multi-module maven project. My objective is to modify the version of all poms, and create a tag in the SCM, which is why I am using the maven release plugin.

This project has a hierarchy that I have simplified as:

example/
    module1/
    module2/
        module-jni-linux/
        module-jni-macosx/

The pom.xml of example contains its modules like this:

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

And the pom.xml of module2 contains modules that depend on a profile determined by the OS type:

<profiles>
<!-- profile for linux -->
<profile>
  <id>linux</id>
  <activation>
    <os>
      <name>linux</name>
    </os>
  </activation>
  <modules>
    <module>module-jni-linux</module>
  </modules>
</profile>
<!-- profile for mac os -->    
<profile> 
  <id>macosx</id>
  <activation>
    <os>
      <name>mac os x</name>
    </os>
  </activation>
  <modules> 
    <module>module-jni-macosx</module> 
  </modules> 
</profile> 

Finally, each module-jni-* uses the native-maven-plugin to compile some C/C++ sources and generate a shared library.


The problem:

When I try a mvn release:prepare -DdryRun=true in a Mac OS X box, I realize that the module-jni-linux is not taken into account by the release process. That means that while all modules pass to a 1.0.0/1.0.1-SNAPSHOT version, module-jni-linux is not modified. What I would like when doing a release:prepare is that all submodules are updated even if its profile has not been activated.

I tried to active both profiles with mvn -P linux,macosx ..., but the module-jni-linux will not build under mac (and viceversa).

How can I perform a release that updates the version of both submodules?

A: 

For your Maven release plug-in configuration in the parent pom.xml, have you tried using the <arguments> parameter specifying the profiles you want enabled?

You can read more about it here: http://maven.apache.org/plugins/maven-release-plugin/prepare-mojo.html

Basically it allows you pass additional arguments to Maven calls including the profiles, such as -P linux,macosx.

jgifford25
A: 

Ok I found a way to do it:

In order to create a release, the maven-release-plugin runs the clean and verify goals before committing to the SCM. The verify goal tries to compile each module.

What I do now is configure the plugin so it only runs the verify goal. But since the verify is important anyway, I run it manually before doing the release under different environments. My release procedure is then as follows:

  1. run mvn clean verify in both a Mac and a Linux environment. For this I configured a multi-node hudson job.
  2. run mvn release:prepare -P macosx,linux -DdryRun=true -DpreparationGoals=clean, this activates both profiles but skips the compilation
  3. check that the dry-run results are satisfactory
  4. do step 2 with -DdryRun=false
YuppieNetworking