[lombok] Gradle sublugin for no-kapt project
This commit is contained in:
committed by
TeamCityServer
parent
8011452c28
commit
79d49e6dbd
+2
-1
@@ -368,7 +368,8 @@ val gradlePluginProjects = listOf(
|
|||||||
":kotlin-annotation-processing-gradle",
|
":kotlin-annotation-processing-gradle",
|
||||||
":kotlin-noarg",
|
":kotlin-noarg",
|
||||||
":kotlin-sam-with-receiver",
|
":kotlin-sam-with-receiver",
|
||||||
":kotlin-parcelize-compiler"
|
":kotlin-parcelize-compiler",
|
||||||
|
":kotlin-lombok"
|
||||||
)
|
)
|
||||||
|
|
||||||
apply {
|
apply {
|
||||||
|
|||||||
@@ -1,5 +1,11 @@
|
|||||||
|
def pluginProjects = [
|
||||||
configure([project(':kotlin-gradle-plugin'), project(':kotlin-allopen'), project(':kotlin-noarg'), project(':kotlin-serialization')]) { project ->
|
project(':kotlin-gradle-plugin'),
|
||||||
|
project(':kotlin-allopen'),
|
||||||
|
project(':kotlin-noarg'),
|
||||||
|
project(':kotlin-serialization'),
|
||||||
|
project(':kotlin-lombok')
|
||||||
|
]
|
||||||
|
configure(pluginProjects) { project ->
|
||||||
apply plugin: 'com.gradle.plugin-publish'
|
apply plugin: 'com.gradle.plugin-publish'
|
||||||
|
|
||||||
afterEvaluate {
|
afterEvaluate {
|
||||||
|
|||||||
@@ -0,0 +1,60 @@
|
|||||||
|
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
|
||||||
|
import plugins.configureDefaultPublishing
|
||||||
|
|
||||||
|
description = "Kotlin lombok compiler plugin"
|
||||||
|
|
||||||
|
plugins {
|
||||||
|
kotlin("jvm")
|
||||||
|
id("jps-compatible")
|
||||||
|
}
|
||||||
|
|
||||||
|
dependencies {
|
||||||
|
embedded(project(":plugins:lombok:lombok-compiler-plugin")) { isTransitive = false }
|
||||||
|
|
||||||
|
compileOnly(gradleApi())
|
||||||
|
api(project(":kotlin-gradle-plugin-api"))
|
||||||
|
api(project(":kotlin-gradle-plugin-model"))
|
||||||
|
}
|
||||||
|
|
||||||
|
projectTest(parallel = true) {
|
||||||
|
workingDir = projectDir
|
||||||
|
}
|
||||||
|
|
||||||
|
publish()
|
||||||
|
|
||||||
|
sourcesJar()
|
||||||
|
javadocJar()
|
||||||
|
runtimeJar(rewriteDefaultJarDepsToShadedCompiler())
|
||||||
|
|
||||||
|
tasks {
|
||||||
|
withType<KotlinCompile> {
|
||||||
|
// kotlinOptions.jdkHome = rootProject.extra["JDK_18"] as String
|
||||||
|
kotlinOptions.languageVersion = "1.3"
|
||||||
|
kotlinOptions.apiVersion = "1.3"
|
||||||
|
kotlinOptions.freeCompilerArgs += listOf(
|
||||||
|
"-Xskip-prerelease-check", "-Xsuppress-version-warnings"
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
named<Jar>("jar") {
|
||||||
|
callGroovy("manifestAttributes", manifest, project)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pluginBundle {
|
||||||
|
fun create(name: String, id: String, display: String) {
|
||||||
|
(plugins).create(name) {
|
||||||
|
this.id = id
|
||||||
|
this.displayName = display
|
||||||
|
this.description = display
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
create(
|
||||||
|
name = "kotlinLombokPlugin",
|
||||||
|
id = "org.jetbrains.kotlin.plugin.lombok",
|
||||||
|
display = "Kotlin Lombok plugin"
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
publishPluginMarkers()
|
||||||
+18
@@ -0,0 +1,18 @@
|
|||||||
|
/*
|
||||||
|
* 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
|
||||||
|
|
||||||
|
import java.io.File
|
||||||
|
|
||||||
|
open class LombokExtension {
|
||||||
|
|
||||||
|
internal var configurationFile: File? = null
|
||||||
|
|
||||||
|
open fun lombokConfigurationFile(file: File) {
|
||||||
|
configurationFile = file
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
+45
@@ -0,0 +1,45 @@
|
|||||||
|
/*
|
||||||
|
* 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
|
||||||
|
|
||||||
|
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 javax.inject.Inject
|
||||||
|
|
||||||
|
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(AllOpenModelBuilder())
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun applyToCompilation(kotlinCompilation: KotlinCompilation<*>): Provider<List<SubpluginOption>> {
|
||||||
|
val project = kotlinCompilation.target.project
|
||||||
|
|
||||||
|
return project.provider {
|
||||||
|
val extension = project.extensions.getByType(LombokExtension::class.java)
|
||||||
|
val options = mutableListOf<SubpluginOption>()
|
||||||
|
|
||||||
|
extension.configurationFile?.let { configFile ->
|
||||||
|
options += SubpluginOption("config", configFile.absolutePath)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
options
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun getCompilerPluginId(): String = "org.jetbrains.kotlin.lombok"
|
||||||
|
|
||||||
|
override fun getPluginArtifact(): SubpluginArtifact = JetBrainsSubpluginArtifact(artifactId = "kotlin-lombok")
|
||||||
|
}
|
||||||
+1
@@ -0,0 +1 @@
|
|||||||
|
implementation-class=org.jetbrains.kotlin.lombok.gradle.LombokSubplugin
|
||||||
+1
@@ -0,0 +1 @@
|
|||||||
|
implementation-class=org.jetbrains.kotlin.lombok.gradle.LombokSubplugin
|
||||||
@@ -33,10 +33,10 @@ projectTest(parallel = true) {
|
|||||||
dependsOn(":dist")
|
dependsOn(":dist")
|
||||||
}
|
}
|
||||||
|
|
||||||
publish()
|
|
||||||
|
|
||||||
runtimeJar()
|
runtimeJar()
|
||||||
testsJar()
|
testsJar()
|
||||||
|
|
||||||
sourcesJar()
|
sourcesJar()
|
||||||
javadocJar()
|
javadocJar()
|
||||||
|
|
||||||
|
apply(from = "$rootDir/gradle/kotlinPluginPublication.gradle.kts")
|
||||||
|
|||||||
+3
-1
@@ -346,7 +346,8 @@ include ":plugins:parcelize:parcelize-compiler",
|
|||||||
":plugins:parcelize:parcelize-runtime",
|
":plugins:parcelize:parcelize-runtime",
|
||||||
":kotlin-parcelize-compiler"
|
":kotlin-parcelize-compiler"
|
||||||
|
|
||||||
include ":plugins:lombok:lombok-compiler-plugin"
|
include ":plugins:lombok:lombok-compiler-plugin",
|
||||||
|
":kotlin-lombok"
|
||||||
|
|
||||||
include ":prepare:ide-plugin-dependencies:android-extensions-compiler-plugin-for-ide",
|
include ":prepare:ide-plugin-dependencies:android-extensions-compiler-plugin-for-ide",
|
||||||
":prepare:ide-plugin-dependencies:allopen-compiler-plugin-for-ide",
|
":prepare:ide-plugin-dependencies:allopen-compiler-plugin-for-ide",
|
||||||
@@ -527,6 +528,7 @@ project(':kotlin-tooling-metadata').projectDir = "$rootDir/libraries/tools/kotli
|
|||||||
project(':kotlin-allopen').projectDir = "$rootDir/libraries/tools/kotlin-allopen" as File
|
project(':kotlin-allopen').projectDir = "$rootDir/libraries/tools/kotlin-allopen" as File
|
||||||
project(':kotlin-noarg').projectDir = "$rootDir/libraries/tools/kotlin-noarg" as File
|
project(':kotlin-noarg').projectDir = "$rootDir/libraries/tools/kotlin-noarg" as File
|
||||||
project(':kotlin-sam-with-receiver').projectDir = "$rootDir/libraries/tools/kotlin-sam-with-receiver" as File
|
project(':kotlin-sam-with-receiver').projectDir = "$rootDir/libraries/tools/kotlin-sam-with-receiver" as File
|
||||||
|
project(':kotlin-lombok').projectDir = "$rootDir/libraries/tools/kotlin-lombok" as File
|
||||||
project(':kotlin-gradle-subplugin-example').projectDir = "$rootDir/libraries/examples/kotlin-gradle-subplugin-example" as File
|
project(':kotlin-gradle-subplugin-example').projectDir = "$rootDir/libraries/examples/kotlin-gradle-subplugin-example" as File
|
||||||
project(':examples:annotation-processor-example').projectDir = "$rootDir/libraries/examples/annotation-processor-example" as File
|
project(':examples:annotation-processor-example').projectDir = "$rootDir/libraries/examples/annotation-processor-example" as File
|
||||||
project(':kotlin-script-util').projectDir = "$rootDir/libraries/tools/kotlin-script-util" as File
|
project(':kotlin-script-util').projectDir = "$rootDir/libraries/tools/kotlin-script-util" as File
|
||||||
|
|||||||
Reference in New Issue
Block a user