简体   繁体   English

在Maven版本准备更改pom.xml之前,如何运行Maven强制实施器规则?

[英]How to run a Maven enforcer rule before the Maven release prepare changes the pom.xml?

I've created a custom Maven enforcer rule . 我创建了一个自定义Maven强制实施器规则 This rule will check the content of the <scm><connection> value to ensure that it points to the trunk or branches/* (ie not a tag). 该规则将检查<scm><connection>值的内容,以确保它指向trunkbranches/* (即不是标记)。 This enforcer is configured in the pom.xml like that: 该执行器在pom.xml配置如下:

        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-enforcer-plugin</artifactId>
            <version>1.3.1</version>
            <dependencies>
                <dependency>
                    <groupId>my.company</groupId>
                    <artifactId>maven-release-enforcer</artifactId>
                    <version>1.0.0</version>
                </dependency>
            </dependencies>
            <executions>
                <execution>
                    <id>enforce-release-check</id>
                    <goals>
                        <goal>enforce</goal>
                    </goals>
                    <phase>validate</phase>
                    <configuration>
                        <rules>
                            <releaseCheck implementation="my.company.maven.release.enforcer.MavenReleaseEnforcer"/>
                        </rules>
                    </configuration>
                </execution>
            </executions>
        </plugin>

Unfortunately, when we use it with the Maven Release plugin, the latter plugin changes the content of the <scm><connection> value during its [enter link description here] prepare 2 goal, so before the enforcer is effectively called. 不幸的是,当我们将其与Maven Release插件一起使用时,后一个插件会在其[此处输入链接说明] prepare 2个目标期间更改<scm><connection>值的内容,因此在有效调用执行程序之前。 This results in a failure of my custom rule, as the <scm><connection> points to a tag at this time. 这导致我的自定义规则失败,因为<scm><connection>指向标签。

So my question: is there a way to force the enforcer to be called before the Maven Release plugin start to modify the pom.xml ? 所以我的问题是:在Maven Release插件开始修改pom.xml之前,是否有一种方法可以强制调用执行程序?

ps: the Jenkins job is divided into 2 steps: mvn clean release:prepare and mvn release:perform . ps:Jenkins作业分为两个步骤: mvn clean release:preparemvn release:perform

when you call 你打电话时

mvn clean release:prepare

only the clean phase and the prepare goal is excuted. 只有clean阶段和prepare目标才被执行。

You could use 你可以用

mvn clean validate release:prepare

to include the validate phase or 包括validate阶段或

mvn clean maven-enforcer-plugin:enforce release:prepare

to just trigger the enforcer plugin 只是触发执行器插件

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM