buildSrc/build.gradle no longer recursively setting out dir for subprojects
to be more compatible with project isolation
Bug: 191913559
Test: Treehugger runs busytown/*.sh
Test: Run `./gradlew :help -Dorg.gradle.unsafe.isolated-projects=true --clean` and see that some warnings about buildSrc are gone
Change-Id: Ifc3450673fd255a9717f59f0124295b7bc2dd41b
diff --git a/buildSrc/out.gradle b/buildSrc/out.gradle
index 0ca9069..e0f12c2 100644
--- a/buildSrc/out.gradle
+++ b/buildSrc/out.gradle
@@ -39,17 +39,23 @@
return new Tuple(outDir, buildSrcOut)
}
-def chooseOutDir(subdir = "") {
+// Ideally this function would just be chooseBuildDir, but Gradle doesn't include the text ":buildSrc" in the project path
+def chooseBuildSrcBuildDir(subdir = "") {
def (outDir, buildSrcOut) = getOutDir(subdir)
project.ext.buildSrcOut = buildSrcOut
project.ext.outDir = outDir
- buildDir = new File(outDir, "$project.name/build")
- .getCanonicalFile()
+ def pathAsFilepath = project.path.replace(":", "").replaceAll(":", "/")
+ project.layout.buildDirectory.set(new File(buildSrcOut, "$pathAsFilepath/build").getCanonicalFile())
+}
+
+def chooseOutDir(subdir = "") {
+ chooseBuildSrcBuildDir()
subprojects {
// Change buildDir first so that all plugins pick up the new value.
- project.buildDir = new File("$project.parent.buildDir/../$project.name/build")
+ project.layout.buildDirectory.set(new File("$project.parent.buildDir/../$project.name/build"))
}
}
ext.init.getOutDir = this.&getOutDir
ext.init.chooseOutDir = this.&chooseOutDir
+ext.init.chooseBuildSrcBuildDir = this.&chooseBuildSrcBuildDir