1 回答

TA貢獻1871條經驗 獲得超8個贊
抱歉,此答案的先前版本誤解了此問題的要求。
這是一個應該可以滿足您要求的解決方案:
// Create a lifecycle task in the root project.
// We'll make this depend on all checkstyle tasks from subprojects (see below)
def checkstyleAllTask = task("checkstyleAll")
// Make 'check' task depend on our new lifecycle task
check.dependsOn(checkstyleAllTask)
allProjects {
? ? // Ensure all checkstyle tasks are a dependency of the "checkstyleAll" task
? ? checkstyleAllTask.dependsOn(tasks.withType(Checkstyle))
? ? tasks.withType(Test) {
? ? ? ? // Indicate that testing tasks should run after the "checkstyleAll" task
? ? ? ? shouldRunAfter(checkstyleAllTask)
? ? ? ? // Indicate that testing tasks should run after any checksytle tasks.
? ? ? ? // This is useful for when you only want to run an individual
? ? ? ? // subproject's checks (e.g. ./gradlew ::subprojA::check)
? ? ? ? shouldRunAfter(tasks.withType(Checkstyle))
? ? }
}
添加回答
舉報