Order of resolved dependencies


(Stefan Marklund) #1

Hello all,

I have a problem regarding how Gradle does its dependency resolution. It has been posted before but I have not seen a yay or nay regarding any additions/improvements.

I need the classpath to be resolved in the order as dependencies are stated. The codebase I am working on moving to Gradle as build system is using shadowing of classes as a means to add more functionality as we progress through the modules towards customer projects.

This was probably not the best design decision as it makes classpath handling crucial (and painful). It is rooted too deep now to change easily.

In Gradle when specifying project dependencies as below there is no way to guarantee the order:

dependencies {
    compile project(':A')
    compile project(':B')
    compile project(':C')
}

I would like to see A with its resolved dependencies followed by B with its dependencies followed by C as the resolved classpath.

Other post: http://forums.gradle.org/gradle/topics/how_do_i_control_the_order_of_compiletime_classpaths

Are there any plans to review/improve the way dependencies are resolved? I am unlikely to be the only one with dependencies for which the order they are stated needs to be honored.

If I have to write a workaround for this do you have any tips on where to begin? We use project, external library and file dependencies.

Thank you, Stefan

Edit: Fixed line breaks and added compile in dependencies.


(Szczepan Faber) #2

Hello,

Here’s what I would try:

configurations {
  projectA
  projectB
}
  dependencies {
  projectA project(":A")
  projectB project(":B")
  compile ...
}
  sourceSets.main.compileClasspath = configurations.projectA + configurations.projectB
+ sourceSets.main.compileClasspath

Hope that helps!


(Stefan Marklund) #3

Hi Szczepan,

Thank you for the feedback.

I will test it out as soon as I can. I’ll come back with findings / follow-up questions.

/ Stefan