Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Referencing the outputs of a task in another project in Gradle

Tags:

gradle

Consider the following setup

rootProject
|--projectA
|--projectB

There is a task taskB in projectB and I would like the reference the outputs of that task in a copy task taskA in projectA. For example, taskA might look something like:

task taskA(type: Copy) {    
    dependsOn ':projectB:taskB'

    from ':projectB:taskB.outputs'

    into 'someFolder'
}

Of course the above example doesn't actually work. While it's okay to reference the task as :projectB:taskB as a dependency, :projectB:taskB.outputs doesn't seem to mean anything to Gradle. I've tried reading through the Gradle docs but didn't find anything that referenced what I'm trying to do.

like image 901
Michael Wu Avatar asked Jan 19 '16 21:01

Michael Wu


1 Answers

projectA build.gradle should be:

evaluationDependsOn(':projectB')

task taskA(type:Copy, dependsOn:':projectB:taskB'){
    from tasks.getByPath(':projectB:taskB').outputs
    into 'someFolder'
}
like image 200
RaGe Avatar answered Dec 03 '22 08:12

RaGe