Alexander Ites
Alexander Ites

Reputation: 490

How to run a Gradle subproject task from another Gradle subproject via GradleBuild task type

I have a Gradle project with the next structure:

prj
+---subprj1
|   \---build.gradle
+---subprj2
|   \---build.gradle
\---build.gradle

subprj1/build.gradle contents are:

task caller (type: GradleBuild) {
    setTasks(["subprj2:callee"])
}

and subprj2/build.gradle contents are:

task callee {
    println "Has been called."
}

This way it doesn't work. Is it possible to use setTasks & GradleBuild task type at this case? How to do that?

Upvotes: 0

Views: 55

Answers (1)

LazerBanana
LazerBanana

Reputation: 7211

This should call callee just before caller

task caller (dependsOn: [':subprj2:callee']) {

}

or:

task caller {
  dependsOn ':subprj2:callee'
}

or:

caller.dependsOn ':subprj2:callee'

Upvotes: 1

Related Questions