0

maven-jar-plugin fails with following error:

Failed to execute goal org.apache.maven.plugins:maven-jar-plugin:3.1.2:jar (default-jar) on project myProject: You have to use a classifier to attach supplemental artifacts to the project instead of replacing them.

I am using java 11. I upgraded maven-jar-plugin from 2.4 to 3.1.0.

It fails only on mvn clean install deploy. (without deploy it is running correctly).

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-jar-plugin</artifactId>
                <version>3.1.2</version>
                <executions>
                    <execution>
                        <goals>
                            <goal>test-jar</goal>
                        </goals>
                        <phase>test-compile</phase>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>

Any ideas?

Maria Dorohin
  • 355
  • 4
  • 17

2 Answers2

1

This plugin doesn't like to create empty jars. Try the

<skipIfEmpty>true</skipIfEmpty>

setting for flexibility, particularly in large multi module projects when this plug is inherited into many modules.

Antony Stubbs
  • 13,161
  • 5
  • 35
  • 39
0

use this line in your pom:

<packaging>jar</packaging>

This helped me for java 8.

Azadi Yazdani
  • 246
  • 1
  • 9