The maven-jar-plugin
does not provide any skip option.
However, several ways are possible to achieve your requirement.
You may just skip the phase which brings by default (via default mappings) the jar creation, that is, the package
phase, and as such simply invoke
mvn clean test
The additional phases would not make sense if you do not create a jar file anyway: package
, install
, deploy
would not have anything to process. Moreover, the additional integration phases may also be impacted depending on your strategy for integration tests, if any.
Alternatively, you can configure your pom as following:
<properties>
<jar.creation>package</jar.creation>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>3.0.0</version>
<executions>
<execution>
<id>default-jar</id>
<phase>${jar.creation}</phase>
</execution>
</executions>
</plugin>
</plugins>
</build>
As such, the default behavior would still provide a jar creation, while executing maven as following:
mvn clean install -Djar.creation=false
Would instead skip the creation of the jar.
What we are actually doing:
- We are re-defining the default execution of the
maven-jar-plugin
- We are overriding its execution id, as such getting more control over it
- We are placing its execution phase binding to a configurable (via property) phase
- Default phase (property value) keeps on being
package
- At command line time you can still change it to any value different than a standard maven phase. That is,
-Djar.creation=none
would also work.