Maven:针对不同目标的不同配置 [英] Maven: Different configuration for different goals

查看:102
本文介绍了Maven:针对不同目标的不同配置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想针对Maven发行插件的不同目标提供不同的配置选项.故事是这样的:

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

我正在将Git用于SCM.我希望release:prepare插件在本地执行所有操作,并希望release:perform将所有更改立即推送到远程存储库.

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.

我试图做这样的事情:

<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>

如果有人想知道,那么localCheckout = true必须使用1.7-SNAPSHOT版本(http://jira.codehaus.org/browse/SCM-662).

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>

它们既适用于release:prepare也适用于release:perform,这不是期望的结果.

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

修改:

要弄清楚点:当我们将Git用于SCM时,我们希望所有操作都可以导致准备发布本地版本,如果您考虑到本地Git存储库是一个本地版本,那不是没有道理的无论如何,都是成熟的回购协议.但是,当我们进行实际发布时,我们希望将所有更改都推送到上游存储库中,以便正确设置所有内容.

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.

有人可以帮我吗?

推荐答案

在需要更改的情况下,您必须在release:perform(目标!)期间更改release插件的原因.项目的名称,并在其上调用部署生命周期.所以这行不通.

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.

我已经对Git项目进行了检查,并对其进行了发布,这就是我所解释的.在release:prepare目标期间,更改将被推送到远程存储库.在release:perform目标期间,不会将任何内容推送到远程存储库,而只会执行克隆操作以检出标记的版本.

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.

这篇关于Maven:针对不同目标的不同配置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆