Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

maven-shade-plugin reports: Error creating shaded jar: ...target/classes (Is a directory)

When running a Maven build in eclipse using the m2eclipse tooling for a project that is configured for the Maven Shade Plugin, the build fails with the following error message:

Failed to execute goal org.apache.maven.plugins:maven-shade-plugin:2.4.3:shade (default) on project xxx: Error creating shaded jar: /.../project/target/classes (Is a directory) -> [Help 1]

I tried different versions of the Shade plugin and tried with different Java versions (6,7,8). All lead to the same error.

Workaround:

The solution for this question provides a workaround: The error only occurs if the option Resolve Workspace Artifacts is selected. If this option is not selected, the build runs fine.

(However, this does not solve the problem since it is often very useful to build projects with enabled workspace resolution).

like image 371
mxro Avatar asked Jun 21 '16 11:06

mxro


1 Answers

I found the issue and its resolution, the problem starts when trying to execute multiple phases in single command like mvn clean install -X test, if you run the single phase command like mvn test or mvn install its working. There is an issue with shaded plugin. These are the issues on apache site. https://issues.apache.org/jira/browse/MSHADE-295 and https://issues.apache.org/jira/browse/MSHADE-215 .

As per the issue, the shaded plugin wont work with multiple phases command. The plugin looks for the classes instead of jar with the name of jar and fails.

Hope this helps to someone.

like image 82
Atul Avatar answered Oct 11 '22 17:10

Atul