在执行assembleDebug任务之前,如何在单独的.gradle文件中运行Gradle任务?
我有 build.gradle (项目:gradle)
buildscript {
//something
}
allprojects{
//something
}
tasks.whenTaskAdded { task ->
if (task.name == 'assembleDebug') {
task.dependsOn mytask
}
}
还有 mytask.gradle ,包括
task mytask << {
println "mytask run!"
}
我有一个例外:Could not get unknown property 'mytask' for root project 'gradle' of type org.gradle.api.Project.