Distzip with dependency project not compiling?


(George Stockfisch) #1

I have a multiproject setup A and a dist project B. B adds the jar from A to B’s zip file. So in the build.gradle of B I have

dependencies {

compile (project(":A", configuration: ‘compile’))

} But it doesn’t compile A when it builds the zip. It zips A’s dependencies, just not the actual A.jar, because it doesn’t get built. I have tried

dependencies {

compile (project(":A", configuration: ‘compile’))

}

But it errors out with

Could not find method project() for arguments [{configuration=compile}, :A] on project ‘:B’


(George Stockfisch) #2

I added

distZip.dependsOn project.configurations.compile

Which seems to do the trick, I’m just not sure if there is a better way


(Peter Niederwieser) #3

The two snippets that you show are identical, and both of them miss a ‘path:’ right before the project path. Anyway, unless project A does something special, the simpler declaration ‘compile project(":A")’ should suffice. This implicitly refers to the ‘default’ configuration of A, which, unlike the ‘compile’ configuration, contains not only the compile dependencies of A but also its artifact. (Actually also the runtime dependencies, but this shouldn’t hurt.)

PS: Please use HTML code tags to make code snippets and Gradle output more readable.


(George Stockfisch) #4

Sorry, copy paste error of course, in addition, I tried 1.6, but I’m currently using 1.7rc1(I haven’t gone to 2 yet)

dependencies {
compile (project(":A")
}

But it doesn’t compile A when it builds the zip. It zips A’s dependencies, just not the actual A.jar, because it doesn’t get built. I have tried

dependencies {
compile (project(":A", configuration: 'compile'))
}

But it errors out with “Could not find method project() for arguments [{configuration=compile}, :A] on project ‘:B’”

I also have a settings.gradle which includes both A and B, I assumed by including that I don’t need to give it the path, is that correct?