Mutli-project with classpath ordering issues

hello,

I have a multi-project build that will, in one of its subprojects, include two dependencies that have conflicting classes. Each subproject contains their dependencies in their own build.gradle file. The root project controls plugins, sourceSets, etc, but so far no mention to specific projects.

project root

subproject A

subproject B

compile (’:projectA’)

compile files (‘fullpath/conflicting.jar’)

I am trying to prepend project A in the classpath, followed by the conflicting.jar for project B only. I have been trying a miscelaneous of this:

compileClasspath = compileClasspath + compileClasspath(file(''fullpath/conflicting.jar''))

inside and outside sourceSets, in the main project build file, and even after the dependencies section inside project B build file.

I am not sure what am I missing here. Any clues? Also, is this the way I should be going for making sure my classpath has the correct ordering?

I forgot to mention that it does not work as I get the errors:

Could not find method compileClasspath() for arguments [’‘fullpath/conflicting.jar’’] on root project ‘bundle’.

I was able to solve this one via configurations.

in my root project I defined a configuration for what is legacy and should come last in the classpath. In the subprojects, I add the configuration as the last element. examples

subprojects {
   configurations {
                legacy
       }
}

And in every child project I have

sourceSets {
   main {
        (...)
        compileClasspath = compileClasspath + configurations.legacy
     }
}
  dependencies {
     compile (group ...)
     legacy files ('legacy-lib.jar')
}

You could configure everything from the root project’s build script.