[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
+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
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user