Maven JAR plugin (version 3.0.2) keeps throwing the following error, even for a single invocation of the jar
goal:
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-jar-plugin:3.0.2:jar (default) on project test: You have to use a classifier to attach supplemental artifacts to the project instead of replacing them. -> [Help 1]
Here's a (minimal?) pom.xml
which demonstrates the problem:
<project xmlns="http://maven.apache.org/POM/4.0.0">
<modelVersion>4.0.0</modelVersion>
<groupId>test</groupId>
<artifactId>test</artifactId>
<version>1.0.0-SNAPSHOT</version>
<build>
<plugins>
<plugin>
<artifactId>maven-jar-plugin</artifactId>
<version>3.0.2</version>
<executions>
<execution>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
The invocation is just mvn package
.
- It doesn't seem to matter whether there are any classes/resources at all — the above error message appears anyway.
- The problem also appears if two goals are specified (
jar
andtest-jar
). - The problem does NOT appear if no goals are specified. But this is not an option, since I really need both
jar
andtest-jar
.
According to the documentation, classifier
only needs to be specified on multiple invocations of the same goal, and there's a reasonable default for the test-jar
goal which I don't intend to change.
Also, the problem doesn't seem to appear on the 2.x line of the JAR plugin.
Did I miss something? Could anybody please suggest what I am doing wrong?
P.S. The Maven version is 3.3.9.