How to build a jar using maven, ignoring test results? [duplicate] How to build a jar using maven, ignoring test results? [duplicate] java java

How to build a jar using maven, ignoring test results? [duplicate]


Please refer to surefire:test for details, but the most useful properties are:

-Dmaven.test.failure.ignore=true (or -DtestFailureIgnore=true) - will ignore any failures occurred during test execution

-Dmaven.test.error.ignore=true ( deprecated ) - will ignore any errors occurred during test execution

-DskipTests - would compile the test classes but skip test execution entirely

-Dmaven.test.skip=true - would not even compile the tests

I believe that in your case where you want to compile test classes but not fail the build due to any tests errors and still create the jar.

You should use the first option to ignore any test failures which you can still review once the build has finished.


mvn -Dmaven.test.skip=true package skips the surefire test mojo.

to ignore test failures and keep maven from stopping you can add this to the section of the pom.xml:

 <plugin>   <groupId>org.apache.maven.plugins</groupId>   <artifactId>maven-surefire-plugin</artifactId>   <configuration>     <testFailureIgnore>true</testFailureIgnore>   </configuration> </plugin>


The solution is:

mvn -fn clean install

execute mvn --help for advanced options

Here's the excerpt for -fn

 -fn,--fail-never         NEVER fail the build, regardless                          of project result