Normalize path (fat jar creation) fails because file path is too long


(Stephan Pfab) #1

the attempt to create a fat jar calls normalize path with fails because the path name is too long.

task: jar {

manifest {

attributes ‘Implementation-Title’: ‘stroy’, ‘Implementation-Version’: version

from { configurations.runtime.collect { it.isDirectory() ? it : zipTree(it) } }

} }

error:

Caused by: org.gradle.api.UncheckedIOException: Could not normalize path for file ‘/Users/stephan/Documents/privat/svn/projects/stroy/[ZIP ‘/Users/stephan/Documents/privat/svn/repo/net/jcip/jcip-annotations/1.0/jcip-annotations-1.0.jar’, ZIP ‘/Users/stephan/Documents/privat/svn/repo/com/intellij/annotations/7.0.3/annotations-7.0.3.jar’, ZIP ‘/Users/stephan/Documents/privat/svn/repo/commons-cli/commons-cli/1.2/commons-cli-1.2.jar’, ZIP ‘/Users/stephan/Documents/privat/svn/repo/muchsoft/sys/1.0/Sys-1.0.jar’, ZIP ‘/Users/stephan/Documents/privat/svn/repo/com/thoughtworks/xstream/xstream/1.3.1/xstream-1.3.1.jar’, ZIP ‘/Users/stephan/Documents/privat/svn/repo/net/sourceforge/mydoggy/mydoggy-api/1.3.1/mydoggy-api-1.3.1.jar’, ZIP ‘/Users/stephan/Documents/privat/svn/repo/net/sourceforge/mydoggy/mydoggy-plaf/1.3.1/mydoggy-plaf-1.3.1.jar’, ZIP ‘/Users/stephan/Documents/privat/svn/repo/net/sourceforge/mydoggy/mydoggy-res/1.3.1/mydoggy-res-1.3.1.jar’, ZIP ‘/Users/stephan/Documents/privat/svn/repo/net/java/dev/designgridlayout/designgridlayout/0.9/designgridlayout-0.9.jar’, ZIP ‘/Users/stephan/Documents/privat/svn/projects/osashosa/build/libs/osashosa-0.4.0.jar’, ZIP ‘/Users/stephan/Documents/privat/svn/projects/openCage-lang/build/libs/openCage-lang-0.9.8.jar’, ZIP ‘/Users/stephan/Documents/privat/svn/repo/xpp3/xpp3_min/1.1.4c/xpp3_min-1.1.4c.jar’, ZIP ‘/Users/stephan/Documents/privat/svn/repo/net/java/dev/swing-layout/swing-layout/1.0.2/swing-layout-1.0.2.jar’]’. 15:27:06.203 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.api.internal.file.AbstractFileResolver.normalise(AbstractFileResolver.java:117) 15:27:06.203 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.api.internal.file.AbstractFileResolver.resolve(AbstractFileResolver.java:58) 15:27:06.203 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.api.internal.file.AbstractFileResolver.resolve(AbstractFileResolver.java:52) 15:27:06.203 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.api.java.archives.internal.DefaultManifest.read(DefaultManifest.java:203) 15:27:06.203 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.api.java.archives.internal.DefaultManifest.(DefaultManifest.java:52) 15:27:06.203 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.api.java.archives.internal.DefaultManifestMergeSpec.createManifest(DefaultManifestMergeSpec.java:116) 15:27:06.203 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.api.java.archives.internal.DefaultManifestMergeSpec.merge(DefaultManifestMergeSpec.java:55) 15:27:06.203 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.api.java.archives.internal.DefaultManifest.getEffectiveManifestInternal(DefaultManifest.java:144) 15:27:06.204 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.api.java.archives.internal.DefaultManifest.getEffectiveManifest(DefaultManifest.java:138) 15:27:06.204 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.api.java.archives.internal.DefaultManifest.writeTo(DefaultManifest.java:152) 15:27:06.204 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.api.java.archives.internal.DefaultManifest.writeTo(DefaultManifest.java:36) 15:27:06.204 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.api.java.archives.Manifest$writeTo.call(Unknown Source) 15:27:06.204 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.api.tasks.bundling.Jar$_closure1_closure3.doCall(Jar.groovy:48) 15:27:06.204 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.api.internal.file.collections.MapFileTree$FileVisitDetailsImpl.copyTo(MapFileTree.java:151) 15:27:06.204 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.api.internal.file.AbstractFileTreeElement.copyFile(AbstractFileTreeElement.java:82) 15:27:06.204 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.api.internal.file.AbstractFileTreeElement.copyTo(AbstractFileTreeElement.java:63) 15:27:06.205 [ERROR] [org.gradle.BuildExceptionReporter] … 62 more 15:27:06.205 [ERROR] [org.gradle.BuildExceptionReporter] Caused by: java.io.IOException: File name too long 15:27:06.205 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.api.internal.file.AbstractFileResolver.normalise(AbstractFileResolver.java:99) 15:27:06.205 [ERROR] [org.gradle.BuildExceptionReporter] … 77 more


(Luke Daley) #2

Your code is wrong. You have:

jar {
   manifest {
     attributes 'Implementation-Title': 'stroy', 'Implementation-Version': version
     from { configurations.runtime.collect { it.isDirectory() ? it : zipTree(it) } }
   }
 }

It should be:

jar {
   manifest {
     attributes 'Implementation-Title': 'stroy', 'Implementation-Version': version
   }
  from { configurations.runtime.collect { it.isDirectory() ? it : zipTree(it) } }
  }

(Eugene Janusov) #3

@Luke: ‘from’ placement isn’t related to the problem. Generated names of the temporary files are too long. ext4 file system, for instance, has a maximum of 255 characters.


(Luke Daley) #4

Do you have a self contained project that exhibits this that I can use?


(Luke Daley) #5

Looking at this with fresh eyes… I think the problem is that from does not deal with a collection of zipTree() objects correctly.

However, I cannot reproduce this with Gradle 1.3.


(Eugene Janusov) #6

@Luke: Here’s one: http://goo.gl/pS2ky Try to run ‘gradle fatJar’ on an ext4 partition.


(René Groeschke) #7

Hello Eugene,

I just copied your script into a build.gradle file. Unfortunately I can’t reproduce the issue you’re running into on a ext4 partition.

cheers, René


(Pawan Yadav) #8

For such problems, you can use Long Path Tool as well, it works good I will say.