通过项目/模块自定义gradle任务的严格执行顺序

时间:2019-01-09 09:44:58

标签: gradle groovy

我具有以下目录结构

myproj/
   - build.gradle
   - settings.gradle
subproj1/
   - build.gradle
subproj2/
   - build.gradle

执行时

gradle customTask

我希望我的customTask在subproj2内完全执行 ,然后在在subproj2内部完成之后同步执行,以继续执行{{1}内的自定义任务}

我当前的配置(我试图将subproj2定义为对subproj1的依赖项):

myproj-settings.gradle

subproj1

myproj-build.gradle

rootProject.name = 'wowsuchwowproject'    
include ':subproj1', ':subproj2'

subproj1-build.gradle

project(":subproj1") {

}

project(":subproj2") {

}

subproj2-build.gradle

dependencies {
    api project(":subproj2")
}

task("customTask") {
    ...
}

但是我遇到了这个错误;我想念什么?

task("customTask") {
    ...
}

更新10/01/2019:添加了插件信息

这些是我在根* What went wrong: Could not determine the dependencies of task ':subproj1:mergeReleaseResources'. > Could not resolve all task dependencies for configuration ':subproj1:releaseRuntimeClasspath'. > Could not resolve project :subproj2. Required by: project :subproj1 > Unable to find a matching configuration of project :subproj2: None of the consumable configurations have attributes. * Try: Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights. 中拥有的其他东西

build.gradle

在我所有的其他人中

buildscript {
    repositories {
        jcenter()
        google()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.2.1'
    }
}

allprojects {
    repositories {
        jcenter()
        google()
    }
}

0 个答案:

没有答案