Details
-
Type:
Bug
-
Status:
Closed
-
Priority:
Major
-
Resolution: Fixed
-
Affects Version/s: 1.2.1
-
Fix Version/s: 1.3
-
Labels:None
Description
I have a project with a dependency on both the jetty jar and the jetty tar.gz (one for compiling, the other due to details of our build system). I would also like to make a shaded jar that includes jetty jar. However, the following exception occurs (to reproduce, do a "mvn -e package" with the attached pom.xml):
[INFO] [shade:shade {execution: default}]
[INFO] Including org.mortbay.jetty:jetty:tar.gz:6.1.18 in the shaded jar.
[INFO] ------------------------------------------------------------------------
[ERROR] BUILD ERROR
[INFO] ------------------------------------------------------------------------
[INFO] Error creating shaded jar.
Embedded error: error in opening zip file
[INFO] ------------------------------------------------------------------------
[INFO] Trace
org.apache.maven.lifecycle.LifecycleExecutionException: Error creating shaded jar.
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:584)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalWithLifecycle(DefaultLifecycleExecutor.java:500)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoal(DefaultLifecycleExecutor.java:479)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalAndHandleFailures(DefaultLifecycleExecutor.java:331)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeTaskSegments(DefaultLifecycleExecutor.java:292)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute(DefaultLifecycleExecutor.java:142)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:336)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:129)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:301)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.codehaus.classworlds.Launcher.launchEnhanced(Launcher.java:315)
at org.codehaus.classworlds.Launcher.launch(Launcher.java:255)
at org.codehaus.classworlds.Launcher.mainWithExitCode(Launcher.java:430)
at org.codehaus.classworlds.Launcher.main(Launcher.java:375)
Caused by: org.apache.maven.plugin.MojoExecutionException: Error creating shaded jar.
at org.apache.maven.plugins.shade.mojo.ShadeMojo.execute(ShadeMojo.java:402)
at org.apache.maven.plugin.DefaultPluginManager.executeMojo(DefaultPluginManager.java:453)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:559)
... 16 more
Caused by: java.util.zip.ZipException: error in opening zip file
at java.util.zip.ZipFile.open(Native Method)
at java.util.zip.ZipFile.<init>(ZipFile.java:114)
at java.util.jar.JarFile.<init>(JarFile.java:133)
at java.util.jar.JarFile.<init>(JarFile.java:97)
at org.apache.maven.plugins.shade.DefaultShader.shade(DefaultShader.java:72)
at org.apache.maven.plugins.shade.mojo.ShadeMojo.execute(ShadeMojo.java:361)
... 18 more
If I remove the tar.gz dependency, it shades just fine. Unfortunately, I can't remove that depend without breaking other stuff.
Near as I can tell, the shade exclusion mechanism doesn't provide a way to exclude org.mortbay.jetty:jetty:tar.gz without also excluding org.mortbay.jetty:jetty:jar.
Seems like there are at least two possible solutions:
- ignore non-jar dependencies when shading
- provide a way to do more granular exclusion
Issue Links
- is related to
-
MSHADE-60
[PATCH] maven shade plugin fails if artifact dependencies contain artifacts that cannot be opened with JarFile class
-
Fixed in r894514 via support for more specific exclusions in the form groupId:artifactId:type:classifier.