From 78c94b65b9de0f5820d6f7fa3821309a051181d5 Mon Sep 17 00:00:00 2001 From: Yahor Berdnikau Date: Mon, 20 Mar 2023 18:02:43 +0100 Subject: [PATCH] Change sam-with-receiver plugin to use published compiler plugin - also publish 'kotlin-sam-with-receiver-compiler-plugin-embeddable' to be used with 'kotlin-compiler-embeddable' - 'kotlin-maven-sam-with-receiver' now just adds 'kotlin-sam-with-receiver-compiler-plugin' as normal dependency instead of embedding it into itself ^KT-52811 In Progress --- gradle/verification-metadata.xml | 5 ++++ .../kotlin-maven-sam-with-receiver/pom.xml | 25 ++++--------------- .../kotlin-sam-with-receiver/build.gradle.kts | 2 -- .../noarg/gradle/SamWithReceiverSubplugin.kt | 2 +- .../build.gradle.kts | 19 ++++++++++++++ settings.gradle | 2 ++ 6 files changed, 32 insertions(+), 23 deletions(-) create mode 100644 plugins/sam-with-receiver/sam-with-receiver.embeddable/build.gradle.kts diff --git a/gradle/verification-metadata.xml b/gradle/verification-metadata.xml index 3474612af91..ba4bd5378d7 100644 --- a/gradle/verification-metadata.xml +++ b/gradle/verification-metadata.xml @@ -14,6 +14,7 @@ + @@ -32,6 +33,8 @@ + + @@ -39,6 +42,8 @@ + + diff --git a/libraries/tools/kotlin-maven-sam-with-receiver/pom.xml b/libraries/tools/kotlin-maven-sam-with-receiver/pom.xml index 4f8cccb62f8..e56b9b11ea5 100755 --- a/libraries/tools/kotlin-maven-sam-with-receiver/pom.xml +++ b/libraries/tools/kotlin-maven-sam-with-receiver/pom.xml @@ -5,12 +5,6 @@ 4.0.0 - ${basedir}/../../../plugins/sam-with-receiver/sam-with-receiver.common/src - ${basedir}/../../../plugins/sam-with-receiver/sam-with-receiver.k1/src - ${basedir}/../../../plugins/sam-with-receiver/sam-with-receiver.k2/src - ${basedir}/../../../plugins/sam-with-receiver/sam-with-receiver.backend/src - ${basedir}/../../../plugins/sam-with-receiver/sam-with-receiver.cli/src - ${basedir}/../../../plugins/sam-with-receiver/sam-with-receiver.cli/resources ${basedir}/src/main/kotlin @@ -38,6 +32,11 @@ ${project.version} provided + + org.jetbrains.kotlin + kotlin-sam-with-receiver-compiler-plugin + ${project.version} + org.apache.maven maven-core @@ -47,10 +46,6 @@ - - ${sam.resources} - - org.codehaus.mojo @@ -61,11 +56,6 @@ add-source - ${sam.common.src} - ${sam.k1.src} - ${sam.k2.src} - ${sam.backend.src} - ${sam.cli.src} ${sam.maven.plugin.src} @@ -85,11 +75,6 @@ compile - - - -opt-in=org.jetbrains.kotlin.compiler.plugin.ExperimentalCompilerApi - - org.codehaus.plexus diff --git a/libraries/tools/kotlin-sam-with-receiver/build.gradle.kts b/libraries/tools/kotlin-sam-with-receiver/build.gradle.kts index fbaa543f9c2..66fb3a380cf 100644 --- a/libraries/tools/kotlin-sam-with-receiver/build.gradle.kts +++ b/libraries/tools/kotlin-sam-with-receiver/build.gradle.kts @@ -16,8 +16,6 @@ dependencies { commonCompileOnly(project(":compiler")) commonCompileOnly(project(":kotlin-sam-with-receiver-compiler-plugin")) - embedded(project(":kotlin-sam-with-receiver-compiler-plugin")) { isTransitive = false } - testImplementation(commonDependency("junit")) } diff --git a/libraries/tools/kotlin-sam-with-receiver/src/common/kotlin/org/jetbrains/kotlin/noarg/gradle/SamWithReceiverSubplugin.kt b/libraries/tools/kotlin-sam-with-receiver/src/common/kotlin/org/jetbrains/kotlin/noarg/gradle/SamWithReceiverSubplugin.kt index a2db78eba95..91e9e90370f 100644 --- a/libraries/tools/kotlin-sam-with-receiver/src/common/kotlin/org/jetbrains/kotlin/noarg/gradle/SamWithReceiverSubplugin.kt +++ b/libraries/tools/kotlin-sam-with-receiver/src/common/kotlin/org/jetbrains/kotlin/noarg/gradle/SamWithReceiverSubplugin.kt @@ -34,7 +34,7 @@ class SamWithReceiverGradleSubplugin } companion object { - const val SAM_WITH_RECEIVER_ARTIFACT_NAME = "kotlin-sam-with-receiver" + const val SAM_WITH_RECEIVER_ARTIFACT_NAME = "kotlin-sam-with-receiver-compiler-plugin-embeddable" private const val ANNOTATION_ARG_NAME = "annotation" private const val PRESET_ARG_NAME = "preset" diff --git a/plugins/sam-with-receiver/sam-with-receiver.embeddable/build.gradle.kts b/plugins/sam-with-receiver/sam-with-receiver.embeddable/build.gradle.kts new file mode 100644 index 00000000000..e4279ac95d1 --- /dev/null +++ b/plugins/sam-with-receiver/sam-with-receiver.embeddable/build.gradle.kts @@ -0,0 +1,19 @@ +plugins { + id("org.jetbrains.kotlin.jvm") +} + +dependencies { + embedded(project(":kotlin-sam-with-receiver-compiler-plugin")) { isTransitive = false } +} + +publish { + artifactId = artifactId.replace(".", "-") +} + +runtimeJar(rewriteDefaultJarDepsToShadedCompiler()) +sourcesJarWithSourcesFromEmbedded( + project(":kotlin-sam-with-receiver-compiler-plugin").tasks.named("sourcesJar") +) +javadocJarWithJavadocFromEmbedded( + project(":kotlin-sam-with-receiver-compiler-plugin").tasks.named("javadocJar") +) diff --git a/settings.gradle b/settings.gradle index d9a68bc104a..bf5ea4d12f2 100644 --- a/settings.gradle +++ b/settings.gradle @@ -141,6 +141,7 @@ include ":kotlin-noarg-compiler-plugin", ":kotlin-noarg-compiler-plugin.cli" include ":kotlin-sam-with-receiver-compiler-plugin", + ":kotlin-sam-with-receiver-compiler-plugin.embeddable", ":kotlin-sam-with-receiver-compiler-plugin.common", ":kotlin-sam-with-receiver-compiler-plugin.k1", ":kotlin-sam-with-receiver-compiler-plugin.k2", @@ -690,6 +691,7 @@ project(':kotlin-noarg-compiler-plugin.backend').projectDir = "$rootDir/plugins/ project(':kotlin-noarg-compiler-plugin.cli').projectDir = "$rootDir/plugins/noarg/noarg.cli" as File project(':kotlin-sam-with-receiver-compiler-plugin').projectDir = "$rootDir/plugins/sam-with-receiver" as File +project(':kotlin-sam-with-receiver-compiler-plugin.embeddable').projectDir = "$rootDir/plugins/sam-with-receiver/sam-with-receiver.embeddable" as File project(':kotlin-sam-with-receiver-compiler-plugin.common').projectDir = "$rootDir/plugins/sam-with-receiver/sam-with-receiver.common" as File project(':kotlin-sam-with-receiver-compiler-plugin.k1').projectDir = "$rootDir/plugins/sam-with-receiver/sam-with-receiver.k1" as File project(':kotlin-sam-with-receiver-compiler-plugin.k2').projectDir = "$rootDir/plugins/sam-with-receiver/sam-with-receiver.k2" as File