Project lib dependencies

(xiaoxi_luo) #1

I have a multi-project gradle build using the java plugin as follows; rootProject/









I would like util to generate two jars containing different sets of class files, say util_a.jar and util_b.jar. moduleA depends on util_a.jar. moduleB depends on both util_a.jar and util_b.jar.

settings.gradle looks like this inlucde ‘util’, ‘moduleA’, ‘moduleB’

rootProject/util/build.gradle looks like this dependencies { … }

task aJar (type: Jar, dependsOn classes) { … }

task bJar(type: Jar, dependesOn classes) { … }

configurations {


bConfig }

artifacts {

aConfig aJar

bConfig bJar }

jar {

actions = []

dependsOn aJar, bJar }

rootProject/moduleA/build.gradle looks like this dependencies {

compile project(path: ':util", configuration: ‘aConfig’) }

rootProject/moduleB/build.gradle looks like this dependencies {

compile project(’:util’) }

When I tried to build moduleA, I got :util:compileJava :util:processResources :util:classes :util:aJar :util:bJar :util:jar :moduleA:compileJava…

moduleA actually failed on compileJava task because it couldn’t find class files which are supposed to be archived into util_a.jar. However, I did see both util_a.jar and util_b.jar being generated in \rootProject\util\build\libs just fine. Why can’t moduleA see them?

Also, since I specify moduleA’s compile dependency only on ‘aConfig’, why was util_b.jar being generated? I thought this would only trigger util_a.jar being generated.

moduleB also failed on compileJava task for the same reason. I guess I don’t understand project lib dependencies well enough. Any inputs are appreciated.