代码之家  ›  专栏  ›  技术社区  ›  user1236048

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

  •  0
  • user1236048  · 技术社区  · 6 年前

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

    当我执行

    gradle customTask

    我要执行自定义任务 完全地 subproj2 然后在 继续并在内部执行自定义任务 subproj1

    我当前的配置(我试图将subroj2定义为subroj1的依赖关系):

    myproj-设置.gradle

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

    myproj-构建.gradle

    project(":subproj1") {
    
    }
    
    project(":subproj2") {
    
    }
    

    子程序J1-build.gradle

    dependencies {
        api project(":subproj2")
    }
    
    task("customTask") {
        ...
    }
    

    task("customTask") {
        ...
    }
    

    但我得到了这个错误;我错过了什么?

    * 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()
        }
    }
    

    在我所有的其他人身上

    apply plugin: com.myown.plugin.AwesomePlugin
    
    0 回复  |  直到 6 年前