[Build] Fix configuration cache issues (part 1)

* Make `clean` task compatible with configuration cache
* Make Java compile instrumentation compatible with configuration cache
* Make settings.gradle compatible with configuration cache
* Initial work on making IntelliJInstrumentCodeTask compatible with configuration cache
* Make writeStdlibVersion task compatible with configuration cache
* Copy some properties to not capture it's owning object into lambda to support configuration cache

Relates to #KT-44611
This commit is contained in:
Alexander Likhachev
2021-01-29 05:44:51 +03:00
parent 111e67dc8d
commit 27956adf3f
11 changed files with 120 additions and 88 deletions
+2 -36
View File
@@ -24,42 +24,8 @@ fun Project.configureJavaInstrumentation() {
includeJars("javac2", "jdom", "asm-all", rootProject = rootProject)
}
}
listOf(mainSourceSet, testSourceSet).forEach { sourceSet ->
tasks.named<JavaCompile>(sourceSet.compileJavaTaskName) javaCompile@ {
doLast {
instrumentClasses(javaInstrumentator.asPath, this@javaCompile, sourceSet)
}
}
}
}
}
fun instrumentClasses(
instrumentatorClasspath: String,
javaCompile: JavaCompile,
sourceSet: SourceSet
) {
javaCompile.ant.withGroovyBuilder {
"taskdef"(
"name" to "instrumentIdeaExtensions",
"classpath" to instrumentatorClasspath,
"loaderref" to "java2.loader",
"classname" to "com.intellij.ant.InstrumentIdeaExtensions"
)
}
val javaSourceDirectories = sourceSet.allJava.sourceDirectories.filter { it.exists() }
javaCompile.ant.withGroovyBuilder {
javaSourceDirectories.forEach { directory ->
"instrumentIdeaExtensions"(
"srcdir" to directory,
"destdir" to javaCompile.destinationDir,
"classpath" to javaCompile.classpath.asPath,
"includeantruntime" to false,
"instrumentNotNull" to true
)
for (sourceSet in listOf(mainSourceSet, testSourceSet)) {
tasks.named(sourceSet.compileJavaTaskName, InstrumentJava(javaInstrumentator, sourceSet))
}
}
}