4

I'd like to have different configuration options for different goals of the Maven's release plugin. The story goes like this:

I'm using Git for an SCM. I want the release:prepare plugin to do everything locally and the release:perform to push all the changes at once to the remote repository.

I've tried doing something like this:

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-release-plugin</artifactId>
    <version>2.2.2</version>
    <executions>
        <execution>
            <id>release-prepare</id>
            <configuration>
                <pushChanges>false</pushChanges>
            </configuration>
            <goals>
                <goal>prepare</goal>
            </goals>
        </execution>
        <execution>
            <id>release-perform</id>
            <configuration>
                <localCheckout>true</localCheckout>
                <pushChanges>true</pushChanges>
            </configuration>
            <goals>
                <goal>perform</goal>
            </goals>
        </execution>
    </executions>
    <dependencies>
        <dependency>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-scm-plugin</artifactId>
            <version>1.7-SNAPSHOT</version>
        </dependency>
    </dependencies>
</plugin>

The 1.7-SNAPSHOT version is required for localCheckout=true to work at all (http://jira.codehaus.org/browse/SCM-662) if anyone is wondering about that.

With the settings mentioned above all the configuration options are ignored completely but when I simply specify the settings like this:

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-release-plugin</artifactId>
    <version>2.2.2</version>
    <configuration>
        <localCheckout>true</localCheckout>
        <pushChanges>false</pushChanges>
    </configuration>
    <dependencies>
        <dependency>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-scm-plugin</artifactId>
            <version>1.7-SNAPSHOT</version>
        </dependency>
    </dependencies>
</plugin>

they apply to both release:prepare as well as release:perform which is not the desired outcome.

Edit:

To make things clear: while we're using Git for SCM we'd like to have all the operations leading to the preparation of a release local which is not without reason if you take into account that the local Git repository is a full-fledged repo anyways. However when we do the actual release we'd like all the changes to be pushed to upstream repository so that everything is properly set.

Could anyone help me out with it?

Matthias Hryniszak
  • 3,099
  • 3
  • 36
  • 51

2 Answers2

0

In the case you need to change that you have to change the release plugin cause during the release:perform (goal!) the release plugin will checkout the tagged state of the project and call the deploy lifecycle on it. So this will not work.

EDIT: I have checkt that with a Git project and did a release on it and it is as i explained. During the release:prepare goal the changes will be pushed to the remote repository. During the release:perform goal nothing will be pushed to the remote repository only a clone will be done to checkout the tagged version.

khmarbaise
  • 92,914
  • 28
  • 189
  • 235
  • Would you mind sharing the plugin version you're using? I'm observing a push right at the point when I do mvn release:prepare. Also I'm using maven version 2.2.1 - can this be a maven version problem? – Matthias Hryniszak Feb 24 '12 at 15:34
  • Ah ..sorry didn't added the information release-plugin version 2.2.2 if you are using Maven 2.2.1 you should add a pluginManagement area in your pom or in your parent pom and define the release. Furthermore the push during release:prepare goal is ok. – khmarbaise Feb 24 '12 at 15:36
  • Well.. the push during release:prepare is exactly what I want not to happen - thus all the configuration fuzz. – Matthias Hryniszak Feb 26 '12 at 11:16
  • The configuration for this plugin clearly states that there are two configuration options: one for using local repository for checkout of release version and the other one to stop maven pushing changes to remote repository. And those settings are available for both goals, prepare and release. I wanted to explore the option of having releases done when they are really happening but obviously there is a problem with it. I ended up doing a 3-phase release: everything is done locally until I manually push changes to remote repository. – Matthias Hryniszak Feb 26 '12 at 11:38
-1

First i have to say that during the release:prepare goal all changes will be done in the SCM and not in the release:perform goal. So the question is why would like to do it in a such complicated (non maven) way ?

khmarbaise
  • 92,914
  • 28
  • 189
  • 235