[lombok] Add simple way to use lombok plugin in one project with kapt

This commit is contained in:
Andrey Zinovyev
2021-03-29 19:38:46 +03:00
committed by TeamCityServer
parent 79d49e6dbd
commit 99f9b79c87
5 changed files with 12 additions and 13 deletions
@@ -700,7 +700,9 @@ class Kapt3GradleSubplugin @Inject internal constructor(private val registry: To
val newCompilerArgs = oldCompilerArgs.filterTo(mutableListOf()) {
it !is CharSequence || !it.toString().startsWith("-proc:")
}
newCompilerArgs.add("-proc:none")
if (!kaptExtension.keepJavacAnnotationProcessors) {
newCompilerArgs.add("-proc:none")
}
@Suppress("UNCHECKED_CAST")
options.compilerArgs = newCompilerArgs as List<String>
@@ -46,6 +46,11 @@ open class KaptExtension {
@Deprecated("Use `annotationProcessor()` and `annotationProcessors()` instead")
open var processors: String = ""
/**
* If true keeps annotation processors added via `annotationProcessor(..)` configuration for javac java-files compilation
*/
open var keepJavacAnnotationProcessors: Boolean = false
/** Opt-out switch for Kapt caching. Should be used when annotation processors used by this project are suspected of
* using anything aside from the task inputs in their logic and are not guaranteed to produce the same
* output on subsequent runs without input changes. */
@@ -146,4 +151,4 @@ private fun Any?.executeClosure(closure: Closure<*>) {
closure.resolveStrategy = Closure.DELEGATE_FIRST
closure.delegate = this
closure.call()
}
}
@@ -1,5 +1,4 @@
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
import plugins.configureDefaultPublishing
description = "Kotlin lombok compiler plugin"
@@ -7,19 +7,15 @@ 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 {
class LombokSubplugin : 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>> {
@@ -32,9 +28,6 @@ class LombokSubplugin @Inject internal constructor(private val registry: Tooling
extension.configurationFile?.let { configFile ->
options += SubpluginOption("config", configFile.absolutePath)
}
options
}
}
@@ -13,7 +13,7 @@ Features support:
- [x] Basic support
- [x] Class-level
- [x] @Accessors config support: chain and fluent
- [ ] Config support (_lombok.getter.noIsPrefix_ only supported)
- [ ] Config support (_lombok.getter.noIsPrefix_ only supported atm)
- [ ] Copy annotations
- [ ] Strip defined prefixes - in config and @Accessors
- [ ] Skip generation with AccessLevel.NONE
@@ -40,7 +40,7 @@ Other todos:
- [x] Generic classes
- [x] Actually run compiled code
- [x] Don't generate members that already exist (if having a duplicate is a problem)
- [ ] Gradle integration (as subplugin or just a way to enable lombok support)
- [x] Gradle integration (as subplugin or just a way to enable lombok support)
- [ ] Maven integration (as subplugin or just a way to enable lombok support)
- [ ] Nullability from annotations. Check if it is inherited from variable definition