gradle构建顺序首先执行主要构建任务

时间:2018-07-12 19:50:32

标签: gradle gradlew

我具有以下gradle结构:

|_ C
   |_ build.gradle
|_ B
   |_ build.gradle
|_ A
   |_ build.gradle
|
|_ build.gradle

在我的根build.gradle中,我有以下任务:

configure(digitalJsProjects) {
    apply plugin: 'base'


    task Install(type: Exec) {
        // install
    }

    task build(type: Exec) {
        // build
    }

    task test(type: Exec) {
        commandLine 'yarn', 'test:ci'

        onlyIf {
            !yarnBuild2.state.upToDate
        }
    }

    xBuild.dependsOn install
    test.dependsOn xbuild
    build.dependsOn test
}

如果我想运行A构建,那么我的A build.gradle看起来像这样:

build.dependsOn ':B:build'
build.dependsOn ':C:build'

但是当我运行gw :A:build - m

我知道:

:A:frontend:assemble SKIPPED
:A:frontend:check SKIPPED
:A:frontend:install SKIPPED
:A:frontend:xBuild SKIPPED
:A:frontend:test SKIPPED
:B:frontend:assemble SKIPPED
:B:frontend:check SKIPPED
:B:frontend:install SKIPPED
:B:frontend:xBuild SKIPPED
:B:frontend:test SKIPPED 
:C:frontend:assemble SKIPPED
:C:frontend:check SKIPPED
:C:frontend:install SKIPPED
:C:frontend:xBuild SKIPPED
:C:frontend:test SKIPPED
:A:build

我没想到将A任务视为首要任务。

我希望所有B任务都可以运行,然后运行C任务之前的A任务。 A:build是我期望的位置,但是为什么其他A个任务首先运行,或者我如何实现此构建顺序:

:B:frontend:assemble SKIPPED
:B:frontend:check SKIPPED
:B:frontend:install SKIPPED
:B:frontend:xBuild SKIPPED
:B:frontend:test SKIPPED 
:C:frontend:assemble SKIPPED
:C:frontend:check SKIPPED
:C:frontend:install SKIPPED
:C:frontend:xBuild SKIPPED
:C:frontend:test SKIPPED
:A:frontend:assemble SKIPPED
:A:frontend:check SKIPPED
:A:frontend:install SKIPPED
:A:frontend:xBuild SKIPPED
:A:frontend:test SKIPPED
:A:build

0 个答案:

没有答案