Skip to content

Commit

Permalink
Simplify settings.gradle
Browse files Browse the repository at this point in the history
  • Loading branch information
fornewid committed Dec 9, 2023
1 parent 42f11cf commit 9cdcc2f
Showing 1 changed file with 44 additions and 10 deletions.
54 changes: 44 additions & 10 deletions settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -40,19 +40,53 @@ dependencyResolutionManagement {
}
}

include ':app'
include ':domain'
include ':testing'
include ':macrobenchmark'
// Automatically detect modules.
rootDir.eachDir { dir ->
findModule("", dir).each { module ->
include "$module"
}
}

private static List<String> findModule(String parent, File dir) {
if (!dir.isDirectory() || isProject(dir)) {
return Collections.emptyList()
}

file("feature").eachDir { dir ->
include ":feature:${dir.name}"
List<String> modules = new ArrayList<String>()
String current = "$parent:${dir.name}"
if (isModule(dir)) {
println "include '$current'"
modules.add("$current")
} else {
var files = dir.listFiles()
if (files != null) {
files.each { file ->
if (file.isDirectory()) {
modules.addAll(findModule(current, file))
}
}
}
}
return modules
}

file("data").eachDir { dir ->
include ":data:${dir.name}"
private static boolean isProject(File file) {
var files = file.listFiles()
if (files == null) {
return false
}
return files.any {
it.isFile() && (it.name == "settings.gradle" || it.name == "settings.gradle.kts")
}
}

file("core").eachDir { dir ->
include ":core:${dir.name}"
private static boolean isModule(File file) {
var files = file.listFiles()
if (files == null) {
return false
}

return files.any {
it.isFile() && (it.name == "build.gradle" || it.name == "build.gradle.kts")
}
}

0 comments on commit 9cdcc2f

Please sign in to comment.