Gradle 1.8 results in a non working build, while same code works fine with Gradle 1.7


(Martin Odhelius) #1

I have an application that is running a Restlet server with a Ebean connection to the database. When building this application with Gradle 1.7 and deploy it to production everything works fine. But when I try to build the same application with Gradle 1.8 it freezes with 100% CPU (on a NIO thread). The only difference between the working version and the non working version is that the working version is built with Gradle 1.7. First I thought it could have anything to do with any corrupt jar-file in the dependency cache for Gradle 1.8, but even when I have flushed the cache I get the same problem. Please, do anyone have a clue what can be causing this?


(Martin Odhelius) #2

I just the jar task to build a fat jar. When I compare the files inside the jars I notice that the classes in javax\servlets is different. How can this happen?


(Luke Daley) #3

This is likely this: http://www.gradle.org/docs/current/release-notes#the-order-of-resolved-files-and-artifacts-has-changed

You’ve likely got multiple jars providing the servlet classes. You should use excludes (or another mechanism) to ensure that you only get the version you want on the classpath.


(Martin Odhelius) #4

I just the jar task to build a fat jar. When I compare the files inside the jars I notice that the classes in javax\servlets is different. How can this happen?


(Martin Odhelius) #5

But why do I get different dependencies between different versions of Gradle?


(Luke Daley) #6

Because of that ordering change I linked to.

If this is indeed the cause, It’s unfortunate that this change has bitten you so hard. However, this was a ticking time bomb as there are number of different potential changes that you could have made to your build config that would have made this surface. The only truly safe solution is to ensure you don’t have duplicate versions of these classes on the classpath at all.

You should consider managing duplicates for your fatjar…

task fatjar(type: Jar) {
   …
   duplicatesStrategy "fail"
}

http://www.gradle.org/docs/current/dsl/org.gradle.api.tasks.Copy.html#org.gradle.api.tasks.Copy:duplicatesStrategy


(Martin Odhelius) #7

Ok, then I see. Thank you for your help. I do not have any dependency to javax myself so it is probably some of my dependencies that depend on different version of it. I will try your trick to fail upon duplicates. Thanks.


(Luke Daley) #8

No problem, good luck.