Multi project build: "gradle jar" -> "Could not create ZIP..."


(uli.heller) #1

My multi project build target “jar” fails with the error message “Could not create ZIP …”. The setup is simple:

  • Project1: Simple java project - gradle works fine here * Project2: Basically a copy of Project1 - gradle works fine * Project3: Another copy * Project4: Contains just a “settings.gradle” which includes projects 1,2 and 3

Within Project4, executing ‘gradle check’ works fine. Basically, it seems to execute ‘gradle check’ in all other projects.

Unfortunately, ‘gradle jar’ doesn’t work within Project4. It creates this output:

gradle.sh jar
:../01-java-quickstart:compileJava
:../01-java-quickstart:processResources UP-TO-DATE
:../01-java-quickstart:classes
:../01-java-quickstart:jar FAILED
  FAILURE: Build failed with an exception.
  * What went wrong:
Execution failed for task ':../01-java-quickstart:jar'.
> Could not create ZIP '/home/uli/git/uli-gradle/01-java-quickstart/build/libs/../01-java-quickstart.jar'.
  * Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
  BUILD FAILED
  Total time: 4.914 secs

When you do a ‘mkdir -p …/01-java-quickstart/build/libs’ before executing ‘gradle jar’, the failure moves to the 2nd project:

$ mkdir -p ../01-java-quickstart/build/libs
$ gradle.sh jar:../01-java-quickstart:compileJava UP-TO-DATE
:../01-java-quickstart:processResources UP-TO-DATE
:../01-java-quickstart:classes UP-TO-DATE
:../01-java-quickstart:jar
:../02-java-quickstart-gradlew:compileJava
:../02-java-quickstart-gradlew:processResources UP-TO-DATE
:../02-java-quickstart-gradlew:classes
:../02-java-quickstart-gradlew:jar FAILED
  FAILURE: Build failed with an exception.
  * What went wrong:
Execution failed for task ':../02-java-quickstart-gradlew:jar'.
> Could not create ZIP '/home/uli/git/uli-gradle/02-java-quickstart-gradlew/build/libs/../02-java-quickstart-gradlew.jar'.
  * Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
  BUILD FAILED
  Total time: 3.362 secs

I’ve done this with gradle-1.4 and 1.5-rc-1.


(Peter Niederwieser) #2

Please provide the stack trace (ideally as a GitHub Gist), settings.gradle, and directory layout.


(uli.heller) #3

Hi Peter,

the stack trace is here: https://gist.github.com/uli-heller/5176745

“settings.gradle” lokks like this:

include '../010-java-quickstart',
        '../020-java-quickstart-gradlew',
        '../030-gradle-wrapper'

The directory layout is this:

010-java-quickstart
010-java-quickstart/src
010-java-quickstart/src/main
010-java-quickstart/src/main/java
010-java-quickstart/src/main/java/org
010-java-quickstart/src/main/java/org/uli
010-java-quickstart/src/main/java/org/uli/httpcat
010-java-quickstart/src/main/java/org/uli/httpcat/HttpCat.java
010-java-quickstart/build.gradle
020-java-quickstart-gradlew
020-java-quickstart-gradlew/gradlew
020-java-quickstart-gradlew/gradlew.bat
020-java-quickstart-gradlew/src
020-java-quickstart-gradlew/src/main
020-java-quickstart-gradlew/src/main/java
020-java-quickstart-gradlew/src/main/java/org
020-java-quickstart-gradlew/src/main/java/org/uli
020-java-quickstart-gradlew/src/main/java/org/uli/httpcat
020-java-quickstart-gradlew/src/main/java/org/uli/httpcat/HttpCat.java
020-java-quickstart-gradlew/gradle
020-java-quickstart-gradlew/gradle/wrapper
020-java-quickstart-gradlew/gradle/wrapper/gradle-wrapper.jar
020-java-quickstart-gradlew/gradle/wrapper/gradle-wrapper.properties
020-java-quickstart-gradlew/build.gradle
030-gradle-wrapper
030-gradle-wrapper/gradlew
030-gradle-wrapper/gradlew.bat
030-gradle-wrapper/src
030-gradle-wrapper/src/main
030-gradle-wrapper/src/main/java
030-gradle-wrapper/src/main/java/org
030-gradle-wrapper/src/main/java/org/uli
030-gradle-wrapper/src/main/java/org/uli/httpcat
030-gradle-wrapper/src/main/java/org/uli/httpcat/HttpCat.java
030-gradle-wrapper/gradle
030-gradle-wrapper/gradle/wrapper
030-gradle-wrapper/gradle/wrapper/gradle-wrapper.jar
030-gradle-wrapper/gradle/wrapper/gradle-wrapper.properties
030-gradle-wrapper/build.gradle
040-multi-project
040-multi-project/settings.gradle

The error shows up when I do

  • cd 040-multi-project * gradle jar

The project is actually available on Github - https://github.com/uli-heller/uli-gradle.git

The error does not show up when I do

  • cp 040-multi-project/settings.gradle . * sed -i s,\.\./, settings.gradle * gradle jar

So I guess it is caused by “…/” showing up within settings.gradle, isn’t it?

Best regards, Uli