Project dependency on a non-default configuration doesn't work


(Vasily Karyaev) #1

According to the documentation, project dependencies can be specified in the following way:

configurationName project(path: ‘:projectA’, configuration: ‘someOtherConfiguration’)

That doesn’t work for me as expected though (I am using Gradle 1.5).

My sample multimodule project has 2 subprojects: ‘a’ and ‘b’. The subproject ‘a’ declares class ‘A’ and has no external dependencies. The subproject ‘b’ declares class ‘B’ extending ‘A’, and its ‘build.gradle’ file looks as follows:

dependencies {

compile project(path: “:a”, configuration: “compile”)

}

When I try to build the project ‘b’, it fails with the following error:

/private/tmp/TestProject/test-project/b/src/main/java/test/B.java:3: cannot find symbol

symbol: class A

public class B extends A {

However If I change the dependencies declaration to

compile project(path: “:a”, configuration: “default”)

or to

compile project(":a")

the project becomes compilable.

I expect that the first declaration is supposed to work the same well. Is this assumption wrong? I can send an archive with the sample project in question if needed.

– You might ask me why do I use the non-default configuration in my dependency declaration. That’s a long story. In short, my build script creates such dependencies dynamically from ‘ivy.xml’ files.

Thanks


(Peter Niederwieser) #2

The ‘compile’ configuration contains the compile dependencies, but not the compiled code.