Adam
Adam

Reputation: 712

Refer to directory in another Gradle sub-project

I have a Gradle build with sub-projects. Until recently, one of the sub-projects needed a reference to the libraries sub-directory within it's own build directory. I achieved this as follows:

file("${buildDir}/libraries")

I now need to change that reference to pick the build directory from another sub-project (called gui). I can't find a way to use the Gradle DSL to achieve this. Instead I have it expressed as follows:

new File(project(':gui').buildDir, 'libraries')

Is there a more elegant way to do this in Gradle?

Upvotes: 0

Views: 522

Answers (1)

M.Ricciuti
M.Ricciuti

Reputation: 12106

You can combine Gradle DSL with Groovy String interpolation, and write your statement as follows

file("${rootProject.project('gui').buildDir}/libraries")

Upvotes: 2

Related Questions