Skip to content

Instantly share code, notes, and snippets.

@BoxResin
Created February 6, 2020 03:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save BoxResin/6a1f53786109f5cad99464429bba9fe7 to your computer and use it in GitHub Desktop.
Save BoxResin/6a1f53786109f5cad99464429bba9fe7 to your computer and use it in GitHub Desktop.
Gradle 서브 모듈 자동 탐지하여 include 하는 스크립트
/** [name] 디렉터리 아래의 모듈을 모두 탐색하여 `AAA:BBB:CCC` 형식으로 반환한다. */
fun submodule(name: String): Array<String> {
// 모듈 디렉터리 탐색하기
val submoduleDirs: List<File> = fileTree(name)
.matching { include("**/*.gradle.kts") }
.map { gradleScript: File -> gradleScript.parentFile }
.distinct()
// gradle 프로젝트 이름 형식으로 고치기
return submoduleDirs
.map { it.toRelativeString(rootDir).replace('\\', ':').replace('/', ':') }
.toTypedArray()
}
@BoxResin
Copy link
Author

BoxResin commented Feb 6, 2020

사용 방법

include("app", *submodule("submodule-name"))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment