kapt: Support inherited annotations in Gradle

This commit is contained in:
Yan Zhulanow
2015-06-23 18:26:04 +03:00
parent a90f175fc2
commit 700d495d7f
3 changed files with 31 additions and 14 deletions
@@ -131,17 +131,7 @@ public open class KotlinCompile() : AbstractKotlinCompile<K2JVMCompilerArguments
val basePluginOptions = extraProperties.getOrNull<Array<String>>("compilerPluginArguments") ?: arrayOf()
val pluginOptions = arrayListOf(*basePluginOptions)
val kaptAnnotationsFile = extraProperties.getOrNull<File>("kaptAnnotationsFile")
if (kaptAnnotationsFile != null) {
if (kaptAnnotationsFile.exists()) kaptAnnotationsFile.delete()
pluginOptions.add("plugin:$ANNOTATIONS_PLUGIN_NAME:output=" + kaptAnnotationsFile)
}
val kaptClassFileStubsDir = extraProperties.getOrNull<File>("stubsDir")
if (kaptClassFileStubsDir != null) {
pluginOptions.add("plugin:$ANNOTATIONS_PLUGIN_NAME:stubs=" + kaptClassFileStubsDir)
}
handleKaptProperties(extraProperties, pluginOptions)
args.pluginOptions = pluginOptions.toTypedArray()
getLogger().kotlinDebug("args.pluginOptions = ${args.pluginOptions.joinToString(File.pathSeparator)}")
@@ -162,6 +152,24 @@ public open class KotlinCompile() : AbstractKotlinCompile<K2JVMCompilerArguments
args.noParamAssertions = kotlinOptions.noParamAssertions
}
private fun handleKaptProperties(extraProperties: ExtraPropertiesExtension, pluginOptions: MutableList<String>) {
val kaptAnnotationsFile = extraProperties.getOrNull<File>("kaptAnnotationsFile")
if (kaptAnnotationsFile != null) {
if (kaptAnnotationsFile.exists()) kaptAnnotationsFile.delete()
pluginOptions.add("plugin:$ANNOTATIONS_PLUGIN_NAME:output=" + kaptAnnotationsFile)
}
val kaptClassFileStubsDir = extraProperties.getOrNull<File>("kaptStubsDir")
if (kaptClassFileStubsDir != null) {
pluginOptions.add("plugin:$ANNOTATIONS_PLUGIN_NAME:stubs=" + kaptClassFileStubsDir)
}
val supportInheritedAnnotations = extraProperties.getOrNull<Boolean>("kaptInheritedAnnotations")
if (supportInheritedAnnotations != null && supportInheritedAnnotations) {
pluginOptions.add("plugin:$ANNOTATIONS_PLUGIN_NAME:inherited=true")
}
}
private fun getJavaSourceRoots(): Set<File> =
getSource()
.filter { it.isJavaFile() }