Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

People also ask

How do I skip the Maven test?

To skip running the tests for a particular project, set the skipTests property to true. You can also skip the tests via the command line by executing the following command: mvn install -DskipTests.

How does Maven release plugin work?

The main aim of the maven-release plugin is to provide a standard mechanism to release project artifacts outside the immediate development team. The plugin provides basic functionality to create a release and to update the project's SCM accordingly.

How do you skip an integration test?

If, instead, you want to skip only the integration tests being run by the Failsafe Plugin, you would use the skipITs property instead: mvn install -DskipITs.

Why tests are skipped Maven surefire plugin?

When the Surefire plugin reaches the test goal, it will skip the unit tests if the maven. test. skip properties is set to true . Another way to configure Maven to skip unit tests is to add this configuration to your project's pom.


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


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


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

-Darguments="-DskipITs"

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.