how to make maven release plugin skip tests?

后端 未结 5 2013
感动是毒
感动是毒 2021-02-03 19:59

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 re

相关标签:
5条回答
  • 2021-02-03 20:26

    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

    0 讨论(0)
  • 2021-02-03 20:26

    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>
    
    0 讨论(0)
  • 2021-02-03 20:38

    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>
    
    0 讨论(0)
  • 2021-02-03 20:39

    This is one of the first hits in google for this problem and yet doesn't have the most likely explanation and solution, so here is my attempt.

    I faced the same issue as the OP in running release:prepare with -DskipTests passed in via -Darguments not getting recognized. After digging in, I noticed that a grandparent POM (parent of the parent) has the following config:

            <plugin>
              <groupId>org.apache.maven.plugins</groupId>
              <artifactId>maven-release-plugin</artifactId>
              <version>2.5.2</version>
              <configuration>
                <arguments>-B</arguments>
              </configuration>
            </plugin>
    
    

    It actually has more config, but I only show what is most relevant for this problem, which is the <arguments>-B</arguments>. This is hardcoding the arguments configuration parameter to -B instead of letting it read the arguments property. To get around, I added the below in the project pom and it started working:

            <plugin>
              <groupId>org.apache.maven.plugins</groupId>
              <artifactId>maven-release-plugin</artifactId>
              <configuration>
                <arguments>$(arguments)</arguments>
              </configuration>
            </plugin>
    
    0 讨论(0)
  • 2021-02-03 20:41

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

    mvn clean -DskipTests -Darguments=-DskipTests release:prepare release:perform
    
    0 讨论(0)
提交回复
热议问题