Fix 'kotlin-spring' and 'kotlin-noarg' Gradle plugin importing (KT-17049)

Allopen and Noarg plugins now use 'presets' that should be handled in the Gradle importer as well.
This commit is contained in:
Yan Zhulanow
2017-03-28 22:04:01 +03:00
committed by Yan Zhulanow
parent 9fa16364e1
commit 21da11fe18
5 changed files with 31 additions and 5 deletions
@@ -28,7 +28,7 @@ import java.io.File
abstract class AbstractGradleImportHandler : GradleProjectImportHandler {
private companion object {
private val TASK_DESCRIPTION_REGEX = "Supported annotations: (.*?); Compiler plugin classpath: (.*)".toRegex()
private val TASK_DESCRIPTION_REGEX = "Supported annotations: ([^; ]*); (?:Presets: (.*?); )?Compiler plugin classpath: (.*?)".toRegex()
}
abstract val compilerPluginId: String
@@ -51,6 +51,8 @@ abstract class AbstractGradleImportHandler : GradleProjectImportHandler {
annotationOptionName = annotationOptionName)
}
protected open fun getAnnotationsForPreset(presetName: String): List<String> = emptyList()
private fun getPluginSetupByModule(
moduleNode: DataNode<ModuleData>
): AnnotationBasedCompilerPluginSetup? {
@@ -60,10 +62,10 @@ abstract class AbstractGradleImportHandler : GradleProjectImportHandler {
}?.data as? TaskData ?: return null
val dataStorageTaskDescription = dataStorageTaskData.description ?: return null
val (annotationFqNamesList, _) = TASK_DESCRIPTION_REGEX.matchEntire(
dataStorageTaskDescription)?.groupValues?.drop(1) ?: return null
val matchResult = TASK_DESCRIPTION_REGEX.matchEntire(dataStorageTaskDescription)?.groupValues?.drop(1) ?: return null
val (annotationFqNamesList, presets) = matchResult
val annotationFqNames = annotationFqNamesList.split(',')
val annotationFqNames = annotationFqNamesList.split(',') + presets.split(',').flatMap { getAnnotationsForPreset(it) }
// For now we can't use plugins from Gradle cause they're shaded and may have an incompatible version.
// So we use ones from the IDEA plugin.