allprojects { repositories { google() mavenCentral() } } val newBuildDir: Directory = rootProject.layout.buildDirectory.dir("../../build").get() rootProject.layout.buildDirectory.value(newBuildDir) subprojects { val newSubprojectBuildDir: Directory = newBuildDir.dir(project.name) project.layout.buildDirectory.value(newSubprojectBuildDir) afterEvaluate { if (extensions.findByName("android") != null) { val android = extensions.findByName("android") as com.android.build.gradle.BaseExtension if (android.namespace == null) { var manifestPackage: String? = null val manifestFile = project.projectDir.resolve("src/main/AndroidManifest.xml") if (manifestFile.exists()) { val content = manifestFile.readText() val match = Regex("package=\"([^\"]+)\"").find(content) if (match != null) { manifestPackage = match.groupValues[1] } } if (manifestPackage != null) { android.namespace = manifestPackage } else { android.namespace = "co.gittouch." + project.name.replace("-", "_") } } } } } subprojects { project.evaluationDependsOn(":app") } tasks.register("clean") { delete(rootProject.layout.buildDirectory) }