Reputation: 22637
i have a multi-project build that includes many sub projects.
include ':common'
project( ':common' ).projectDir = new File( rootDir, 'android-common/common' )
include ':setup'
project( ':setup' ).projectDir = new File( rootDir, 'android-setup/setup' )
...
i'd like to add ordering (or dependencies) between them, at the master project level. in the above example, i want common
to always build before setup
. it seems like i want do something like get a reference to setup:compile
(or whatever the build task is named) and add an additional dependency. something like,
tasks[':setup'].dependsOn += tasks[':common:install']
obviously that doesn't work. is this possible?
EDIT: a little more detail. the result of :common
is to install a maven artifact, which is then used by :setup
. so, the dependency between them is soft. however, in our typical dev cycle we still want to build :common
first.
Upvotes: 3
Views: 2485
Reputation: 2232
it sounds to me like you want to use project dependencies
project(':setup') {
dependencies {
compile project(':common')
}
}
EDIT: it seems that you just want to declare cross-project task dependencies in your parent build.gradle.
tasks.getByPath(":setup:compile").dependsOn(":common:install")
Note that this will cause the setup project to be evaluated/configured at that point. If this causes problems for some reason, you might want to use an evaluation listener
project("setup").afterEvaluate { setup -> setup.compile.dependsOn ":common:install }
Further note that if you want to build the setup project independently in this structure you will have to use the -u command line option.
Upvotes: 2