AllOpen, NoArg: Use the bundled plugins in Maven projects
Use the bundled compiler plugins for Maven projects (as we do for Gradle projects already) because the plugin provided as a dependency in the POM file may have an incompatible version.
This commit is contained in:
+2
-1
@@ -65,7 +65,8 @@ abstract class AbstractGradleImportHandler : GradleProjectImportHandler {
|
||||
|
||||
val annotationFqNames = annotationFqNamesList.split(',')
|
||||
|
||||
// For now we can't use plugins from Gradle cause they're shaded. So we use ones from the IDEA plugin
|
||||
// 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.
|
||||
val classpath = listOf(pluginJarFileFromIdea.absolutePath)
|
||||
|
||||
return AnnotationBasedCompilerPluginSetup(annotationFqNames, classpath)
|
||||
|
||||
+5
-10
@@ -30,6 +30,7 @@ abstract class AbstractMavenImportHandler : MavenProjectImportHandler {
|
||||
abstract val pluginName: String
|
||||
abstract val annotationOptionName: String
|
||||
abstract val mavenPluginArtifactName: String
|
||||
abstract val pluginJarFileFromIdea: File
|
||||
|
||||
override fun invoke(facet: KotlinFacet, mavenProject: MavenProject) {
|
||||
modifyCompilerArgumentsForPlugin(facet, getPluginSetup(mavenProject),
|
||||
@@ -45,15 +46,6 @@ abstract class AbstractMavenImportHandler : MavenProjectImportHandler {
|
||||
it.groupId == KOTLIN_PLUGIN_GROUP_ID && it.artifactId == KOTLIN_PLUGIN_ARTIFACT_ID
|
||||
} ?: return null
|
||||
|
||||
val runtimeJarFile = mavenProject.dependencies
|
||||
.firstOrNull { it.groupId == KOTLIN_PLUGIN_GROUP_ID &&
|
||||
(it.artifactId == "kotlin-runtime" || it.artifactId == "kotlin-stdlib") }
|
||||
?.file ?: return null
|
||||
val runtimeVersion = runtimeJarFile.parentFile.name
|
||||
|
||||
val mavenCompilerPluginJar = File(runtimeJarFile.parentFile.parentFile.parentFile,
|
||||
"$mavenPluginArtifactName/$runtimeVersion/$mavenPluginArtifactName-$runtimeVersion.jar")
|
||||
|
||||
val configuration = kotlinPlugin.configurationElement ?: return null
|
||||
|
||||
val enabledCompilerPlugins = configuration.getElement("compilerPlugins")
|
||||
@@ -67,8 +59,11 @@ abstract class AbstractMavenImportHandler : MavenProjectImportHandler {
|
||||
?.mapTo(mutableListOf()) { (it as Text).text }
|
||||
?: mutableListOf<String>()
|
||||
|
||||
// We can't use the plugin from Gradle as it may have the incompatible version
|
||||
val classpath = listOf(pluginJarFileFromIdea.absolutePath)
|
||||
|
||||
val annotationFqNames = getAnnotations(enabledCompilerPlugins, compilerPluginOptions) ?: return null
|
||||
return AnnotationBasedCompilerPluginSetup(annotationFqNames, listOf(mavenCompilerPluginJar.absolutePath))
|
||||
return AnnotationBasedCompilerPluginSetup(annotationFqNames, classpath)
|
||||
}
|
||||
|
||||
private fun Element.getElement(name: String) = content.firstOrNull { it is Element && it.name == name } as? Element
|
||||
|
||||
Reference in New Issue
Block a user