Stop double null instrumentation for modules with several source roots

KTI-754

For instrumentation only destination directory is relevant. So each
execution did own instrumentation, and there no internal mechanism for
preventing re-instrumentation included.

Replace InstrumentIdeaExtensions with Javac2 because
areJavaClassesCompiled=true in the base class.

https://github.com/JetBrains/intellij-community/blob/9c40bdd/java/compiler/javac2/src/com/intellij/ant/InstrumentIdeaExtensions.java
https://github.com/JetBrains/intellij-community/blob/9c40bdd/java/compiler/javac2/src/com/intellij/ant/Javac2.java
This commit is contained in:
Nikolay Krasko
2022-01-18 19:37:36 +03:00
committed by TeamCityServer
parent 59173baf5a
commit 22b5d86656
+12 -13
View File
@@ -24,21 +24,20 @@ class InstrumentJava(@Transient val javaInstrumentator: Configuration, @Transien
override fun execute(task: Task) {
require(task is JavaCompile) { "$task is not of type JavaCompile!" }
task.doLast {
task.ant.withGroovyBuilder {
"taskdef"(
"name" to "instrumentIdeaExtensions",
"classpath" to instrumentatorClasspath,
"loaderref" to "java2.loader",
"classname" to "com.intellij.ant.InstrumentIdeaExtensions"
)
}
val anySrcDir = srcDirs.filter { it.exists() }.firstOrNull()
if (anySrcDir != null) {
task.ant.withGroovyBuilder {
"taskdef"(
"name" to "instrumentIdeaExtensions",
"classpath" to instrumentatorClasspath,
"loaderref" to "java2.loader",
"classname" to "com.intellij.ant.Javac2"
)
}
val javaSourceDirectories = srcDirs.filter { it.exists() }
task.ant.withGroovyBuilder {
javaSourceDirectories.forEach { directory ->
task.ant.withGroovyBuilder {
"instrumentIdeaExtensions"(
"srcdir" to directory,
"srcdir" to anySrcDir, // No code should actually be compiled because of areJavaClassesCompiled==true in Javac2 - so any src folder will do.
"destdir" to task.destinationDirectory.asFile.get(),
"classpath" to task.classpath.asPath,
"includeantruntime" to false,