The World’s Largest Online Community for Developers

'; Gradle: how to make cross-project dependencies between tasks? - LavOzs.Com

I have a multi-module project with projects projectA and projectB.

// 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')

How do I configure projectB such that projectA:tarTask will run as a dependency of projectB:someOtherTask?

I have tried following the guidance in the docs here, but can't get projectB to recognise the first project:

./gradlew :projectB:someOtherTask
A problem occurred evaluating root project 'projectB'.
> Project with path ':projectA' could not be found in root project 'projectB'.
How can I force gradle to redownload dependencies?
Model project dependencies in Gradle: Add a dependent project to another project
How to manually include external aar package using new Gradle Android Build System
Gradle dependency to project in buildscript
Using gradle to find dependency tree
How to add Project Dependency using gradle?
Gradle + Buildship - Switch dependency between JAR and projects
What's the difference between implementation and compile in Gradle?
Understanding gradle dependencies
Gradle Run MainClass from external dependency