[KAPT4] Create basic infrastructure for KAPT4
This commit is contained in:
committed by
Space Team
parent
fc57f48c8f
commit
083f54aceb
@@ -0,0 +1,59 @@
|
||||
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
|
||||
|
||||
description = "Annotation Processor for Kotlin"
|
||||
|
||||
plugins {
|
||||
kotlin("jvm")
|
||||
id("jps-compatible")
|
||||
}
|
||||
|
||||
dependencies {
|
||||
compileOnly(project(":compiler:frontend.java"))
|
||||
compileOnly(project(":compiler:plugin-api"))
|
||||
|
||||
implementation(project(":kotlin-annotation-processing-compiler"))
|
||||
embedded(project(":kotlin-annotation-processing-compiler")) { isTransitive = false }
|
||||
}
|
||||
|
||||
optInToExperimentalCompilerApi()
|
||||
|
||||
sourceSets {
|
||||
"main" { projectDefault() }
|
||||
"test" {
|
||||
projectDefault()
|
||||
generatedTestDir()
|
||||
}
|
||||
}
|
||||
|
||||
testsJar {}
|
||||
|
||||
kaptTestTask("test", JavaLanguageVersion.of(8))
|
||||
kaptTestTask("testJdk11", JavaLanguageVersion.of(11))
|
||||
kaptTestTask("testJdk17", JavaLanguageVersion.of(17))
|
||||
|
||||
fun Project.kaptTestTask(name: String, javaLanguageVersion: JavaLanguageVersion) {
|
||||
val service = extensions.getByType<JavaToolchainService>()
|
||||
|
||||
projectTest(taskName = name, parallel = true) {
|
||||
useJUnitPlatform {
|
||||
excludeTags = setOf("IgnoreJDK11")
|
||||
}
|
||||
workingDir = rootDir
|
||||
dependsOn(":dist")
|
||||
javaLauncher.set(service.launcherFor { languageVersion.set(javaLanguageVersion) })
|
||||
}
|
||||
}
|
||||
|
||||
publish()
|
||||
runtimeJar()
|
||||
sourcesJar()
|
||||
javadocJar()
|
||||
|
||||
|
||||
allprojects {
|
||||
tasks.withType(KotlinCompile::class).all {
|
||||
kotlinOptions {
|
||||
freeCompilerArgs += "-Xcontext-receivers"
|
||||
}
|
||||
}
|
||||
}
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
#
|
||||
# Copyright 2010-2023 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.
|
||||
#
|
||||
|
||||
org.jetbrains.kotlin.kapt4.Kapt4CompilerPluginRegistrar
|
||||
@@ -0,0 +1,38 @@
|
||||
/*
|
||||
* Copyright 2010-2023 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.kapt4
|
||||
|
||||
import org.jetbrains.kotlin.compiler.plugin.CompilerPluginRegistrar
|
||||
import org.jetbrains.kotlin.config.CommonConfigurationKeys
|
||||
import org.jetbrains.kotlin.config.CompilerConfiguration
|
||||
import org.jetbrains.kotlin.fir.extensions.FirAnalysisHandlerExtension
|
||||
import org.jetbrains.kotlin.kapt3.KAPT_OPTIONS
|
||||
|
||||
|
||||
class Kapt4AnalysisHandlerExtension : FirAnalysisHandlerExtension() {
|
||||
override fun isApplicable(configuration: CompilerConfiguration): Boolean =
|
||||
configuration.getBoolean(CommonConfigurationKeys.USE_FIR) && configuration[KAPT_OPTIONS] != null
|
||||
|
||||
override fun doAnalysis(configuration: CompilerConfiguration): Boolean {
|
||||
TODO("Not yet implemented")
|
||||
}
|
||||
}
|
||||
|
||||
class Kapt4CompilerPluginRegistrar : CompilerPluginRegistrar() {
|
||||
override fun ExtensionStorage.registerExtensions(configuration: CompilerConfiguration) {
|
||||
Companion.registerExtensions(this)
|
||||
}
|
||||
|
||||
override val supportsK2: Boolean
|
||||
get() = true
|
||||
|
||||
|
||||
companion object {
|
||||
fun registerExtensions(extensionStorage: ExtensionStorage) = with(extensionStorage) {
|
||||
FirAnalysisHandlerExtension.registerExtension(Kapt4AnalysisHandlerExtension())
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user