Integrate serialization plugin into big Kotlin plugin

Split import handlers into multiple files
Add empty Maven handler for Android Studio

Add testRuntime dependency on kx-serialization-plugin for all modules which require compiler
plugins in test classpath
This commit is contained in:
Leonid Startsev
2018-09-05 16:03:16 +03:00
parent 087f60389a
commit dea69e4469
60 changed files with 117 additions and 184 deletions
@@ -43,6 +43,7 @@ dependencies {
testRuntime(project(":noarg-ide-plugin"))
testRuntime(project(":allopen-ide-plugin"))
testRuntime(project(":kotlin-scripting-idea"))
testRuntime(project(":kotlinx-serialization-compiler-plugin"))
testRuntime(project(":plugins:lint"))
testRuntime(intellijPluginDep("junit"))
testRuntime(intellijPluginDep("IntelliLang"))
@@ -43,6 +43,7 @@ dependencies {
testRuntime(project(":noarg-ide-plugin"))
testRuntime(project(":allopen-ide-plugin"))
testRuntime(project(":kotlin-scripting-idea"))
testRuntime(project(":kotlinx-serialization-compiler-plugin"))
testRuntime(project(":plugins:lint"))
testRuntime(intellijPluginDep("junit"))
testRuntime(intellijPluginDep("IntelliLang"))
@@ -43,6 +43,7 @@ dependencies {
testRuntime(project(":noarg-ide-plugin"))
testRuntime(project(":allopen-ide-plugin"))
testRuntime(project(":kotlin-scripting-idea"))
testRuntime(project(":kotlinx-serialization-compiler-plugin"))
testRuntime(project(":plugins:lint"))
testRuntime(intellijPluginDep("junit"))
testRuntime(intellijPluginDep("IntelliLang"))
@@ -43,6 +43,7 @@ dependencies {
testRuntime(project(":noarg-ide-plugin"))
testRuntime(project(":allopen-ide-plugin"))
testRuntime(project(":kotlin-scripting-idea"))
testRuntime(project(":kotlinx-serialization-compiler-plugin"))
testRuntime(project(":plugins:lint"))
testRuntime(intellijPluginDep("junit"))
testRuntime(intellijPluginDep("IntelliLang"))
@@ -43,6 +43,7 @@ dependencies {
testRuntime(project(":noarg-ide-plugin"))
testRuntime(project(":allopen-ide-plugin"))
testRuntime(project(":kotlin-scripting-idea"))
testRuntime(project(":kotlinx-serialization-compiler-plugin"))
testRuntime(project(":plugins:lint"))
testRuntime(intellijPluginDep("junit"))
testRuntime(intellijPluginDep("IntelliLang"))
@@ -5,12 +5,13 @@ plugins {
kotlin("jvm")
id("jps-compatible")
}
jvmTarget = "1.6"
dependencies {
// val compileOnly by configurations
// val runtime by configurations
compileOnly(intellijCoreDep()) { includeJars("intellij-core") }
compileOnly(intellijDep())
compileOnly(intellijPluginDep("maven"))
excludeInAndroidStudio(rootProject) { compileOnly(intellijPluginDep("maven")) }
compileOnly(project(":jps-plugin"))
compileOnly(project(":compiler:plugin-api"))
compileOnly(project(":compiler:frontend"))
@@ -35,10 +36,8 @@ val jar = runtimeJar {
from(fileTree("$projectDir/src")) { include("META-INF/**") }
}
val serialPluginDir: File by rootProject.extra
dist(targetDir = File(serialPluginDir,"lib"), targetName = the<BasePluginConvention>().archivesBaseName.removePrefix("kotlin-") + ".jar")
dist(targetName = the<BasePluginConvention>().archivesBaseName + ".jar")
ideaPlugin {
from(jar)
rename("^kotlin-", "")
}
runtimeJar()
ideaPlugin()
@@ -1,23 +0,0 @@
<idea-plugin url="https://github.com/Kotlin/kotlinx.serialization" >
<name>Kotlin-serialization</name>
<id>org.jetbrains.kotlinx.serialization</id>
<version>0.5.2-SNAPSHOT</version>
<depends>org.jetbrains.kotlin</depends>
<idea-version since-build="172"/>
<extensions defaultExtensionNs="org.jetbrains.kotlin">
<expressionCodegenExtension implementation="org.jetbrains.kotlinx.serialization.compiler.extensions.SerializationCodegenExtension"/>
<syntheticResolveExtension implementation="org.jetbrains.kotlinx.serialization.compiler.extensions.SerializationResolveExtension"/>
<jsSyntheticTranslateExtension implementation="org.jetbrains.kotlinx.serialization.compiler.extensions.SerializationJsExtension"/>
<irGenerationExtension implementation="org.jetbrains.kotlinx.serialization.compiler.extensions.SerializationLoweringExtension"/>
<gradleProjectImportHandler implementation="org.jetbrains.kotlinx.serialization.idea.KotlinSerializationGradleImportHandler"/>
<mavenProjectImportHandler implementation="org.jetbrains.kotlinx.serialization.idea.KotlinSerializationMavenImportHandler"/>
</extensions>
<extensions defaultExtensionNs="com.intellij">
<compileServer.plugin classpath="kotlinx-serialization-compiler-plugin.jar"/>
</extensions>
</idea-plugin>
@@ -0,0 +1,24 @@
/*
* Copyright 2010-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
* that can be found in the license/LICENSE.txt file.
*/
package org.jetbrains.kotlinx.serialization.idea
import com.intellij.openapi.externalSystem.model.DataNode
import com.intellij.openapi.externalSystem.model.project.ModuleData
import org.jetbrains.kotlin.idea.configuration.GradleProjectImportHandler
import org.jetbrains.kotlin.idea.facet.KotlinFacet
import org.jetbrains.plugins.gradle.model.data.GradleSourceSetData
class KotlinSerializationGradleImportHandler : GradleProjectImportHandler {
override fun importBySourceSet(facet: KotlinFacet, sourceSetNode: DataNode<GradleSourceSetData>) {
KotlinSerializationImportHandler.modifyCompilerArguments(facet, PLUGIN_GRADLE_JAR)
}
override fun importByModule(facet: KotlinFacet, moduleNode: DataNode<ModuleData>) {
KotlinSerializationImportHandler.modifyCompilerArguments(facet, PLUGIN_GRADLE_JAR)
}
private val PLUGIN_GRADLE_JAR = "kotlinx-gradle-serialization-plugin"
}
@@ -16,38 +16,11 @@
package org.jetbrains.kotlinx.serialization.idea
import com.intellij.openapi.externalSystem.model.DataNode
import com.intellij.openapi.externalSystem.model.project.ModuleData
import com.intellij.util.PathUtil
import org.jetbrains.idea.maven.project.MavenProject
import org.jetbrains.kotlin.cli.common.arguments.CommonCompilerArguments
import org.jetbrains.kotlin.idea.configuration.GradleProjectImportHandler
import org.jetbrains.kotlin.idea.facet.KotlinFacet
import org.jetbrains.kotlin.idea.maven.MavenProjectImportHandler
import org.jetbrains.kotlinx.serialization.idea.KotlinSerializationImportHandler.modifyCompilerArguments
import org.jetbrains.plugins.gradle.model.data.GradleSourceSetData
import java.io.File
class KotlinSerializationGradleImportHandler : GradleProjectImportHandler {
override fun importBySourceSet(facet: KotlinFacet, sourceSetNode: DataNode<GradleSourceSetData>) {
modifyCompilerArguments(facet, PLUGIN_GRADLE_JAR)
}
override fun importByModule(facet: KotlinFacet, moduleNode: DataNode<ModuleData>) {
modifyCompilerArguments(facet, PLUGIN_GRADLE_JAR)
}
private val PLUGIN_GRADLE_JAR = "kotlinx-gradle-serialization-plugin"
}
class KotlinSerializationMavenImportHandler: MavenProjectImportHandler {
override fun invoke(facet: KotlinFacet, mavenProject: MavenProject) {
modifyCompilerArguments(facet, PLUGIN_MAVEN_JAR)
}
private val PLUGIN_MAVEN_JAR = "kotlinx-maven-serialization-plugin"
}
internal object KotlinSerializationImportHandler {
private val PLUGIN_JPS_JAR :String
get() = File(PathUtil.getJarPathForClass(this::class.java)).absolutePath
@@ -0,0 +1,18 @@
/*
* Copyright 2010-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
* that can be found in the license/LICENSE.txt file.
*/
package org.jetbrains.kotlinx.serialization.idea
import org.jetbrains.idea.maven.project.MavenProject
import org.jetbrains.kotlin.idea.facet.KotlinFacet
import org.jetbrains.kotlin.idea.maven.MavenProjectImportHandler
class KotlinSerializationMavenImportHandler: MavenProjectImportHandler {
override fun invoke(facet: KotlinFacet, mavenProject: MavenProject) {
KotlinSerializationImportHandler.modifyCompilerArguments(facet, PLUGIN_MAVEN_JAR)
}
private val PLUGIN_MAVEN_JAR = "kotlinx-maven-serialization-plugin"
}
+1
View File
@@ -34,6 +34,7 @@ dependencies {
testRuntime(project(":kotlin-scripting-idea"))
testRuntime(project(":plugins:android-extensions-ide"))
testRuntime(project(":plugins:kapt3-idea"))
testRuntime(project(":kotlinx-serialization-compiler-plugin"))
testRuntime(intellijDep())
testRuntime(intellijPluginDep("junit"))
testRuntime(intellijPluginDep("gradle"))
+1
View File
@@ -32,6 +32,7 @@ dependencies {
testRuntime(project(":kotlin-scripting-idea"))
testRuntime(project(":plugins:android-extensions-ide"))
testRuntime(project(":plugins:kapt3-idea"))
testRuntime(project(":kotlinx-serialization-compiler-plugin"))
testRuntime(intellijDep())
testRuntime(intellijPluginDep("junit"))
testRuntime(intellijPluginDep("gradle"))