shadow: shadow jar with > 65535 files fails

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':xxxxx:shadowJar'.
> org.apache.tools.zip.Zip64RequiredException: archive contains more than 65535 entries.

  To build this archive, please enable the zip64 extension.
  See: http://gradle.org/docs/2.1/dsl/org.gradle.api.tasks.bundling.Zip.html#org.gradle.api.tasks.bundling.Zip:zip64

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

BUILD FAILED

About this issue

  • Original URL
  • State: closed
  • Created 12 years ago
  • Reactions: 1
  • Comments: 15

Commits related to this issue

Most upvoted comments

It’s on shadowJar itself. The ShadowJarTask class extends Gradle’s Jar task. So any properties on it are available: http://www.gradle.org/docs/current/dsl/org.gradle.api.tasks.bundling.Jar.html

shadowJar {
  zip64 true
}

For anyone using the Gradle Kotlin-DSL, the above answers result in the following:

import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar<br/>

...

tasks {  
    "shadowJar"(ShadowJar::class) {  
        isZip64 = true  
    }  
}

for Kotlin DSL, if you applied shadow using plugins block now you can use the type-safe accessor for shadowJar task, it also uses lazy tasks API:

plugins {
   id("com.github.johnrengelman.shadow") version shadowVersion
}
tasks.shadowJar {
   isZip64 = true  
}

if you happened to follow this tutorial: https://www.artificialworlds.net/blog/2019/07/12/building-an-all-in-one-jar-in-gradle-with-the-kotlin-dsl/

you can add setZip64(true) as shown below:

$ cat build.gradle.kts import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar

plugins {      kotlin(“jvm”) version “1.3.41”      id(“com.github.johnrengelman.shadow”) version “5.1.0” }

repositories {      mavenCentral() }

dependencies {      implementation(kotlin(“stdlib”)) }

tasks.withType<ShadowJar>() {     setZip64(true)  // new code     manifest {         attributes[“Main-Class”] = “HelloKt”     } }

Have you tried enabling the zip64 option like the error says?

I am seeing the following error: java.util.zip.ZipException: central directory zip64 extended information extra field’s length doesn’t match central directory data. Expected length 0 but is 16

Not sure how to solve this. Any help would be appreciated.

@pkallos Where did you add the zip64 configuration? Can you paste your build.gradle here?