Paul Woitaschek
02/21/2019, 10:39 AMGarouDan
02/21/2019, 11:01 AMtapchicoma
02/21/2019, 12:20 PMsettings.gradle
I have following:
// Define dirs pattern to skip traversing
def skipDirs = ~/^(build|\..*|src|out|config)/
def preDir = {
if (skipDirs.matcher(it.name).matches()) return FileVisitResult.SKIP_SUBTREE
}
def getProjectName(String dir) {
return (dir - (rootDir.toString() + '/')).replaceAll('/', ':')
}
def getProjectBuildFile(String dir) {
return ((dir - (rootDir.toString() + '/')).replaceAll('/', '-')) + '.gradle'
}
rootDir.traverse(type: FileType.DIRECTORIES, preDir: preDir) { dir->
String dstr = dir.toString()
if (new File(dstr + '/' + getProjectBuildFile(dstr)).exists()) {
def projectName = getProjectName(dstr)
<http://logger.info|logger.info>("Including module from ${dstr} with project name: ${projectName}")
include projectName
project(':' + projectName).buildFileName = getProjectBuildFile(dstr)
}
}
that searches starting from the root folder and automatically adds modules.tapchicoma
02/21/2019, 12:21 PMtapchicoma
02/21/2019, 12:26 PMbuild.gradle
I am using bootstrap file:
apply plugin: 'java-library'
apply plugin: 'kotlin'
apply from: "${project.rootDir}/config/quality.gradle"
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
test {
useJUnitPlatform()
}
dependencies {
api Libs.kotlinStandardLibrary
testImplementation Libs.junit
testRuntimeOnly Libs.junitVintage
}
Then in main `build.gradle`:
buildscript {
ext.bootstrap = [
kotlinLibrary : "${project.rootDir}/config/kotlin-library-bootstrap.gradle",
]
}
and then module build.gradle
looks following:
apply from: bootstrap.kotlinLibrary
tapchicoma
02/21/2019, 12:26 PM