diff --git a/buildSrc/src/main/kotlin/instrument.kt b/buildSrc/src/main/kotlin/instrument.kt index 82c9a05a96b..17009b71035 100644 --- a/buildSrc/src/main/kotlin/instrument.kt +++ b/buildSrc/src/main/kotlin/instrument.kt @@ -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. @@ -23,7 +23,6 @@ import org.gradle.api.file.ConfigurableFileCollection import org.gradle.api.file.FileCollection import org.gradle.api.internal.ConventionTask import org.gradle.api.plugins.ExtensionAware -import org.gradle.api.plugins.JavaPluginConvention import org.gradle.api.tasks.* import org.gradle.api.tasks.compile.AbstractCompile import org.gradle.kotlin.dsl.* @@ -46,8 +45,8 @@ fun Project.configureInstrumentation() { val testCompile = tasks.findByName("compileTestKotlin") as AbstractCompile? testCompile?.doFirst { testCompile.classpath = (testCompile.classpath - - mainSourceSet.output.classesDirs - + files((mainSourceSet as ExtensionAware).extra.get("classesDirsCopy"))) + - mainSourceSet.output.classesDirs + + files((mainSourceSet as ExtensionAware).extra.get("classesDirsCopy"))) } } @@ -68,7 +67,8 @@ fun Project.configureInstrumentation() { logger.info("Saving old sources dir for project ${project.name}") val instrumentedClassesDir = File(project.buildDir, "classes/${sourceSetParam.name}-instrumented") (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 { dependsOn(sourceSetParam.classesTaskName).onlyIf { !classesDirsCopy.isEmpty } sourceSet = sourceSetParam @@ -109,17 +109,23 @@ open class IntelliJInstrumentCodeTask : ConventionTask() { @TaskAction 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() copyOriginalClasses() val classpath = instrumentationClasspath!! ant.withGroovyBuilder { - "taskdef"("name" to "instrumentIdeaExtensions", - "classpath" to classpath.asPath, - "loaderref" to LOADER_REF, - "classname" to "com.intellij.ant.InstrumentIdeaExtensions") + "taskdef"( + "name" to "instrumentIdeaExtensions", + "classpath" to classpath.asPath, + "loaderref" to LOADER_REF, + "classname" to "com.intellij.ant.InstrumentIdeaExtensions" + ) } logger.info("Compiling forms and instrumenting code with nullability preconditions") @@ -136,10 +142,12 @@ open class IntelliJInstrumentCodeTask : ConventionTask() { private fun prepareNotNullInstrumenting(classpath: String): Boolean { ant.withGroovyBuilder { - "typedef"("name" to "skip", - "classpath" to classpath, - "loaderref" to LOADER_REF, - "classname" to FILTER_ANNOTATION_REGEXP_CLASS) + "typedef"( + "name" to "skip", + "classpath" to classpath, + "loaderref" to LOADER_REF, + "classname" to FILTER_ANNOTATION_REGEXP_CLASS + ) } return true } @@ -149,20 +157,22 @@ open class IntelliJInstrumentCodeTask : ConventionTask() { // Instrumentation needs to have access to sources of forms for inclusion 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 = - depSourceDirectorySets.fold(sourceSet!!.compileClasspath) { acc, v -> acc + v }.asPath.also { - logger.info("Using following dependency source dirs: $it") - } + depSourceDirectorySets.fold(sourceSet!!.compileClasspath) { acc, v -> acc + v }.asPath.also { + logger.info("Using following dependency source dirs: $it") + } logger.info("Running instrumentIdeaExtensions with srcdir=${srcDirs.asPath}}, destdir=$output and classpath=$instrumentationClasspath") ant.withGroovyBuilder { - "instrumentIdeaExtensions"("srcdir" to srcDirs.asPath, - "destdir" to output, - "classpath" to instrumentationClasspath, - "includeantruntime" to false, - "instrumentNotNull" to instrumentNotNull) { + "instrumentIdeaExtensions"( + "srcdir" to srcDirs.asPath, + "destdir" to output, + "classpath" to instrumentationClasspath, + "includeantruntime" to false, + "instrumentNotNull" to instrumentNotNull + ) { if (instrumentNotNull) { ant.withGroovyBuilder { "skip"("pattern" to "kotlin/Metadata") diff --git a/buildSrc/src/main/kotlin/instrument.kt.181 b/buildSrc/src/main/kotlin/instrument.kt.181 index 81c02b650e8..29275b96620 100644 --- a/buildSrc/src/main/kotlin/instrument.kt.181 +++ b/buildSrc/src/main/kotlin/instrument.kt.181 @@ -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. @@ -23,7 +23,6 @@ import org.gradle.api.file.ConfigurableFileCollection import org.gradle.api.file.FileCollection import org.gradle.api.internal.ConventionTask import org.gradle.api.plugins.ExtensionAware -import org.gradle.api.plugins.JavaPluginConvention import org.gradle.api.tasks.* import org.gradle.api.tasks.compile.AbstractCompile import org.gradle.kotlin.dsl.* @@ -46,8 +45,8 @@ fun Project.configureInstrumentation() { val testCompile = tasks.findByName("compileTestKotlin") as AbstractCompile? testCompile?.doFirst { testCompile.classpath = (testCompile.classpath - - mainSourceSet.output.classesDirs - + files((mainSourceSet as ExtensionAware).extra.get("classesDirsCopy"))) + - mainSourceSet.output.classesDirs + + files((mainSourceSet as ExtensionAware).extra.get("classesDirsCopy"))) } } @@ -68,7 +67,8 @@ fun Project.configureInstrumentation() { logger.info("Saving old sources dir for project ${project.name}") val instrumentedClassesDir = File(project.buildDir, "classes/${sourceSetParam.name}-instrumented") (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 { dependsOn(sourceSetParam.classesTaskName).onlyIf { !classesDirsCopy.isEmpty } sourceSet = sourceSetParam @@ -109,17 +109,23 @@ open class IntelliJInstrumentCodeTask : ConventionTask() { @TaskAction 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() copyOriginalClasses() val classpath = instrumentationClasspath!! ant.withGroovyBuilder { - "taskdef"("name" to "instrumentIdeaExtensions", - "classpath" to classpath.asPath, - "loaderref" to LOADER_REF, - "classname" to "com.intellij.ant.InstrumentIdeaExtensions") + "taskdef"( + "name" to "instrumentIdeaExtensions", + "classpath" to classpath.asPath, + "loaderref" to LOADER_REF, + "classname" to "com.intellij.ant.InstrumentIdeaExtensions" + ) } logger.info("Compiling forms and instrumenting code with nullability preconditions") @@ -136,10 +142,12 @@ open class IntelliJInstrumentCodeTask : ConventionTask() { private fun prepareNotNullInstrumenting(classpath: String): Boolean { ant.withGroovyBuilder { - "typedef"("name" to "skip", - "classpath" to classpath, - "loaderref" to LOADER_REF, - "classname" to FILTER_ANNOTATION_REGEXP_CLASS) + "typedef"( + "name" to "skip", + "classpath" to classpath, + "loaderref" to LOADER_REF, + "classname" to FILTER_ANNOTATION_REGEXP_CLASS + ) } return true } @@ -149,20 +157,22 @@ open class IntelliJInstrumentCodeTask : ConventionTask() { // Instrumentation needs to have access to sources of forms for inclusion 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 = - depSourceDirectorySets.fold(sourceSet!!.compileClasspath) { acc, v -> acc + v }.asPath.also { - logger.info("Using following dependency source dirs: $it") - } + depSourceDirectorySets.fold(sourceSet!!.compileClasspath) { acc, v -> acc + v }.asPath.also { + logger.info("Using following dependency source dirs: $it") + } logger.info("Running instrumentIdeaExtensions with srcdir=${srcDirs.asPath}}, destdir=$output and classpath=$instrumentationClasspath") ant.withGroovyBuilder { - "instrumentIdeaExtensions"("srcdir" to srcDirs.asPath, - "destdir" to output, - "classpath" to instrumentationClasspath, - "includeantruntime" to false, - "instrumentNotNull" to instrumentNotNull) { + "instrumentIdeaExtensions"( + "srcdir" to srcDirs.asPath, + "destdir" to output, + "classpath" to instrumentationClasspath, + "includeantruntime" to false, + "instrumentNotNull" to instrumentNotNull + ) { if (instrumentNotNull) { ant.withGroovyBuilder { "skip"("pattern" to "kotlin/Metadata")