Make pluginOptions.classpath a separate input in the Gradle tasks

(cherry picked from commit b03e758)
This commit is contained in:
Sergey Igushkin
2017-11-16 16:20:21 +03:00
parent a752d30f12
commit a8ba8fbf77
3 changed files with 16 additions and 5 deletions
@@ -44,6 +44,9 @@ open class KaptGenerateStubsTask : KotlinCompile() {
@get:Classpath @get:InputFiles
lateinit var kaptClasspath: List<File>
@get:Classpath @get:InputFiles @Suppress("unused")
internal val kotlinTaskPluginClasspath get() = kotlinCompileTask.pluginClasspath
override fun source(vararg sources: Any?): SourceTask? {
return super.source(sourceRootsContainer.add(sources))
}
@@ -61,7 +64,7 @@ open class KaptGenerateStubsTask : KotlinCompile() {
override fun setupCompilerArgs(args: K2JVMCompilerArguments, defaultsOnly: Boolean) {
kotlinCompileTask.setupCompilerArgs(args)
args.pluginClasspaths = (pluginOptions.classpath + args.pluginClasspaths!!).toSet().toTypedArray()
args.pluginClasspaths = (pluginClasspath + args.pluginClasspaths!!).toSet().toTypedArray()
args.pluginOptions = (pluginOptions.arguments + args.pluginOptions!!).toTypedArray()
args.verbose = project.hasProperty("kapt.verbose") && project.property("kapt.verbose").toString().toBoolean() == true
args.classpathAsList = this.compileClasspath.toList()
@@ -43,7 +43,7 @@ open class KaptTask : ConventionTask(), CompilerArgumentAware<K2JVMCompilerArgum
override fun setupCompilerArgs(args: K2JVMCompilerArguments, defaultsOnly: Boolean) {
kotlinCompileTask.setupCompilerArgs(args)
args.pluginClasspaths = (pluginOptions.classpath + args.pluginClasspaths!!).toSet().toTypedArray()
args.pluginClasspaths = (pluginClasspath + args.pluginClasspaths!!).toSet().toTypedArray()
args.pluginOptions = (pluginOptions.arguments + args.pluginOptions!!).toTypedArray()
args.verbose = project.hasProperty("kapt.verbose") && project.property("kapt.verbose").toString().toBoolean() == true
}
@@ -52,6 +52,12 @@ open class KaptTask : ConventionTask(), CompilerArgumentAware<K2JVMCompilerArgum
val classpath: FileCollection
get() = kotlinCompileTask.classpath
@get:Classpath @get:InputFiles @Suppress("unused")
internal val kotlinTaskPluginClasspaths get() = kotlinCompileTask.pluginClasspath
@get:Classpath @get:InputFiles
internal val pluginClasspath get() = pluginOptions.classpath
val source: FileCollection
@InputFiles get() {
val sourcesFromKotlinTask = kotlinCompileTask.source
@@ -37,7 +37,6 @@ import org.jetbrains.kotlin.cli.common.messages.MessageCollector
import org.jetbrains.kotlin.compilerRunner.*
import org.jetbrains.kotlin.gradle.dsl.*
import org.jetbrains.kotlin.gradle.internal.CompilerArgumentAware
import org.jetbrains.kotlin.gradle.internal.CompilerArgumentAware
import org.jetbrains.kotlin.gradle.internal.prepareCompilerArguments
import org.jetbrains.kotlin.gradle.plugin.kotlinDebug
import org.jetbrains.kotlin.gradle.plugin.kotlinInfo
@@ -104,6 +103,9 @@ abstract class AbstractKotlinCompile<T : CommonCompilerArguments>() : AbstractKo
get() = (classpath + additionalClasspath)
.filterTo(LinkedHashSet(), File::exists)
@get:Classpath @get:InputFiles
internal val pluginClasspath get() = pluginOptions.classpath
private val kotlinExt: KotlinProjectExtension
get() = project.extensions.findByType(KotlinProjectExtension::class.java)!!
@@ -228,7 +230,7 @@ abstract class AbstractKotlinCompile<T : CommonCompilerArguments>() : AbstractKo
}
open fun setupPlugins(compilerArgs: T) {
compilerArgs.pluginClasspaths = pluginOptions.classpath.toTypedArray()
compilerArgs.pluginClasspaths = pluginClasspath.toTypedArray()
compilerArgs.pluginOptions = pluginOptions.arguments.toTypedArray()
}
}
@@ -285,7 +287,7 @@ open class KotlinCompile : AbstractKotlinCompile<K2JVMCompilerArguments>(), Kotl
K2JVMCompilerArguments()
override fun setupPlugins(compilerArgs: K2JVMCompilerArguments) {
compilerArgs.pluginClasspaths = pluginOptions.classpath.toTypedArray()
compilerArgs.pluginClasspaths = pluginClasspath.toTypedArray()
val kaptPluginOptions = getKaptPluginOptions()
compilerArgs.pluginOptions = (pluginOptions.arguments + kaptPluginOptions.arguments).toTypedArray()