Maven: Different configuration for different goals

久未见 提交于 2019-12-13 13:23:18

问题


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?


回答1:


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.




回答2:


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 ?



来源:https://stackoverflow.com/questions/9430104/maven-different-configuration-for-different-goals

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!