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

前端 未结 2 499
刺人心
刺人心 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

提交回复
热议问题