Skip to content

Instantly share code, notes, and snippets.

@47star
Created September 19, 2022 11:43
Show Gist options
  • Save 47star/f802ca7dcb837dcd42424f416c263db3 to your computer and use it in GitHub Desktop.
Save 47star/f802ca7dcb837dcd42424f416c263db3 to your computer and use it in GitHub Desktop.
Gradle Submodule Notation for Kotlin DSL
class GradleSubmodule(
private val name: String,
private vararg val children: GradleSubmodule,
) {
operator fun unaryPlus() = load("")
private fun load(parent: String) {
include("$parent:$name")
for (child in children) {
child.load("$parent:$name")
}
}
}
+GradleSubmodule(
"modules",
GradleSubmodule(
"a",
GradleSubmodule("a"),
),
GradleSubmodule("b"),
GradleSubmodule("c"),
GradleSubmodule("d"),
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment