import org.jetbrains.gradle.ext.compiler import org.jetbrains.gradle.ext.settings plugins { alias(libs.plugins.taskTree) id("org.jetbrains.gradle.plugin.idea-ext") } idea.project.settings.compiler.javac { // We want ErrorProne to be present when compiling via IntelliJ, as it offers some helpful warnings // and errors. Loop through our source sets and find the appropriate flags. moduleJavacAdditionalOptions = subprojects .asSequence() .map { evaluationDependsOn(it.path) } .flatMap { project -> val sourceSets = project.extensions.findByType(SourceSetContainer::class) ?: return@flatMap sequenceOf() sourceSets.asSequence().map { sourceSet -> val name = "${idea.project.name}.${project.name}.${sourceSet.name}" val compile = project.tasks.named(sourceSet.compileJavaTaskName, JavaCompile::class).get() name to compile.options.allCompilerArgs.joinToString(" ") { if (it.contains(" ")) "\"$it\"" else it } } } .toMap() }