What is the syntax for a gradle subproject task depending on a parent project's task?

前端 未结 2 513
刺人心
刺人心 2021-02-15 17:03

I need some help with a Gradle build file. I have some subprojects which depend on tasks in the top folder. I just need to take a test task and split it into two se

相关标签:
2条回答
  • 2021-02-15 17:41

    There are a few syntax solutions here:

    runDifferentTests.dependsOn (":bTask")
    
    runDifferentTests.dependsOn rootProject.bTask
    
    task runDifferentTests(type : Test, dependsOn: [":bTask"]) {
    ...
    }
    
    task runDifferentTests(type : Test) {
    dependsOn rootProject.bTask
    ...
    }
    
    //in the root build.gradle to apply to all subprojects at once.
    subprojects {
        runDifferentTests.dependsOn (":bTask")
    }
    
    runDifferentTests.dependsOn {
        tasks.findAll { task -> task.name.startsWith('bTask') }
    }
    

    : can be used to go a level up instead of rootProject depends on the preference and the project structure

    0 讨论(0)
  • 2021-02-15 17:51

    Just remove the declaration in subprojects and declare your dependency directly in the subproject, in C.gradle:

    runDifferentTests.dependsOn rootProject.bTask
    
    0 讨论(0)
提交回复
热议问题