Reformat instrument.kt
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
@file:Suppress("unused") // usages in build scripts are not tracked properly
|
@file:Suppress("unused")
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright 2010-2017 JetBrains s.r.o.
|
* Copyright 2010-2017 JetBrains s.r.o.
|
||||||
@@ -23,7 +23,6 @@ import org.gradle.api.file.ConfigurableFileCollection
|
|||||||
import org.gradle.api.file.FileCollection
|
import org.gradle.api.file.FileCollection
|
||||||
import org.gradle.api.internal.ConventionTask
|
import org.gradle.api.internal.ConventionTask
|
||||||
import org.gradle.api.plugins.ExtensionAware
|
import org.gradle.api.plugins.ExtensionAware
|
||||||
import org.gradle.api.plugins.JavaPluginConvention
|
|
||||||
import org.gradle.api.tasks.*
|
import org.gradle.api.tasks.*
|
||||||
import org.gradle.api.tasks.compile.AbstractCompile
|
import org.gradle.api.tasks.compile.AbstractCompile
|
||||||
import org.gradle.kotlin.dsl.*
|
import org.gradle.kotlin.dsl.*
|
||||||
@@ -46,8 +45,8 @@ fun Project.configureInstrumentation() {
|
|||||||
val testCompile = tasks.findByName("compileTestKotlin") as AbstractCompile?
|
val testCompile = tasks.findByName("compileTestKotlin") as AbstractCompile?
|
||||||
testCompile?.doFirst {
|
testCompile?.doFirst {
|
||||||
testCompile.classpath = (testCompile.classpath
|
testCompile.classpath = (testCompile.classpath
|
||||||
- mainSourceSet.output.classesDirs
|
- mainSourceSet.output.classesDirs
|
||||||
+ files((mainSourceSet as ExtensionAware).extra.get("classesDirsCopy")))
|
+ files((mainSourceSet as ExtensionAware).extra.get("classesDirsCopy")))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -68,7 +67,8 @@ fun Project.configureInstrumentation() {
|
|||||||
logger.info("Saving old sources dir for project ${project.name}")
|
logger.info("Saving old sources dir for project ${project.name}")
|
||||||
val instrumentedClassesDir = File(project.buildDir, "classes/${sourceSetParam.name}-instrumented")
|
val instrumentedClassesDir = File(project.buildDir, "classes/${sourceSetParam.name}-instrumented")
|
||||||
(sourceSetParam.output.classesDirs as ConfigurableFileCollection).setFrom(instrumentedClassesDir)
|
(sourceSetParam.output.classesDirs as ConfigurableFileCollection).setFrom(instrumentedClassesDir)
|
||||||
val instrumentTask = project.tasks.create(sourceSetParam.getTaskName("instrument", "classes"), IntelliJInstrumentCodeTask::class.java)
|
val instrumentTask =
|
||||||
|
project.tasks.create(sourceSetParam.getTaskName("instrument", "classes"), IntelliJInstrumentCodeTask::class.java)
|
||||||
instrumentTask.apply {
|
instrumentTask.apply {
|
||||||
dependsOn(sourceSetParam.classesTaskName).onlyIf { !classesDirsCopy.isEmpty }
|
dependsOn(sourceSetParam.classesTaskName).onlyIf { !classesDirsCopy.isEmpty }
|
||||||
sourceSet = sourceSetParam
|
sourceSet = sourceSetParam
|
||||||
@@ -109,17 +109,23 @@ open class IntelliJInstrumentCodeTask : ConventionTask() {
|
|||||||
|
|
||||||
@TaskAction
|
@TaskAction
|
||||||
fun instrumentClasses() {
|
fun instrumentClasses() {
|
||||||
logger.info("input files are: ${originalClassesDirs?.joinToString("; ", transform = { "'${it.name}'${if (it.exists()) "" else " (does not exists)" }"})}")
|
logger.info(
|
||||||
|
"input files are: ${originalClassesDirs?.joinToString(
|
||||||
|
"; ",
|
||||||
|
transform = { "'${it.name}'${if (it.exists()) "" else " (does not exists)"}" })}"
|
||||||
|
)
|
||||||
output.deleteRecursively()
|
output.deleteRecursively()
|
||||||
copyOriginalClasses()
|
copyOriginalClasses()
|
||||||
|
|
||||||
val classpath = instrumentationClasspath!!
|
val classpath = instrumentationClasspath!!
|
||||||
|
|
||||||
ant.withGroovyBuilder {
|
ant.withGroovyBuilder {
|
||||||
"taskdef"("name" to "instrumentIdeaExtensions",
|
"taskdef"(
|
||||||
"classpath" to classpath.asPath,
|
"name" to "instrumentIdeaExtensions",
|
||||||
"loaderref" to LOADER_REF,
|
"classpath" to classpath.asPath,
|
||||||
"classname" to "com.intellij.ant.InstrumentIdeaExtensions")
|
"loaderref" to LOADER_REF,
|
||||||
|
"classname" to "com.intellij.ant.InstrumentIdeaExtensions"
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
logger.info("Compiling forms and instrumenting code with nullability preconditions")
|
logger.info("Compiling forms and instrumenting code with nullability preconditions")
|
||||||
@@ -136,10 +142,12 @@ open class IntelliJInstrumentCodeTask : ConventionTask() {
|
|||||||
|
|
||||||
private fun prepareNotNullInstrumenting(classpath: String): Boolean {
|
private fun prepareNotNullInstrumenting(classpath: String): Boolean {
|
||||||
ant.withGroovyBuilder {
|
ant.withGroovyBuilder {
|
||||||
"typedef"("name" to "skip",
|
"typedef"(
|
||||||
"classpath" to classpath,
|
"name" to "skip",
|
||||||
"loaderref" to LOADER_REF,
|
"classpath" to classpath,
|
||||||
"classname" to FILTER_ANNOTATION_REGEXP_CLASS)
|
"loaderref" to LOADER_REF,
|
||||||
|
"classname" to FILTER_ANNOTATION_REGEXP_CLASS
|
||||||
|
)
|
||||||
}
|
}
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
@@ -149,20 +157,22 @@ open class IntelliJInstrumentCodeTask : ConventionTask() {
|
|||||||
|
|
||||||
// Instrumentation needs to have access to sources of forms for inclusion
|
// Instrumentation needs to have access to sources of forms for inclusion
|
||||||
val depSourceDirectorySets = project.configurations["compile"].dependencies.withType(ProjectDependency::class.java)
|
val depSourceDirectorySets = project.configurations["compile"].dependencies.withType(ProjectDependency::class.java)
|
||||||
.map { p -> p.dependencyProject.mainSourceSet.allSource.sourceDirectories }
|
.map { p -> p.dependencyProject.mainSourceSet.allSource.sourceDirectories }
|
||||||
val instrumentationClasspath =
|
val instrumentationClasspath =
|
||||||
depSourceDirectorySets.fold(sourceSet!!.compileClasspath) { acc, v -> acc + v }.asPath.also {
|
depSourceDirectorySets.fold(sourceSet!!.compileClasspath) { acc, v -> acc + v }.asPath.also {
|
||||||
logger.info("Using following dependency source dirs: $it")
|
logger.info("Using following dependency source dirs: $it")
|
||||||
}
|
}
|
||||||
|
|
||||||
logger.info("Running instrumentIdeaExtensions with srcdir=${srcDirs.asPath}}, destdir=$output and classpath=$instrumentationClasspath")
|
logger.info("Running instrumentIdeaExtensions with srcdir=${srcDirs.asPath}}, destdir=$output and classpath=$instrumentationClasspath")
|
||||||
|
|
||||||
ant.withGroovyBuilder {
|
ant.withGroovyBuilder {
|
||||||
"instrumentIdeaExtensions"("srcdir" to srcDirs.asPath,
|
"instrumentIdeaExtensions"(
|
||||||
"destdir" to output,
|
"srcdir" to srcDirs.asPath,
|
||||||
"classpath" to instrumentationClasspath,
|
"destdir" to output,
|
||||||
"includeantruntime" to false,
|
"classpath" to instrumentationClasspath,
|
||||||
"instrumentNotNull" to instrumentNotNull) {
|
"includeantruntime" to false,
|
||||||
|
"instrumentNotNull" to instrumentNotNull
|
||||||
|
) {
|
||||||
if (instrumentNotNull) {
|
if (instrumentNotNull) {
|
||||||
ant.withGroovyBuilder {
|
ant.withGroovyBuilder {
|
||||||
"skip"("pattern" to "kotlin/Metadata")
|
"skip"("pattern" to "kotlin/Metadata")
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
@file:Suppress("unused") // usages in build scripts are not tracked properly
|
@file:Suppress("unused")
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright 2010-2017 JetBrains s.r.o.
|
* Copyright 2010-2017 JetBrains s.r.o.
|
||||||
@@ -23,7 +23,6 @@ import org.gradle.api.file.ConfigurableFileCollection
|
|||||||
import org.gradle.api.file.FileCollection
|
import org.gradle.api.file.FileCollection
|
||||||
import org.gradle.api.internal.ConventionTask
|
import org.gradle.api.internal.ConventionTask
|
||||||
import org.gradle.api.plugins.ExtensionAware
|
import org.gradle.api.plugins.ExtensionAware
|
||||||
import org.gradle.api.plugins.JavaPluginConvention
|
|
||||||
import org.gradle.api.tasks.*
|
import org.gradle.api.tasks.*
|
||||||
import org.gradle.api.tasks.compile.AbstractCompile
|
import org.gradle.api.tasks.compile.AbstractCompile
|
||||||
import org.gradle.kotlin.dsl.*
|
import org.gradle.kotlin.dsl.*
|
||||||
@@ -46,8 +45,8 @@ fun Project.configureInstrumentation() {
|
|||||||
val testCompile = tasks.findByName("compileTestKotlin") as AbstractCompile?
|
val testCompile = tasks.findByName("compileTestKotlin") as AbstractCompile?
|
||||||
testCompile?.doFirst {
|
testCompile?.doFirst {
|
||||||
testCompile.classpath = (testCompile.classpath
|
testCompile.classpath = (testCompile.classpath
|
||||||
- mainSourceSet.output.classesDirs
|
- mainSourceSet.output.classesDirs
|
||||||
+ files((mainSourceSet as ExtensionAware).extra.get("classesDirsCopy")))
|
+ files((mainSourceSet as ExtensionAware).extra.get("classesDirsCopy")))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -68,7 +67,8 @@ fun Project.configureInstrumentation() {
|
|||||||
logger.info("Saving old sources dir for project ${project.name}")
|
logger.info("Saving old sources dir for project ${project.name}")
|
||||||
val instrumentedClassesDir = File(project.buildDir, "classes/${sourceSetParam.name}-instrumented")
|
val instrumentedClassesDir = File(project.buildDir, "classes/${sourceSetParam.name}-instrumented")
|
||||||
(sourceSetParam.output.classesDirs as ConfigurableFileCollection).setFrom(instrumentedClassesDir)
|
(sourceSetParam.output.classesDirs as ConfigurableFileCollection).setFrom(instrumentedClassesDir)
|
||||||
val instrumentTask = project.tasks.create(sourceSetParam.getTaskName("instrument", "classes"), IntelliJInstrumentCodeTask::class.java)
|
val instrumentTask =
|
||||||
|
project.tasks.create(sourceSetParam.getTaskName("instrument", "classes"), IntelliJInstrumentCodeTask::class.java)
|
||||||
instrumentTask.apply {
|
instrumentTask.apply {
|
||||||
dependsOn(sourceSetParam.classesTaskName).onlyIf { !classesDirsCopy.isEmpty }
|
dependsOn(sourceSetParam.classesTaskName).onlyIf { !classesDirsCopy.isEmpty }
|
||||||
sourceSet = sourceSetParam
|
sourceSet = sourceSetParam
|
||||||
@@ -109,17 +109,23 @@ open class IntelliJInstrumentCodeTask : ConventionTask() {
|
|||||||
|
|
||||||
@TaskAction
|
@TaskAction
|
||||||
fun instrumentClasses() {
|
fun instrumentClasses() {
|
||||||
logger.info("input files are: ${originalClassesDirs?.joinToString("; ", transform = { "'${it.name}'${if (it.exists()) "" else " (does not exists)" }"})}")
|
logger.info(
|
||||||
|
"input files are: ${originalClassesDirs?.joinToString(
|
||||||
|
"; ",
|
||||||
|
transform = { "'${it.name}'${if (it.exists()) "" else " (does not exists)"}" })}"
|
||||||
|
)
|
||||||
output.deleteRecursively()
|
output.deleteRecursively()
|
||||||
copyOriginalClasses()
|
copyOriginalClasses()
|
||||||
|
|
||||||
val classpath = instrumentationClasspath!!
|
val classpath = instrumentationClasspath!!
|
||||||
|
|
||||||
ant.withGroovyBuilder {
|
ant.withGroovyBuilder {
|
||||||
"taskdef"("name" to "instrumentIdeaExtensions",
|
"taskdef"(
|
||||||
"classpath" to classpath.asPath,
|
"name" to "instrumentIdeaExtensions",
|
||||||
"loaderref" to LOADER_REF,
|
"classpath" to classpath.asPath,
|
||||||
"classname" to "com.intellij.ant.InstrumentIdeaExtensions")
|
"loaderref" to LOADER_REF,
|
||||||
|
"classname" to "com.intellij.ant.InstrumentIdeaExtensions"
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
logger.info("Compiling forms and instrumenting code with nullability preconditions")
|
logger.info("Compiling forms and instrumenting code with nullability preconditions")
|
||||||
@@ -136,10 +142,12 @@ open class IntelliJInstrumentCodeTask : ConventionTask() {
|
|||||||
|
|
||||||
private fun prepareNotNullInstrumenting(classpath: String): Boolean {
|
private fun prepareNotNullInstrumenting(classpath: String): Boolean {
|
||||||
ant.withGroovyBuilder {
|
ant.withGroovyBuilder {
|
||||||
"typedef"("name" to "skip",
|
"typedef"(
|
||||||
"classpath" to classpath,
|
"name" to "skip",
|
||||||
"loaderref" to LOADER_REF,
|
"classpath" to classpath,
|
||||||
"classname" to FILTER_ANNOTATION_REGEXP_CLASS)
|
"loaderref" to LOADER_REF,
|
||||||
|
"classname" to FILTER_ANNOTATION_REGEXP_CLASS
|
||||||
|
)
|
||||||
}
|
}
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
@@ -149,20 +157,22 @@ open class IntelliJInstrumentCodeTask : ConventionTask() {
|
|||||||
|
|
||||||
// Instrumentation needs to have access to sources of forms for inclusion
|
// Instrumentation needs to have access to sources of forms for inclusion
|
||||||
val depSourceDirectorySets = project.configurations["compile"].dependencies.withType(ProjectDependency::class.java)
|
val depSourceDirectorySets = project.configurations["compile"].dependencies.withType(ProjectDependency::class.java)
|
||||||
.map { p -> p.dependencyProject.mainSourceSet.allSource.sourceDirectories }
|
.map { p -> p.dependencyProject.mainSourceSet.allSource.sourceDirectories }
|
||||||
val instrumentationClasspath =
|
val instrumentationClasspath =
|
||||||
depSourceDirectorySets.fold(sourceSet!!.compileClasspath) { acc, v -> acc + v }.asPath.also {
|
depSourceDirectorySets.fold(sourceSet!!.compileClasspath) { acc, v -> acc + v }.asPath.also {
|
||||||
logger.info("Using following dependency source dirs: $it")
|
logger.info("Using following dependency source dirs: $it")
|
||||||
}
|
}
|
||||||
|
|
||||||
logger.info("Running instrumentIdeaExtensions with srcdir=${srcDirs.asPath}}, destdir=$output and classpath=$instrumentationClasspath")
|
logger.info("Running instrumentIdeaExtensions with srcdir=${srcDirs.asPath}}, destdir=$output and classpath=$instrumentationClasspath")
|
||||||
|
|
||||||
ant.withGroovyBuilder {
|
ant.withGroovyBuilder {
|
||||||
"instrumentIdeaExtensions"("srcdir" to srcDirs.asPath,
|
"instrumentIdeaExtensions"(
|
||||||
"destdir" to output,
|
"srcdir" to srcDirs.asPath,
|
||||||
"classpath" to instrumentationClasspath,
|
"destdir" to output,
|
||||||
"includeantruntime" to false,
|
"classpath" to instrumentationClasspath,
|
||||||
"instrumentNotNull" to instrumentNotNull) {
|
"includeantruntime" to false,
|
||||||
|
"instrumentNotNull" to instrumentNotNull
|
||||||
|
) {
|
||||||
if (instrumentNotNull) {
|
if (instrumentNotNull) {
|
||||||
ant.withGroovyBuilder {
|
ant.withGroovyBuilder {
|
||||||
"skip"("pattern" to "kotlin/Metadata")
|
"skip"("pattern" to "kotlin/Metadata")
|
||||||
|
|||||||
Reference in New Issue
Block a user