Gradle:如何使任务之间的跨项目依赖关系?

时间:2020-02-21 20:00:47

标签: gradle

我有一个包含项目projectAprojectB的多模块项目。

// project A build.gradle
task tarTask(type:Tar) {
    // some configuration here
}

sourceSets {
    main {
        output.dir( "someOutputDir", builtBy: tarTask)
    }
}


// project B build.gradle
task someOtherTask {
    doLast {
        // do something that refers to the output of :projectA:tarTask
    }
}

dependencies {
    runtimeOnly project(':projectA')
}

如何配置projectB,使projectA:tarTask作为projectB:someOtherTask的依赖项运行?

我尝试遵循文档here中的指导,但无法获得projectB来识别第一个项目:

./gradlew :projectB:someOtherTask
... 
...
A problem occurred evaluating root project 'projectB'.
> Project with path ':projectA' could not be found in root project 'projectB'.

0 个答案:

没有答案