how to make maven release plugin skip tests?

2019-04-03 09:07发布

I'm running mvn release:prepare -Darguments="-Dmaven.test.skip=true -DskipTests" on the master checkout of Spotify's docker-client. But I can't get maven's release plugin to skip the tests. Why doesn't maven in this case respect the CLI flags?

I'm also curious what causes the release plugin to execute the surefire-plugin. There's no surefire-plugin specified in pom.xml.

mvn --version

Apache Maven 3.2.5 (12a6b3acb947671f09b81f49094c53f426d8cea1; 2014-12-14T12:29:23-05:00)
Maven home: /usr/local/Cellar/maven/3.2.5/libexec
Java version: 1.7.0_25, vendor: Oracle Corporation
Java home: /Library/Java/JavaVirtualMachines/jdk1.7.0_25.jdk/Contents/Home/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "mac os x", version: "10.10.2", arch: "x86_64", family: "mac"

4条回答
小情绪 Triste *
2楼-- · 2019-04-03 09:55

This worked for me. I wanted to both prepare and perform the release.

mvn clean -DskipTests -Darguments=-DskipTests release:prepare release:perform
查看更多
劳资没心,怎么记你
3楼-- · 2019-04-03 10:01

There are two things. First if you like to run a release you need to run mvn release:perform which really runs the step for the final release and not the mvn release:prepare. If you like to skip the tests in mvn release:prepare you should use mvn -Dmaven.test.skip=true plus the given arguments you have defined.

Apart from that maven-surefire-plugin is defined in the default life cylce

查看更多
放荡不羁爱自由
4楼-- · 2019-04-03 10:08

This works with Maven 3.6 (and probably some earlier versions).

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-release-plugin</artifactId>
    <version>2.5.3</version>
    <configuration>
        <arguments>-DskipTests</arguments>
    </configuration>
</plugin>
查看更多
Melony?
5楼-- · 2019-04-03 10:10

I have used the following in my pom.xml

        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-release-plugin</artifactId>
            <version>2.5.3</version>
            <configuration>
                <tagNameFormat>v@{project.version}</tagNameFormat>
                <arguments>-Dmaven.javadoc.skip=true -Dmaven.test.skipTests=true -Dmaven.test.skip=true</arguments>
            </configuration>
        </plugin>
查看更多
登录 后发表回答