88657

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.

<strong>Workaround:</strong>

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).

Answer1:

it is often very useful to build projects with enabled workspace resolution

I used to think the same... Obviously, it was pretty useful to be able to build project right from another project located in the current workspace. However, I quickly entered a nightmare with Eclipse, m2eclipse and Maven.

On one hand, Maven is supposed to find the project dependencies in a repository (local, central ...). On the other hand, m2eclipse "lures" Maven making it believe that a project located in the Eclipse workspace is a dependency in a well known Maven place (ie a repository).

This m2eclipse magic works great in some cases but in others... it just plainly fails (maven shade plugin is an example). Did you also notice that the option Resolve Workspace Artifacts is not activated by default?

To escape the nigthmare, I found it useful to <strong>always</strong> fetch my projects dependencies from a repository. If my project A depends on another project B in my workspace, I just install B in the local repository (Right click on the project B, Run as > Maven install. That's all).

I can see three advantages with this workaround:

    <li>No more nightmares</li> <li>No m2eclipse magic involved</li> <li>Full standard and conventional Maven way honored</li> </ul>

    You can see this approach as a little freedom eater. If you still really want to go with the nifty option Resolve Workspace Artifacts, send an issue to the m2eclipse team. Don't forget to prepare a sample project reproducing the problem.

Recommend

  • Whats the best way to bundle the whole project in Maven?
  • Pandas Merging 101
  • Wrapping a java command line application with launch4j and maven
  • UIVisualEffectView creates a grey box instead of blurring
  • Create ranking for vector of double
  • opengl: adding higher resolution mipmaps to a texture
  • Weird session behaviour in codeigniter
  • Getting IIS6 to play nice with WordPress Pretty Permalinks
  • integrate POCO library in android ndk
  • ZipList with Scalaz
  • Retaining data after updating application
  • “mvn clean generate-source” could not resolve dependencies
  • Implement JwtBearer Authentication in NSwag SwaggerUi
  • In Java, how can I construct a File from a resource?
  • How to handle elastic beanstalk deployment so it uploads only changed files
  • Android Studio Can't Find tools.jar
  • Filter strings with regex before casting to numeric
  • Does it make sense to call System.gc() and Thread.sleep() when working on Bitmaps?
  • How to define custom class, title, and target in Link Browser for content elements and the new rte_c
  • azure media services - The request body is too large and exceeds the maximum permissible limit
  • Ajax Loaded meta Tags
  • Initializer list vs. initialization method
  • Control modification in presentation layer
  • Xamarin Forms - UWP Fonts
  • Sails.js/waterline: Executing waterline queries in toJSON function of a model?
  • Fetching methods from BroadcastReceiver to update UI
  • Excel - Autoshape get it's name from cell (value)
  • Cross-Platform Protobuf Serialization
  • Check if a string to interpolate provides expected placeholders
  • Arrow is showed instead of the material design version hamburger icon. Why doesn't syncState in
  • RestKit - RKRequestDelegate does not exist
  • Arrays break string types in Julia
  • Traverse Array and Display in markup
  • How to format a variable of double type
  • coudnt use logback because of log4j
  • JaxB to read class hierarchy
  • Observable and ngFor in Angular 2
  • How to Embed XSL into XML
  • UserPrincipal.Current returns apppool on IIS
  • Conditional In-Line CSS for IE and Others?