How can I get maven-release-plugin to skip my tests?
Asked Answered
S

7

182

How can I get the maven-release-plugin to run without triggering the tests?

I have tried

-Dmaven.test.skip=true 

and

-DskipTests 

and

-DpreparationGoals=clean

...yet none work.

Yes, I know I shouldn't release if the tests don't pass, but I don't have control over making my coworkers write reliable tests.

Silkstocking answered 30/12, 2011 at 23:41 Comment(0)
C
413

-Darguments="-DskipTests" is what you want, or explicitly configuring the forked executions in the pom.

Casavant answered 31/12, 2011 at 0:3 Comment(4)
It works for me, thanks and +1 but ... Wny is this necessary?Ormsby
IT is necessary because the release process forks a new maven process, and the tpical -DskipTests are not passed along as system properties.Bonnett
wish I could vote you 2 up. I spent hours trying to get this right... but 1. Did I miss something in the documentation or is the mvn documentation missing something ? 2. I had <skipTests>true</skipTests> configured in my company POM. Still did not work. What worked was your solution.Breathing
Do you need some specific config in the pom to make this work?Vacua
P
42

-Darguments="..." passes arguments to the forked maven process, but it is important to realise that there are two different switches being used here. The -DskipTests forces maven to not run any tests, but the tests are still compiled (this is important if you have any dependencies on a test-jar type). The -Dmaven.test.skip=true forces maven to not even compile the tests, which means that any test-jars will not be generated.

So, you must use -Darguments, but to skip tests running use only skipTests, to stop them compiling use maven.test.skip.

Pyromancy answered 8/2, 2013 at 18:27 Comment(0)
C
21

If you just want to skip integration tests, this will do it:

-Darguments="-DskipITs"
Calcium answered 24/9, 2012 at 3:27 Comment(0)
B
4

you have too differents choices to avoid and skip tests with the release plugin

  • The first is to pass as argument on cli to the release goal or phases by providing a -Darguments:

exemple: mvn -X -Darguments="-Dmaven.javadoc.skip=true -Dmaven.test.skipTests=true -Dmaven.test.skip=true" -P release-mode release:prepare

-The second is to perform thoses arguments on your pom.xml in the build like this:

                <plugin>    
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-release-plugin</artifactId>
                    <dependencies>
                        <dependency>
                            <groupId>org.apache.maven.scm</groupId>
                            <artifactId>maven-scm-provider-gitexe</artifactId>
                            <version>1.9.4</version>
                        </dependency>
                    </dependencies>
                    <configuration>
                        <skip>true</skip>
                        <skipTests>true</skipTests>
                        <preparationGoals>clean validate</preparationGoals>
                        <arguments>-Dmaven.javadoc.skip=true -Dmaven.test.skipTests=true -Dmaven.test.skip=true</arguments>
                        <useReleaseProfile>false</useReleaseProfile>
                        <releaseProfiles>release-mode</releaseProfiles>
                        <tagNameFormat>TEST-@{project.version}</tagNameFormat>
                    </configuration>
                </plugin>

Note that the second method override the first.

I recommanded you to prepare release first on a single action and then you can edit the release.properties file on the working directorie and look the exec.additionalArguments properties if your arguments are there. It will look like: exec.additionalArguments=-Dmaven.javadoc.skip\=true -Dmaven.test.skipTests\=true -Dmaven.test.skip\=true -P release-mode.

After you can perform the release.

Byng answered 7/6, 2018 at 10:12 Comment(0)
E
1

I have managed to avoid running the verify goal by simply adding the configuration preparationGoals to clean:

<plugin>
  <groupId>org.apache.maven.plugins</groupId>
  <artifactId>maven-release-plugin</artifactId>
  <version>2.5.3</version>
  <configuration>
    <preparationGoals>clean</preparationGoals> <!-- See here -->
  </configuration>
</plugin>
Egger answered 9/7, 2021 at 9:10 Comment(0)
A
0

Use the following argument to skip test

-Darguments="-DskipTests"

or

alternatively skipping by default

 [...]
  <properties>
    <skipTests>true</skipTests>
  </properties>
  [...]
Admissive answered 28/6, 2016 at 7:39 Comment(1)
This question is specifically about the Maven release plugin, so these are not the Maven goals that will be used.Ivanna
C
0

When You use gitflow-maven-plugin to skip tests use skipTestProject : true inside configuration property (default value is false). Described in details in documentation : https://aleksandr-m.github.io/gitflow-maven-plugin/release-finish-mojo.html

example :

    <plugin>
        <groupId>com.amashchenko.maven.plugin</groupId>
        <artifactId>gitflow-maven-plugin</artifactId>
        <version>${gitflow.plugin.version}</version>
        <configuration>
            <skipTestProject>true</skipTestProject>
        </configuration>
    </plugin>
Cyclist answered 17/10, 2023 at 11:54 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.