Getting Started with Maven | Others | Package Without Tests
When you run Maven’s package task, the project’s tests are also executed. This time, we will look at how to package without running tests.
Skipping Tests When Running Maven
You can skip tests by adding the -DskipTests=true option when running mvn. The command is as follows.
> mvn package -DskipTests=true
Skipping Tests with pom.xml Settings
It can be inconvenient to add the option every time you run the command. In that case, you can set the maven.test.skip property to true in pom.xml, so tests are skipped by default when running mvn.
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
... omitted ...
<properties>
<maven.test.skip>true</maven.test.skip>
</properties>
... omitted ...
</project>