How to get property of Gradle task from an included build?

Viewed 319

I have a composite Gradle build and in the root build I would like to reference a property of a task in one of the included builds, is this possible?

E.g. if I have this structure:

rootBuild
 + includedBuild1
   + project1
   + project2
 + includedBuild2

I know that in the build.gradle of "project1" I can use this statement to output the property I am interested in:

println shadowJar.archiveFile.get()

For some reason I don't understand, from this project's parent build.gradle ("includedBuild1") I can't reference the 'shadowJar' plugin task directly, but I am able to get the property I'm interested in like this:

println tasks.getByPath(':project1:jar').archiveFile.get()

Now I would like to reference this same property in the root build. However, trying something like this indicates that property 'archiveFile' is not set on the refenced task (i.e. outputs "null"):

println gradle.includedBuild('includedBuild1').task(':project1:jar').properties['archiveFile']

Is there a way to reference the property I'm interested in from the root of the composite build?

0 Answers
Related