[lombok] Support import from gradle to IDE
Introduce base module for ide compiler plugins
This commit is contained in:
committed by
TeamCityServer
parent
b58bea6fa1
commit
8afb6d2761
@@ -139,6 +139,9 @@ dependencies {
|
||||
testRuntime(project(":plugins:annotation-based-compiler-plugins-ide-support")) { isTransitive = false }
|
||||
testRuntime(project(":plugins:parcelize:parcelize-compiler"))
|
||||
testRuntime(project(":plugins:parcelize:parcelize-ide")) { isTransitive = false }
|
||||
testRuntime(project(":plugins:base-compiler-plugins-ide-support")) { isTransitive = false }
|
||||
testRuntime(project(":plugins:lombok:lombok-compiler-plugin"))
|
||||
testRuntime(project(":plugins:lombok:lombok-ide-plugin")) { isTransitive = false }
|
||||
testRuntime(project(":kotlin-scripting-idea")) { isTransitive = false }
|
||||
testRuntime(project(":kotlin-scripting-compiler-impl"))
|
||||
testRuntime(project(":sam-with-receiver-ide-plugin")) { isTransitive = false }
|
||||
|
||||
@@ -48,6 +48,7 @@ dependencies {
|
||||
testRuntime(project(":kotlin-scripting-idea"))
|
||||
testRuntime(project(":kotlinx-serialization-ide-plugin"))
|
||||
testRuntime(project(":plugins:parcelize:parcelize-ide"))
|
||||
testRuntime(project(":plugins:lombok:lombok-ide-plugin"))
|
||||
|
||||
testRuntime(intellijPluginDep("android"))
|
||||
|
||||
|
||||
@@ -44,6 +44,7 @@ dependencies {
|
||||
testRuntimeOnly(project(":kotlin-scripting-idea"))
|
||||
testRuntimeOnly(project(":kotlinx-serialization-ide-plugin"))
|
||||
testRuntimeOnly(project(":plugins:parcelize:parcelize-ide"))
|
||||
testRuntimeOnly(project(":plugins:lombok:lombok-ide-plugin"))
|
||||
testRuntimeOnly(project(":nj2k:nj2k-services"))
|
||||
testRuntimeOnly(project(":kotlin-reflect"))
|
||||
testRuntimeOnly(project(":idea:kotlin-gradle-tooling"))
|
||||
|
||||
@@ -50,6 +50,7 @@ dependencies {
|
||||
testRuntime(project(":kotlin-scripting-idea"))
|
||||
testRuntime(project(":plugins:parcelize:parcelize-ide"))
|
||||
testRuntime(project(":kotlinx-serialization-ide-plugin"))
|
||||
testRuntime(project(":plugins:lombok:lombok-ide-plugin"))
|
||||
// TODO: the order of the plugins matters here, consider avoiding order-dependency
|
||||
Platform[192].orHigher {
|
||||
testRuntime(intellijPluginDep("java"))
|
||||
@@ -98,4 +99,4 @@ if (Ide.AS41.orHigher()) {
|
||||
getOrCreateTask<Test>("test") {
|
||||
setExcludes(listOf("**"))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -59,6 +59,7 @@ dependencies {
|
||||
testRuntime(project(":kotlin-scripting-idea"))
|
||||
testRuntime(project(":kotlinx-serialization-ide-plugin"))
|
||||
testRuntime(project(":plugins:parcelize:parcelize-ide"))
|
||||
testRuntime(project(":plugins:lombok:lombok-ide-plugin"))
|
||||
testRuntime(project(":kotlin-gradle-statistics"))
|
||||
// TODO: the order of the plugins matters here, consider avoiding order-dependency
|
||||
testRuntime(intellijPluginDep("junit"))
|
||||
|
||||
@@ -65,6 +65,7 @@ dependencies {
|
||||
testRuntime(project(":plugins:parcelize:parcelize-ide"))
|
||||
testRuntime(project(":kotlin-scripting-idea"))
|
||||
testRuntime(project(":kotlinx-serialization-ide-plugin"))
|
||||
testRuntime(project(":plugins:lombok:lombok-ide-plugin"))
|
||||
|
||||
testRuntime(intellijDep())
|
||||
// TODO: the order of the plugins matters here, consider avoiding order-dependency
|
||||
|
||||
@@ -37,6 +37,7 @@ dependencies {
|
||||
testRuntimeOnly(project(":kotlin-gradle-statistics"))
|
||||
testRuntimeOnly(project(":kotlin-scripting-idea"))
|
||||
testRuntimeOnly(project(":plugins:parcelize:parcelize-ide"))
|
||||
testRuntimeOnly(project(":plugins:lombok:lombok-ide-plugin"))
|
||||
testRuntimeOnly(intellijRuntimeAnnotations())
|
||||
|
||||
|
||||
|
||||
@@ -36,6 +36,7 @@ dependencies {
|
||||
testRuntime(project(":kotlin-scripting-idea"))
|
||||
testRuntime(project(":kotlinx-serialization-ide-plugin"))
|
||||
testRuntime(project(":plugins:parcelize:parcelize-ide"))
|
||||
testRuntime(project(":plugins:lombok:lombok-ide-plugin"))
|
||||
|
||||
testRuntime(intellijDep())
|
||||
testRuntime(intellijRuntimeAnnotations())
|
||||
@@ -51,4 +52,4 @@ projectTest(parallel = true) {
|
||||
workingDir = rootDir
|
||||
}
|
||||
|
||||
testsJar()
|
||||
testsJar()
|
||||
|
||||
+2
-1
@@ -6,4 +6,5 @@ org.jetbrains.kotlin.allopen.ide.AllOpenModelBuilderService
|
||||
org.jetbrains.kotlin.kapt.idea.KaptModelBuilderService
|
||||
org.jetbrains.kotlin.noarg.ide.NoArgModelBuilderService
|
||||
org.jetbrains.kotlin.samWithReceiver.ide.SamWithReceiverModelBuilderService
|
||||
org.jetbrains.kotlin.parcelize.ide.ParcelizeModelBuilderService
|
||||
org.jetbrains.kotlin.parcelize.ide.ParcelizeModelBuilderService
|
||||
org.jetbrains.kotlin.lombok.ide.LombokModelBuilderService
|
||||
|
||||
+52
@@ -0,0 +1,52 @@
|
||||
/*
|
||||
* Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* 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.kotlin.lombok.ide
|
||||
|
||||
import org.gradle.api.Project
|
||||
import org.jetbrains.plugins.gradle.tooling.AbstractModelBuilderService
|
||||
import org.jetbrains.plugins.gradle.tooling.ErrorMessageBuilder
|
||||
import org.jetbrains.plugins.gradle.tooling.ModelBuilderContext
|
||||
import java.io.File
|
||||
import java.io.Serializable
|
||||
|
||||
interface LombokModel : Serializable {
|
||||
val configurationFile: File?
|
||||
}
|
||||
|
||||
class LombokModelImpl(override val configurationFile: File?) : LombokModel
|
||||
|
||||
class LombokModelBuilderService : AbstractModelBuilderService() {
|
||||
private val extensionName = "kotlinLombok"
|
||||
|
||||
override fun canBuild(modelName: String?): Boolean = modelName == LombokModel::class.java.name
|
||||
|
||||
override fun buildAll(modelName: String, project: Project, context: ModelBuilderContext): Any? {
|
||||
if (project.plugins.findPlugin("kotlin-lombok") == null) return null
|
||||
|
||||
val extension: Any = project.extensions.findByName(extensionName) ?: return null
|
||||
|
||||
val configurationFile = extension.getFieldValue("configurationFile") as? File
|
||||
return LombokModelImpl(configurationFile)
|
||||
}
|
||||
|
||||
override fun getErrorMessageBuilder(project: Project, e: Exception): ErrorMessageBuilder {
|
||||
return ErrorMessageBuilder.create(project, e, "Gradle import errors")
|
||||
.withDescription("Unable to build lombok plugin configuration")
|
||||
}
|
||||
|
||||
private fun Any.getFieldValue(fieldName: String, clazz: Class<*> = this.javaClass): Any? {
|
||||
val field = clazz.declaredFields.firstOrNull { it.name == fieldName }
|
||||
?: return getFieldValue(fieldName, clazz.superclass ?: return null)
|
||||
|
||||
val oldIsAccessible = field.isAccessible
|
||||
try {
|
||||
field.isAccessible = true
|
||||
return field.get(this)
|
||||
} finally {
|
||||
field.isAccessible = oldIsAccessible
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -19,6 +19,7 @@ dependencies {
|
||||
testRuntimeOnly(project(":kotlin-scripting-idea"))
|
||||
testRuntimeOnly(project(":kotlinx-serialization-ide-plugin"))
|
||||
testRuntimeOnly(project(":plugins:parcelize:parcelize-ide"))
|
||||
testRuntimeOnly(project(":plugins:lombok:lombok-ide-plugin"))
|
||||
testRuntimeOnly(project(":nj2k:nj2k-services"))
|
||||
testRuntimeOnly(project(":kotlin-reflect"))
|
||||
testRuntimeOnly(project(":idea:kotlin-gradle-tooling"))
|
||||
@@ -172,4 +173,4 @@ projectTest(taskName = "fe10ProjectPerformanceTest") {
|
||||
}
|
||||
|
||||
|
||||
testsJar()
|
||||
testsJar()
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
<projectResolve implementation="org.jetbrains.kotlin.kapt.idea.KaptProjectResolverExtension" order="last"/>
|
||||
<projectResolve implementation="org.jetbrains.kotlin.allopen.ide.AllOpenProjectResolverExtension" order="last"/>
|
||||
<projectResolve implementation="org.jetbrains.kotlin.noarg.ide.NoArgProjectResolverExtension" order="last"/>
|
||||
<projectResolve implementation="org.jetbrains.kotlin.lombok.ide.LombokGradleProjectResolverExtension" order="last"/>
|
||||
<projectResolve implementation="org.jetbrains.kotlin.samWithReceiver.ide.SamWithReceiverProjectResolverExtension" order="last"/>
|
||||
</extensions>
|
||||
|
||||
@@ -47,6 +48,7 @@
|
||||
<gradleProjectImportHandler implementation="org.jetbrains.kotlin.scripting.idea.plugin.ScriptingGradleProjectImportHandler"/>
|
||||
<gradleProjectImportHandler implementation="org.jetbrains.kotlin.kapt.idea.KaptGradleProjectImportHandler"/>
|
||||
<gradleProjectImportHandler implementation="org.jetbrains.kotlin.noarg.ide.NoArgGradleProjectImportHandler"/>
|
||||
<gradleProjectImportHandler implementation="org.jetbrains.kotlin.lombok.ide.LombokGradleProjectImportHandler"/>
|
||||
<gradleProjectImportHandler implementation="org.jetbrains.kotlin.samWithReceiver.ide.SamWithReceiverGradleProjectImportHandler"/>
|
||||
<gradleProjectImportHandler implementation="org.jetbrains.kotlinx.serialization.idea.KotlinSerializationGradleImportHandler"/>
|
||||
|
||||
|
||||
@@ -28,6 +28,7 @@ dependencies {
|
||||
testRuntime(project(":kotlinx-serialization-ide-plugin")) { isTransitive = false }
|
||||
testRuntime(project(":plugins:parcelize:parcelize-compiler"))
|
||||
testRuntime(project(":plugins:parcelize:parcelize-ide")) { isTransitive = false }
|
||||
testRuntime(project(":plugins:lombok:lombok-ide-plugin"))
|
||||
|
||||
testRuntime(project(":idea:idea-android")) { isTransitive = false }
|
||||
|
||||
@@ -50,4 +51,4 @@ projectTest(parallel = true) {
|
||||
workingDir = rootDir
|
||||
}
|
||||
|
||||
testsJar()
|
||||
testsJar()
|
||||
|
||||
@@ -43,6 +43,7 @@ dependencies {
|
||||
testRuntime(project(":kotlin-scripting-idea"))
|
||||
testRuntime(project(":kotlinx-serialization-ide-plugin"))
|
||||
testRuntime(project(":plugins:parcelize:parcelize-ide"))
|
||||
testRuntime(project(":plugins:lombok:lombok-ide-plugin"))
|
||||
testRuntime(intellijPluginDep("properties"))
|
||||
testRuntime(intellijPluginDep("gradle"))
|
||||
testRuntime(intellijPluginDep("Groovy"))
|
||||
|
||||
+27
@@ -0,0 +1,27 @@
|
||||
/*
|
||||
* Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* 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.kotlin.gradle.model
|
||||
|
||||
import java.io.File
|
||||
|
||||
interface Lombok {
|
||||
|
||||
/**
|
||||
* @return Return a number representing the version of this API.
|
||||
* Always increasing if changed.
|
||||
*/
|
||||
val modelVersion: Long
|
||||
|
||||
/**
|
||||
* @return the module (Gradle project) name
|
||||
*/
|
||||
val name: String
|
||||
|
||||
/**
|
||||
* Lombok configuration file
|
||||
*/
|
||||
val configurationFile: File?
|
||||
}
|
||||
@@ -15,9 +15,7 @@ dependencies {
|
||||
api(project(":kotlin-gradle-plugin-model"))
|
||||
}
|
||||
|
||||
projectTest(parallel = true) {
|
||||
workingDir = projectDir
|
||||
}
|
||||
projectTest(parallel = true)
|
||||
|
||||
publish()
|
||||
|
||||
|
||||
+5
-1
@@ -7,15 +7,19 @@ package org.jetbrains.kotlin.lombok.gradle
|
||||
|
||||
import org.gradle.api.Project
|
||||
import org.gradle.api.provider.Provider
|
||||
import org.gradle.tooling.provider.model.ToolingModelBuilderRegistry
|
||||
import org.jetbrains.kotlin.gradle.plugin.*
|
||||
import org.jetbrains.kotlin.lombok.gradle.model.builder.LombokModelBuilder
|
||||
import javax.inject.Inject
|
||||
|
||||
class LombokSubplugin : KotlinCompilerPluginSupportPlugin {
|
||||
class LombokSubplugin @Inject internal constructor(private val registry: ToolingModelBuilderRegistry) : KotlinCompilerPluginSupportPlugin {
|
||||
|
||||
override fun isApplicable(kotlinCompilation: KotlinCompilation<*>): Boolean =
|
||||
(kotlinCompilation.platformType == KotlinPlatformType.jvm || kotlinCompilation.platformType == KotlinPlatformType.androidJvm)
|
||||
|
||||
override fun apply(target: Project) {
|
||||
target.extensions.create("kotlinLombok", LombokExtension::class.java)
|
||||
registry.register(LombokModelBuilder())
|
||||
}
|
||||
|
||||
override fun applyToCompilation(kotlinCompilation: KotlinCompilation<*>): Provider<List<SubpluginOption>> {
|
||||
|
||||
+25
@@ -0,0 +1,25 @@
|
||||
/*
|
||||
* Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* 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.kotlin.lombok.gradle.model.builder
|
||||
|
||||
import org.gradle.api.Project
|
||||
import org.gradle.tooling.provider.model.ToolingModelBuilder
|
||||
import org.jetbrains.kotlin.gradle.model.Lombok
|
||||
import org.jetbrains.kotlin.lombok.gradle.LombokExtension
|
||||
import org.jetbrains.kotlin.lombok.gradle.model.impl.LombokImpl
|
||||
|
||||
class LombokModelBuilder : ToolingModelBuilder {
|
||||
|
||||
override fun canBuild(modelName: String): Boolean = modelName == Lombok::class.java.name
|
||||
|
||||
override fun buildAll(modelName: String, project: Project): Any? =
|
||||
if (canBuild(modelName)) {
|
||||
val extension = project.extensions.getByType(LombokExtension::class.java)
|
||||
LombokImpl(project.name, extension.configurationFile)
|
||||
} else {
|
||||
null
|
||||
}
|
||||
}
|
||||
+20
@@ -0,0 +1,20 @@
|
||||
/*
|
||||
* Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* 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.kotlin.lombok.gradle.model.impl
|
||||
|
||||
import org.jetbrains.kotlin.gradle.model.Lombok
|
||||
import java.io.File
|
||||
import java.io.Serializable
|
||||
|
||||
data class LombokImpl(override val name: String, override val configurationFile: File?) : Lombok, Serializable {
|
||||
|
||||
override val modelVersion: Long
|
||||
get() = serialVersionUID
|
||||
|
||||
companion object {
|
||||
private const val serialVersionUID = 1L
|
||||
}
|
||||
}
|
||||
@@ -37,6 +37,7 @@ dependencies {
|
||||
testRuntime(project(":kotlin-reflect"))
|
||||
testRuntime(project(":kotlinx-serialization-ide-plugin"))
|
||||
testRuntime(project(":plugins:parcelize:parcelize-ide"))
|
||||
testRuntime(project(":plugins:lombok:lombok-ide-plugin"))
|
||||
}
|
||||
|
||||
sourceSets {
|
||||
|
||||
@@ -38,6 +38,7 @@ dependencies {
|
||||
testCompileOnly(project(":kotlin-sam-with-receiver-compiler-plugin"))
|
||||
testCompileOnly(project(":noarg-ide-plugin"))
|
||||
testCompileOnly(project(":sam-with-receiver-ide-plugin"))
|
||||
testCompileOnly(project(":plugins:lombok:lombok-ide-plugin"))
|
||||
testCompileOnly(project(":idea:idea-native"))
|
||||
testCompileOnly(project(":idea:idea-gradle-native"))
|
||||
testCompileOnly(projectTests(":idea:idea-test-framework"))
|
||||
|
||||
@@ -48,6 +48,7 @@ dependencies {
|
||||
testRuntime(project(":kotlinx-serialization-ide-plugin"))
|
||||
testRuntime(project(":plugins:lint"))
|
||||
testRuntime(project(":plugins:parcelize:parcelize-ide"))
|
||||
testRuntime(project(":plugins:lombok:lombok-ide-plugin"))
|
||||
testRuntime(intellijPluginDep("junit"))
|
||||
testRuntime(intellijPluginDep("IntelliLang"))
|
||||
testRuntime(intellijPluginDep("properties"))
|
||||
|
||||
+3
-14
@@ -1,17 +1,6 @@
|
||||
/*
|
||||
* Copyright 2010-2016 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
* Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* 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.kotlin.annotation.plugin.ide
|
||||
@@ -70,4 +59,4 @@ abstract class AbstractGradleImportHandler<T : AnnotationBasedPluginModel> : Gra
|
||||
|
||||
private fun getPluginSetupBySourceSet(sourceSetNode: DataNode<GradleSourceSetData>) =
|
||||
ExternalSystemApiUtil.findParent(sourceSetNode, ProjectKeys.MODULE)?.let { getPluginSetupByModule(it) }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
|
||||
plugins {
|
||||
kotlin("jvm")
|
||||
id("jps-compatible")
|
||||
}
|
||||
|
||||
dependencies {
|
||||
compile(project(":compiler:util"))
|
||||
compile(project(":compiler:frontend"))
|
||||
compile(project(":compiler:cli-common"))
|
||||
compile(project(":idea"))
|
||||
compile(project(":idea:idea-jvm"))
|
||||
compile(project(":idea:idea-jps-common"))
|
||||
compile(project(":idea:idea-gradle"))
|
||||
compile(project(":idea:idea-maven"))
|
||||
excludeInAndroidStudio(rootProject) { compileOnly(intellijPluginDep("maven")) }
|
||||
compileOnly(intellijPluginDep("gradle"))
|
||||
compileOnly(intellijDep())
|
||||
compileOnly(project(":idea:kotlin-gradle-tooling"))
|
||||
}
|
||||
|
||||
sourceSets {
|
||||
"main" { projectDefault() }
|
||||
"test" {}
|
||||
}
|
||||
|
||||
+56
@@ -0,0 +1,56 @@
|
||||
/*
|
||||
* Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* 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.kotlin.plugin.ide
|
||||
|
||||
import com.intellij.openapi.externalSystem.model.DataNode
|
||||
import com.intellij.openapi.externalSystem.model.ProjectKeys
|
||||
import com.intellij.openapi.externalSystem.model.project.ModuleData
|
||||
import com.intellij.openapi.externalSystem.util.ExternalSystemApiUtil
|
||||
import com.intellij.openapi.util.Key
|
||||
import org.jetbrains.kotlin.idea.configuration.GradleProjectImportHandler
|
||||
import org.jetbrains.kotlin.idea.facet.KotlinFacet
|
||||
import org.jetbrains.plugins.gradle.model.data.GradleSourceSetData
|
||||
import java.io.File
|
||||
|
||||
abstract class AbstractGradleImportHandler<T> : GradleProjectImportHandler {
|
||||
|
||||
abstract val modelKey: Key<T>
|
||||
abstract val pluginJarFileFromIdea: File
|
||||
abstract val compilerPluginId: String
|
||||
abstract val pluginName: String
|
||||
|
||||
abstract fun getOptions(model: T): List<CompilerPluginSetup.PluginOption>?
|
||||
|
||||
override fun importBySourceSet(facet: KotlinFacet, sourceSetNode: DataNode<GradleSourceSetData>) {
|
||||
modifyCompilerArgumentsForPlugin(
|
||||
facet, getPluginSetupBySourceSet(sourceSetNode),
|
||||
compilerPluginId = compilerPluginId,
|
||||
pluginName = pluginName
|
||||
)
|
||||
}
|
||||
|
||||
override fun importByModule(facet: KotlinFacet, moduleNode: DataNode<ModuleData>) {
|
||||
modifyCompilerArgumentsForPlugin(
|
||||
facet, getPluginSetupByModule(moduleNode),
|
||||
compilerPluginId = compilerPluginId,
|
||||
pluginName = pluginName
|
||||
)
|
||||
}
|
||||
|
||||
private fun getPluginSetupByModule(moduleNode: DataNode<ModuleData>): CompilerPluginSetup? {
|
||||
val pluginModel = moduleNode.getCopyableUserData(modelKey) ?: return null
|
||||
|
||||
val options = getOptions(pluginModel) ?: return null
|
||||
// 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 CompilerPluginSetup(options, classpath)
|
||||
}
|
||||
|
||||
private fun getPluginSetupBySourceSet(sourceSetNode: DataNode<GradleSourceSetData>) =
|
||||
ExternalSystemApiUtil.findParent(sourceSetNode, ProjectKeys.MODULE)?.let { getPluginSetupByModule(it) }
|
||||
}
|
||||
+2
-3
@@ -3,7 +3,7 @@
|
||||
* 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.kotlin.lombok.ide
|
||||
package org.jetbrains.kotlin.plugin.ide
|
||||
|
||||
import org.jdom.Element
|
||||
import org.jdom.Text
|
||||
@@ -13,12 +13,11 @@ import org.jetbrains.kotlin.idea.maven.MavenProjectImportHandler
|
||||
import org.jetbrains.kotlin.idea.maven.KotlinMavenImporter.Companion.KOTLIN_PLUGIN_GROUP_ID
|
||||
import org.jetbrains.kotlin.idea.maven.KotlinMavenImporter.Companion.KOTLIN_PLUGIN_ARTIFACT_ID
|
||||
import java.io.File
|
||||
import org.jetbrains.kotlin.lombok.ide.CompilerPluginSetup.PluginOption
|
||||
import org.jetbrains.kotlin.plugin.ide.CompilerPluginSetup.PluginOption
|
||||
|
||||
abstract class AbstractMavenImportHandler : MavenProjectImportHandler {
|
||||
abstract val compilerPluginId: String
|
||||
abstract val pluginName: String
|
||||
// abstract val mavenPluginArtifactName: String
|
||||
abstract val pluginJarFileFromIdea: File
|
||||
|
||||
override fun invoke(facet: KotlinFacet, mavenProject: MavenProject) {
|
||||
+4
-1
@@ -3,12 +3,15 @@
|
||||
* 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.kotlin.lombok.ide
|
||||
package org.jetbrains.kotlin.plugin.ide
|
||||
|
||||
import org.jetbrains.kotlin.cli.common.arguments.CommonCompilerArguments
|
||||
import org.jetbrains.kotlin.idea.facet.KotlinFacet
|
||||
import java.io.File
|
||||
|
||||
//todo this is basically a copy-paste of the same file from annotation-based-compiler-plugins-ide-support
|
||||
//and should be merged together later
|
||||
|
||||
class CompilerPluginSetup(val options: List<PluginOption>, val classpath: List<String>) {
|
||||
class PluginOption(val key: String, val value: String)
|
||||
}
|
||||
@@ -35,6 +35,7 @@ dependencies {
|
||||
testRuntime(project(":plugins:parcelize:parcelize-ide"))
|
||||
testRuntime(project(":sam-with-receiver-ide-plugin"))
|
||||
testRuntime(project(":noarg-ide-plugin"))
|
||||
testRuntime(project(":plugins:lombok:lombok-ide-plugin"))
|
||||
testCompile(intellijDep())
|
||||
testCompile(intellijPluginDep("java"))
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@ plugins {
|
||||
|
||||
dependencies {
|
||||
implementation(project(":plugins:lombok:lombok-compiler-plugin"))
|
||||
implementation(project(":plugins:base-compiler-plugins-ide-support"))
|
||||
|
||||
compileOnly(project(":idea"))
|
||||
compileOnly(project(":idea:idea-jvm"))
|
||||
|
||||
+29
@@ -0,0 +1,29 @@
|
||||
/*
|
||||
* Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* 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.kotlin.lombok.ide
|
||||
|
||||
import com.intellij.openapi.util.Key
|
||||
import org.jetbrains.kotlin.lombok.LombokCommandLineProcessor
|
||||
import org.jetbrains.kotlin.lombok.LombokCommandLineProcessor.Companion.CONFIG_FILE_OPTION
|
||||
import org.jetbrains.kotlin.plugin.ide.AbstractGradleImportHandler
|
||||
import org.jetbrains.kotlin.plugin.ide.CompilerPluginSetup
|
||||
import org.jetbrains.kotlin.utils.PathUtil
|
||||
import java.io.File
|
||||
|
||||
class LombokGradleProjectImportHandler : AbstractGradleImportHandler<LombokModel>() {
|
||||
|
||||
override val modelKey: Key<LombokModel> = LombokGradleProjectResolverExtension.KEY
|
||||
override val pluginJarFileFromIdea: File = PathUtil.kotlinPathsForIdeaPlugin.lombokPluginJarPath
|
||||
override val compilerPluginId: String = LombokCommandLineProcessor.PLUGIN_ID
|
||||
override val pluginName: String = "lombok"
|
||||
|
||||
override fun getOptions(model: LombokModel): List<CompilerPluginSetup.PluginOption> =
|
||||
listOfNotNull(
|
||||
model.configurationFile?.let {
|
||||
CompilerPluginSetup.PluginOption(CONFIG_FILE_OPTION.optionName, it.path)
|
||||
}
|
||||
)
|
||||
}
|
||||
+41
@@ -0,0 +1,41 @@
|
||||
/*
|
||||
* Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* 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.kotlin.lombok.ide
|
||||
|
||||
import com.intellij.openapi.externalSystem.model.DataNode
|
||||
import com.intellij.openapi.externalSystem.model.project.ModuleData
|
||||
import com.intellij.openapi.util.Key
|
||||
import org.gradle.tooling.model.idea.IdeaModule
|
||||
import org.jetbrains.plugins.gradle.service.project.AbstractProjectResolverExtension
|
||||
|
||||
class LombokGradleProjectResolverExtension : AbstractProjectResolverExtension() {
|
||||
|
||||
private val modelClass: Class<LombokModel> = LombokModel::class.java
|
||||
private val userDataKey: Key<LombokModel> = KEY
|
||||
|
||||
override fun getExtraProjectModelClasses() = setOf(modelClass)
|
||||
|
||||
override fun getToolingExtensionsClasses() = setOf(
|
||||
modelClass,
|
||||
LombokGradleProjectResolverExtension::class.java,
|
||||
Unit::class.java
|
||||
)
|
||||
|
||||
override fun populateModuleExtraModels(gradleModule: IdeaModule, ideModule: DataNode<ModuleData>) {
|
||||
val model = resolverCtx.getExtraProject(gradleModule, modelClass)
|
||||
|
||||
if (model != null) {
|
||||
ideModule.putCopyableUserData(userDataKey, model)
|
||||
}
|
||||
|
||||
super.populateModuleExtraModels(gradleModule, ideModule)
|
||||
}
|
||||
|
||||
companion object {
|
||||
val KEY = Key<LombokModel>("LombokModel")
|
||||
}
|
||||
|
||||
}
|
||||
+2
-1
@@ -7,7 +7,8 @@ package org.jetbrains.kotlin.lombok.ide
|
||||
|
||||
import org.jetbrains.kotlin.lombok.LombokCommandLineProcessor
|
||||
import org.jetbrains.kotlin.lombok.LombokCommandLineProcessor.Companion.CONFIG_FILE_OPTION
|
||||
import org.jetbrains.kotlin.lombok.ide.CompilerPluginSetup.PluginOption
|
||||
import org.jetbrains.kotlin.plugin.ide.AbstractMavenImportHandler
|
||||
import org.jetbrains.kotlin.plugin.ide.CompilerPluginSetup.PluginOption
|
||||
import org.jetbrains.kotlin.utils.PathUtil
|
||||
import java.io.File
|
||||
|
||||
|
||||
@@ -50,6 +50,7 @@ dependencies {
|
||||
testRuntime(project(":plugins:kapt3-idea"))
|
||||
testRuntime(project(":kotlinx-serialization-ide-plugin"))
|
||||
testRuntime(project(":plugins:parcelize:parcelize-ide"))
|
||||
testRuntime(project(":plugins:lombok:lombok-ide-plugin"))
|
||||
testRuntime(intellijDep())
|
||||
testRuntime(intellijPluginDep("junit"))
|
||||
testRuntime(intellijPluginDep("gradle"))
|
||||
|
||||
@@ -212,6 +212,7 @@ include ":benchmarks",
|
||||
":plugins:uast-kotlin",
|
||||
":plugins:uast-kotlin-idea",
|
||||
":plugins:annotation-based-compiler-plugins-ide-support",
|
||||
":plugins:base-compiler-plugins-ide-support",
|
||||
":kotlin-script-runtime",
|
||||
":plugins:fir:fir-plugin-prototype",
|
||||
":plugins:fir:fir-plugin-prototype:plugin-annotations",
|
||||
|
||||
Reference in New Issue
Block a user