Build: Instrument only java tasks for main & test source sets
This commit is contained in:
committed by
Denis Zharkov
parent
50eb98194a
commit
1bd5b68b4a
@@ -25,16 +25,22 @@ fun Project.configureJavaInstrumentation() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
tasks.withType<JavaCompile> {
|
listOf(mainSourceSet, testSourceSet).forEach { sourceSet ->
|
||||||
doLast {
|
tasks.named<JavaCompile>(sourceSet.compileJavaTaskName) javaCompile@ {
|
||||||
instrumentClasses(javaInstrumentator.asPath)
|
doLast {
|
||||||
|
instrumentClasses(javaInstrumentator.asPath, this@javaCompile, sourceSet)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun JavaCompile.instrumentClasses(instrumentatorClasspath: String) {
|
fun instrumentClasses(
|
||||||
ant.withGroovyBuilder {
|
instrumentatorClasspath: String,
|
||||||
|
javaCompile: JavaCompile,
|
||||||
|
sourceSet: SourceSet
|
||||||
|
) {
|
||||||
|
javaCompile.ant.withGroovyBuilder {
|
||||||
"taskdef"(
|
"taskdef"(
|
||||||
"name" to "instrumentIdeaExtensions",
|
"name" to "instrumentIdeaExtensions",
|
||||||
"classpath" to instrumentatorClasspath,
|
"classpath" to instrumentatorClasspath,
|
||||||
@@ -43,16 +49,14 @@ fun JavaCompile.instrumentClasses(instrumentatorClasspath: String) {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
val sourceSet = project.sourceSets.single { it.compileJavaTaskName == name }
|
|
||||||
|
|
||||||
val javaSourceDirectories = sourceSet.allJava.sourceDirectories.filter { it.exists() }
|
val javaSourceDirectories = sourceSet.allJava.sourceDirectories.filter { it.exists() }
|
||||||
|
|
||||||
ant.withGroovyBuilder {
|
javaCompile.ant.withGroovyBuilder {
|
||||||
javaSourceDirectories.forEach { directory ->
|
javaSourceDirectories.forEach { directory ->
|
||||||
"instrumentIdeaExtensions"(
|
"instrumentIdeaExtensions"(
|
||||||
"srcdir" to directory,
|
"srcdir" to directory,
|
||||||
"destdir" to destinationDir,
|
"destdir" to javaCompile.destinationDir,
|
||||||
"classpath" to classpath.asPath,
|
"classpath" to javaCompile.classpath.asPath,
|
||||||
"includeantruntime" to false,
|
"includeantruntime" to false,
|
||||||
"instrumentNotNull" to true
|
"instrumentNotNull" to true
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user