Hello,
When I use shadow plugin I am getting following exception:
Caused by: org.gradle.api.GradleException: Could not create ZIP '/Users/Badyl/Projects/example/release/build/libs/example-shadow.jar'
at com.github.jengelman.gradle.plugins.shadow.tasks.ShadowCopyAction.execute(ShadowCopyAction.groovy:71)
at org.gradle.api.internal.file.copy.NormalizingCopyActionDecorator.execute(NormalizingCopyActionDecorator.java:52)
at org.gradle.api.internal.file.copy.DuplicateHandlingCopyActionDecorator.execute(DuplicateHandlingCopyActionDecorator.java:42)
at org.gradle.api.internal.file.copy.CopyActionExecuter.execute(CopyActionExecuter.java:38)
at org.gradle.api.tasks.AbstractCopyTask.copy(AbstractCopyTask.java:83)
at com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar.copy(ShadowJar.java:70)
at org.gradle.internal.reflect.JavaMethod.invoke(JavaMethod.java:75)
at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$StandardTaskAction.doExecute(AnnotationProcessingTaskFactory.java:227)
at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$StandardTaskAction.execute(AnnotationProcessingTaskFactory.java:220)
at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$StandardTaskAction.execute(AnnotationProcessingTaskFactory.java:209)
at org.gradle.api.internal.AbstractTask$TaskActionWrapper.execute(AbstractTask.java:585)
at org.gradle.api.internal.AbstractTask$TaskActionWrapper.execute(AbstractTask.java:568)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeAction(ExecuteActionsTaskExecuter.java:80)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:61)
... 60 more
Caused by: org.gradle.api.UncheckedIOException: Unable to create ZIP output stream for file /Users/Badyl/Projects/example/release/build/libs/example-shadow.jar.
at com.github.jengelman.gradle.plugins.shadow.internal.DefaultZipCompressor.createArchiveOutputStream(DefaultZipCompressor.groovy:41)
at com.github.jengelman.gradle.plugins.shadow.internal.ZipCompressor$createArchiveOutputStream.call(Unknown Source)
at com.github.jengelman.gradle.plugins.shadow.tasks.ShadowCopyAction.execute(ShadowCopyAction.groovy:69)
... 73 more
Caused by: groovy.lang.MissingMethodException: No signature of method: org.apache.tools.zip.ZipOutputStream.setUseZip64() is applicable for argument types: (org.apache.tools.zip.Zip64Mode) values: [Never]
at com.github.jengelman.gradle.plugins.shadow.internal.DefaultZipCompressor.createArchiveOutputStream(DefaultZipCompressor.groovy:36)
... 75 more
So apparently I have org.apache.tools.zip.ZipOutputStream
on classpath which is missing setUseZip64
method. I tried it with Gradle 2.14.1 and 3.0.
When I do:
gradle buildEnvironment
I get
classpath
+--- com.github.jengelman.gradle.plugins:shadow:1.2.3
| +--- org.jdom:jdom2:2.0.5
| +--- org.ow2.asm:asm:5.0.3
| +--- org.ow2.asm:asm-commons:5.0.3
| | \--- org.ow2.asm:asm-tree:5.0.3
| | \--- org.ow2.asm:asm:5.0.3
| +--- commons-io:commons-io:2.4
| +--- org.apache.ant:ant:1.9.4
| | \--- org.apache.ant:ant-launcher:1.9.4
| +--- org.codehaus.plexus:plexus-utils:2.0.6
| \--- org.codehaus.groovy:groovy-backports-compat23:2.4.4
+--- clojuresque:clojuresque:1.6.0
| \--- de.kotka.gradle:gradle-utils:0.2.3
| \--- de.kotka.groovy:zweig:0.4.0
| \--- org.codehaus.groovy:groovy:1.8.9
| +--- antlr:antlr:2.7.7
| +--- asm:asm:3.2
| +--- asm:asm-commons:3.2
| | \--- asm:asm-tree:3.2
| | \--- asm:asm:3.2
| +--- asm:asm-util:3.2
| | \--- asm:asm-tree:3.2 (*)
| +--- asm:asm-analysis:3.2
| | \--- asm:asm-tree:3.2 (*)
| \--- asm:asm-tree:3.2 (*)
\--- com.example:common-build:1.0.3
It shows ant:1.9.4
which is fine as it contains org.apache.tools.zip.ZipOutputStream.setUseZip64
method.
However, when I run following task:
task show << {
buildscript.configurations.classpath.findAll { it.getAbsolutePath().contains("org.apache.ant") }.each { println "Classpath file: $it" }
if (org.apache.tools.zip.ZipOutputStream.class.getDeclaredMethods().find { it.name.contains("setUseZip64") }) {
println "Found setUseZip64 method"
} else {
println "No setUseZip64 method"
}
org.apache.tools.zip.ZipOutputStream.class.classLoader.getURLs().findAll { it.toString().contains("org.apache.ant") }.each { println "Classpath URL: $it" }
}
I am getting:
Classpath file: /Users/Badyl/.gradle/caches/modules-2/files-2.1/org.apache.ant/ant/1.9.4/6d473e8653d952045f550f4ef225a9591b79094a/ant-1.9.4.jar
Classpath file: /Users/Badyl/.gradle/caches/modules-2/files-2.1/org.apache.ant/ant-launcher/1.9.4/334b62cb4be0432769679e8b94e83f8fd5ed395c/ant-launcher-1.9.4.jar
No setUseZip64 method
Classpath URL: file:/Users/Badyl/.gradle/caches/modules-2/files-2.1/org.apache.ant/ant/1.8.2/fc33bf7cd8c5309dd7b81228e8626515ee42efd9/ant-1.8.2.jar
Classpath URL: file:/Users/Badyl/.gradle/caches/modules-2/files-2.1/org.apache.ant/ant-launcher/1.8.2/6a5466384e7e2086b13d3d281dadaa059b0d0923/ant-launcher-1.8.2.jar
so as you can see there is a different version (1.8.2) effectively visible on classpath. There must be something adding older version to classpath.
Do you have any hints how I can troubleshoot this issue and trace where the incorrect ant version comes from?
Best regards,
Piotr