Build: Don't instrument NotNulls during form instrumentation

This commit is contained in:
Vyacheslav Gerasimov
2018-12-25 21:54:46 +03:00
parent f40635c2d2
commit 38d836dece
7 changed files with 23 additions and 13 deletions
+9 -4
View File
@@ -28,7 +28,7 @@ import org.gradle.api.tasks.compile.AbstractCompile
import org.gradle.kotlin.dsl.* import org.gradle.kotlin.dsl.*
import java.io.File import java.io.File
fun Project.configureInstrumentation() { fun Project.configureFormInstrumentation() {
plugins.matching { it::class.java.canonicalName.startsWith("org.jetbrains.kotlin.gradle.plugin") }.all { plugins.matching { it::class.java.canonicalName.startsWith("org.jetbrains.kotlin.gradle.plugin") }.all {
// When we change the output classes directory, Gradle will automatically configure // When we change the output classes directory, Gradle will automatically configure
// the test compile tasks to use the instrumented classes. Normally this is fine, // the test compile tasks to use the instrumented classes. Normally this is fine,
@@ -100,6 +100,9 @@ open class IntelliJInstrumentCodeTask : ConventionTask() {
@Input @Input
var originalClassesDirs: FileCollection? = null var originalClassesDirs: FileCollection? = null
@get:Input
var instrumentNotNull: Boolean = false
@get:InputFiles @get:InputFiles
val sourceDirs: FileCollection val sourceDirs: FileCollection
get() = project.files(sourceSet!!.allSource.srcDirs.filter { !sourceSet!!.resources.contains(it) && it.exists() }) get() = project.files(sourceSet!!.allSource.srcDirs.filter { !sourceSet!!.resources.contains(it) && it.exists() })
@@ -129,7 +132,10 @@ open class IntelliJInstrumentCodeTask : ConventionTask() {
} }
logger.info("Compiling forms and instrumenting code with nullability preconditions") logger.info("Compiling forms and instrumenting code with nullability preconditions")
val instrumentNotNull = prepareNotNullInstrumenting(classpath.asPath) if (instrumentNotNull) {
prepareNotNullInstrumenting(classpath.asPath)
}
instrumentCode(sourceDirs, instrumentNotNull) instrumentCode(sourceDirs, instrumentNotNull)
} }
@@ -140,7 +146,7 @@ open class IntelliJInstrumentCodeTask : ConventionTask() {
} }
} }
private fun prepareNotNullInstrumenting(classpath: String): Boolean { private fun prepareNotNullInstrumenting(classpath: String) {
ant.withGroovyBuilder { ant.withGroovyBuilder {
"typedef"( "typedef"(
"name" to "skip", "name" to "skip",
@@ -149,7 +155,6 @@ open class IntelliJInstrumentCodeTask : ConventionTask() {
"classname" to FILTER_ANNOTATION_REGEXP_CLASS "classname" to FILTER_ANNOTATION_REGEXP_CLASS
) )
} }
return true
} }
private fun instrumentCode(srcDirs: FileCollection, instrumentNotNull: Boolean) { private fun instrumentCode(srcDirs: FileCollection, instrumentNotNull: Boolean) {
+9 -4
View File
@@ -28,7 +28,7 @@ import org.gradle.api.tasks.compile.AbstractCompile
import org.gradle.kotlin.dsl.* import org.gradle.kotlin.dsl.*
import java.io.File import java.io.File
fun Project.configureInstrumentation() { fun Project.configureFormInstrumentation() {
plugins.matching { it::class.java.canonicalName.startsWith("org.jetbrains.kotlin.gradle.plugin") }.all { plugins.matching { it::class.java.canonicalName.startsWith("org.jetbrains.kotlin.gradle.plugin") }.all {
// When we change the output classes directory, Gradle will automatically configure // When we change the output classes directory, Gradle will automatically configure
// the test compile tasks to use the instrumented classes. Normally this is fine, // the test compile tasks to use the instrumented classes. Normally this is fine,
@@ -100,6 +100,9 @@ open class IntelliJInstrumentCodeTask : ConventionTask() {
@Input @Input
var originalClassesDirs: FileCollection? = null var originalClassesDirs: FileCollection? = null
@get:Input
var instrumentNotNull: Boolean = false
@get:InputFiles @get:InputFiles
val sourceDirs: FileCollection val sourceDirs: FileCollection
get() = project.files(sourceSet!!.allSource.srcDirs.filter { !sourceSet!!.resources.contains(it) && it.exists() }) get() = project.files(sourceSet!!.allSource.srcDirs.filter { !sourceSet!!.resources.contains(it) && it.exists() })
@@ -129,7 +132,10 @@ open class IntelliJInstrumentCodeTask : ConventionTask() {
} }
logger.info("Compiling forms and instrumenting code with nullability preconditions") logger.info("Compiling forms and instrumenting code with nullability preconditions")
val instrumentNotNull = prepareNotNullInstrumenting(classpath.asPath) if (instrumentNotNull) {
prepareNotNullInstrumenting(classpath.asPath)
}
instrumentCode(sourceDirs, instrumentNotNull) instrumentCode(sourceDirs, instrumentNotNull)
} }
@@ -140,7 +146,7 @@ open class IntelliJInstrumentCodeTask : ConventionTask() {
} }
} }
private fun prepareNotNullInstrumenting(classpath: String): Boolean { private fun prepareNotNullInstrumenting(classpath: String) {
ant.withGroovyBuilder { ant.withGroovyBuilder {
"typedef"( "typedef"(
"name" to "skip", "name" to "skip",
@@ -149,7 +155,6 @@ open class IntelliJInstrumentCodeTask : ConventionTask() {
"classname" to FILTER_ANNOTATION_REGEXP_CLASS "classname" to FILTER_ANNOTATION_REGEXP_CLASS
) )
} }
return true
} }
private fun instrumentCode(srcDirs: FileCollection, instrumentNotNull: Boolean) { private fun instrumentCode(srcDirs: FileCollection, instrumentNotNull: Boolean) {
+1 -1
View File
@@ -205,5 +205,5 @@ projectTest(taskName = "performanceTest") {
testsJar {} testsJar {}
classesDirsArtifact() classesDirsArtifact()
configureInstrumentation() configureFormInstrumentation()
+1 -1
View File
@@ -30,4 +30,4 @@ sourceSets {
"test" { none() } "test" { none() }
} }
configureInstrumentation() configureFormInstrumentation()
+1 -1
View File
@@ -74,4 +74,4 @@ projectTest {
useAndroidSdk() useAndroidSdk()
} }
configureInstrumentation() configureFormInstrumentation()
+1 -1
View File
@@ -28,7 +28,7 @@ sourceSets {
"test" { none() } "test" { none() }
} }
configureInstrumentation() configureFormInstrumentation()
runtimeJar { runtimeJar {
archiveName = "jvm-ide.jar" archiveName = "jvm-ide.jar"
+1 -1
View File
@@ -17,7 +17,7 @@ sourceSets {
"test" { none() } "test" { none() }
} }
configureInstrumentation() configureFormInstrumentation()
runtimeJar { runtimeJar {
archiveName = "native-ide.jar" archiveName = "native-ide.jar"