apache / apache/maven-shade-plugin
[MSHADE-215] Failed to execute goal org.apache.maven.plugins:maven-shade-plugin:2.3:shade (default) on project mshade171-ui: Error creating shaded jar: /tmp/shade/mshade171-base/target/classes (Ist ein Verzeichnis) -> [Help 1]
- Dominant language
- Java
- Stars
- 188
- Forks
- 103
- Avg merge
- 16h 39m
- Merged PRs (30d)
- 4
Description
**[Dominik Stadler](https://issues.apache.org/jira/secure/ViewProfile.jspa?name=centic)** opened **[MSHADE-215](https://issues.apache.org/jira/browse/MSHADE-215?redirect=false)** and commented
MSHADE-171 reported a problem with locked files when running on Windows. The same sample project fails for me with a different error message when I run the steps "package test" on Linux. I tried using the latest 2.4.3-SNAPSHOT version which should have fixes for MSHADE-171.
The error-output is listed below.
Calling "mvn package" or "mvn test" works, it only fails if both goals/phases are executed in one command.
I tried to debug this and found that in the error-case in the code at `ShadeMojo.processArtifactSelectors()` the call to `project.getArtifacts()` returns an Artifact which has the file-path to the `classes` directory, but has `Artifact.getType() == "jar"`.
It seems running the test goal/phase adds this Artifact and the shade-plugin does not handle this correctly as it expects all Artifacts to be jars, not directories.
Let me know if I can provide more information. I am attaching the same sample-project that was used in MSHADE-171 as it can be used to reproduce this problem as well.
```
[INFO] Reactor Summary:
[INFO]
[INFO] mshade171 ......................................... SUCCESS [0.003s]
[INFO] mshade171-base .................................... SUCCESS [1.596s]
[INFO] mshade171-ui ...................................... FAILURE [0.697s]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2.488s
[INFO] Finished at: Fri Nov 27 21:24:34 CET 2015
[INFO] Final Memory: 10M/211M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-shade-plugin:2.4.3-SNAPSHOT:shade (default) on project mshade171-ui: Error creating shaded jar: /tmp/shade/mshade171-base/target/classes (Ist ein Verzeichnis) -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.maven.plugins:maven-shade-plugin:2.4.3-SNAPSHOT:shade (default) on project mshade171-ui: Error creating shaded jar: /tmp/shade/mshade171-base/target/classes (Ist ein Verzeichnis)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:217)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:84)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:59)
at org.apache.maven.lifecycle.internal.LifecycleStarter.singleThreadedBuild(LifecycleStarter.java:183)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:161)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:320)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:156)
at org.apache.maven.cli.MavenCli.execute(MavenCli.java:537)
at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:196)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:141)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
Caused by: org.apache.maven.plugin.MojoExecutionException: Error creating shaded jar: /tmp/shade/mshade171-base/target/classes (Ist ein Verzeichnis)
at org.apache.maven.plugins.shade.mojo.ShadeMojo.execute(ShadeMojo.java:539)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:101)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:209)
... 19 more
Caused by: java.io.FileNotFoundException: /tmp/shade/mshade171-base/target/classes (Ist ein Verzeichnis)
at java.util.zip.ZipFile.open(Native Method)
at java.util.zip.ZipFile.(ZipFile.java:219)
at java.util.zip.ZipFile.(ZipFile.java:149)
at java.util.jar.JarFile.(JarFile.java:166)
at java.util.jar.JarFile.(JarFile.java:130)
at org.apache.maven.plugins.shade.DefaultShader.newJarFile(DefaultShader.java:351)
at org.apache.maven.plugins.shade.DefaultShader.goThroughAllJarEntriesForManifestTransformer(DefaultShader.java:261)
at org.apache.maven.plugins.shade.DefaultShader.shade(DefaultShader.java:98)
at org.apache.maven.plugins.shade.mojo.ShadeMojo.execute(ShadeMojo.java:454)
... 21 more
[ERROR]
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
[ERROR]
[ERROR] After correcting the problems, you can resume the build with the command
[ERROR] mvn -rf :mshade171-ui
```
---
**Affects:** 2.4.2
**Attachments:**
- [MSHADE-171.zip](https://issues.apache.org/jira/secure/attachment/12774664/MSHADE-171.zip) (_3.06 kB_)
1 votes, 6 watchers
Contributor guide
No contributing guide indexed for this repository
Research direction
Reproduce the failure with the attached MSHADE-171 sample using `mvn package test`, then inspect `ShadeMojo.processArtifactSelectors()` and the `DefaultShader.newJarFile()` path shown in the stack trace. Done means the combined goals no longer try to process `/target/classes` as a jar, while `mvn package` and `mvn test` continue to work.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- build-system
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100