Hi,
I would like to add a task only for the rootProject in a multiModule project using buildSrc. That works in theory well with the following:
if (!rootProject.tasks.getNames().contains("theTask")) {
rootProject.tasks.register("theTask", Task::class) {
}
}
But there is currently a java.util.ConcurrentModificationException because of course “all” modules want to create the task at the same time. How can I do this better? Can I find out if I am currently in the rootProject? Unfortunately I get
Function invocation 'project(...)' expected
Unresolved reference. None of the following candidates is applicable because of receiver type mismatch:
public fun DependencyHandler.project(path: String, configuration: String? = ...): ProjectDependency defined in org.gradle.kotlin.dsl
with the following call:
if (this.project.parent == null) {}
Thank you very much!