Fixed duplicated kapt options caused by multiple call to args setup

Separated kapt args from other plugin options.

Issues: #KT-16965 Fixed

Fix indentation
This commit is contained in:
Sergey Igushkin
2017-04-10 16:32:17 +03:00
parent ea3adb0629
commit 8cdb08cbfe
@@ -196,9 +196,11 @@ open class KotlinCompile : AbstractKotlinCompile<K2JVMCompilerArguments>(), Kotl
super.setupCompilerArgs(args, defaultsOnly) super.setupCompilerArgs(args, defaultsOnly)
args.apply { fillDefaultValues() } args.apply { fillDefaultValues() }
handleKaptProperties()
args.pluginClasspaths = pluginOptions.classpath.toTypedArray() args.pluginClasspaths = pluginOptions.classpath.toTypedArray()
args.pluginOptions = pluginOptions.arguments.toTypedArray()
val kaptPluginOptions = getKaptPluginOptions()
args.pluginOptions = (pluginOptions.arguments + kaptPluginOptions.arguments).toTypedArray()
args.moduleName = moduleName args.moduleName = moduleName
args.addCompilerBuiltIns = true args.addCompilerBuiltIns = true
@@ -284,21 +286,22 @@ open class KotlinCompile : AbstractKotlinCompile<K2JVMCompilerArguments>(), Kotl
throwGradleExceptionIfError(exitCode) throwGradleExceptionIfError(exitCode)
} }
private fun handleKaptProperties() { private fun getKaptPluginOptions() =
CompilerPluginOptions().apply {
kaptOptions.annotationsFile?.let { kaptAnnotationsFile -> kaptOptions.annotationsFile?.let { kaptAnnotationsFile ->
if (incremental) { if (incremental) {
kaptAnnotationsFileUpdater = AnnotationFileUpdaterImpl(kaptAnnotationsFile) kaptAnnotationsFileUpdater = AnnotationFileUpdaterImpl(kaptAnnotationsFile)
} }
pluginOptions.addPluginArgument(ANNOTATIONS_PLUGIN_NAME, "output", kaptAnnotationsFile.canonicalPath) addPluginArgument(ANNOTATIONS_PLUGIN_NAME, "output", kaptAnnotationsFile.canonicalPath)
} }
if (kaptOptions.generateStubs) { if (kaptOptions.generateStubs) {
pluginOptions.addPluginArgument(ANNOTATIONS_PLUGIN_NAME, "stubs", destinationDir.canonicalPath) addPluginArgument(ANNOTATIONS_PLUGIN_NAME, "stubs", destinationDir.canonicalPath)
} }
if (kaptOptions.supportInheritedAnnotations) { if (kaptOptions.supportInheritedAnnotations) {
pluginOptions.addPluginArgument(ANNOTATIONS_PLUGIN_NAME, "inherited", true.toString()) addPluginArgument(ANNOTATIONS_PLUGIN_NAME, "inherited", true.toString())
} }
} }