Checking for project dependencies in a multi-project build


(kev.hannen) #1

In a multi-project build is there a way to test if one project has a dependency on another project? The scenario is that the parent build file sets up general configuration and tasks but some of the behaviour is driven by specific project dependencies which are set in the child build file. I have tried something like

project.configurations.compile.dependencies.contains(project(’:projA’))

but that always returns false.


(Peter Niederwieser) #2

Of course it’s possible, but a simpler solution is to put both the adding of the project dependency and the necessary configuration that goes along with it into a separate build script (say ‘gradle/foo.gradle’) and apply it with ‘apply from: “gradle/foo.gradle”’.


(kev.hannen) #3

Your suggestion is just right. Thanks.


(kev.hannen) #4

Your suggestion works just fine. Thanks.