Not really a kotlin related question but more grad...
# gradle
j
Not really a kotlin related question but more gradle in general. Is this the only way to attach a dependency to the
check
or
build
task if you have subprojects that apply the
java
plugin but the root project doesn't apply the
java
plugin?
Copy code
val checkTask = task("check") {
    description = "Check all sub-projects"
    group = "verification"
}

val buildTask = task("build") {
    description = "Build all sub-projects"
    group = "build"
    dependsOn(checkTask)
}

configure(javaProjects + kotlinProjects) {
    checkTask.dependsOn(tasks.getByName("check"))
    buildTask.dependsOn(tasks.getByName("build"))
}

afterEvaluate {
    checkTask.dependsOn("spotlessCheck")
}
Because the root project doesn't actually have the
check
or
build
task. Even though you can run
./gradlew build
against the root project.