Skip to content

Commit 494f7e9

Browse files
committed
Setup depenedencies in compiler plugin's POM
To be able to do composite build, KSP depends on kotlin-compiler rather than kotlin-compiler-embeddable and uses ShadowJar to relocate some symbols. Unfortunately, ShadowJar doesn't seem able to relocate the jar only and generate proper dependencies in the POM. As a workaround, this commit hard-coded the dependencies.
1 parent be5642b commit 494f7e9

File tree

2 files changed

+23
-11
lines changed

2 files changed

+23
-11
lines changed

compiler-plugin/build.gradle.kts

+1
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ fun ModuleDependency.includeJars(vararg names: String) {
3434
}
3535
}
3636

37+
// WARNING: remember to update the dependencies in symbol-processing as well.
3738
dependencies {
3839
implementation(kotlin("stdlib", kotlinBaseVersion))
3940
implementation("org.jetbrains.kotlin:kotlin-compiler:$kotlinBaseVersion")

symbol-processing/build.gradle.kts

+22-11
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
22

3+
val kotlinBaseVersion: String by project
4+
35
plugins {
46
kotlin("jvm")
57
id("com.github.johnrengelman.shadow") version "6.0.0"
@@ -10,20 +12,11 @@ val packedJars by configurations.creating
1012

1113
dependencies {
1214
packedJars(project(":compiler-plugin")) { isTransitive = false }
13-
packedJars(project(":api")) { isTransitive = false }
1415
}
1516

1617
tasks.withType<ShadowJar>() {
1718
archiveClassifier.set("")
1819
from(packedJars)
19-
exclude(
20-
"kotlin/**",
21-
"org/intellij/**",
22-
"org/jetbrains/annotations/**",
23-
"META-INF/maven/org.jetbrains/annotations/*",
24-
"META-INF/kotlin-stdlib*"
25-
)
26-
2720
relocate("com.intellij", "org.jetbrains.kotlin.com.intellij")
2821
}
2922

@@ -34,7 +27,6 @@ tasks {
3427

3528
val sourcesJar by creating(Jar::class) {
3629
archiveClassifier.set("sources")
37-
from(project(":api").sourceSets.main.get().allSource)
3830
from(project(":compiler-plugin").sourceSets.main.get().allSource)
3931
}
4032

@@ -49,11 +41,30 @@ publishing {
4941
val publication = create<MavenPublication>("shadow") {
5042
artifactId = "symbol-processing"
5143
artifact(tasks["sourcesJar"])
44+
artifact(tasks["shadowJar"])
5245
pom {
5346
name.set("com.google.devtools.ksp:symbol-processing")
5447
description.set("Symbol processing for Kotlin")
48+
// FIXME: figure out how to make ShadowJar generate dependencies in POM,
49+
// or simply depends on kotlin-compiler-embeddable so that relocation
50+
// isn't needed, at the price of giving up composite build.
51+
withXml {
52+
fun groovy.util.Node.addDependency(groupId: String, artifactId: String, version: String, scope: String = "runtime") {
53+
appendNode("dependency").apply {
54+
appendNode("groupId", groupId)
55+
appendNode("artifactId", artifactId)
56+
appendNode("version", version)
57+
appendNode("scope", scope)
58+
}
59+
}
60+
61+
asNode().appendNode("dependencies").apply {
62+
addDependency("org.jetbrains.kotlin", "kotlin-stdlib", kotlinBaseVersion)
63+
addDependency("org.jetbrains.kotlin", "kotlin-compiler-embeddable", kotlinBaseVersion)
64+
addDependency("com.google.devtools.ksp", "symbol-processing-api", version)
65+
}
66+
}
5567
}
5668
}
57-
project.shadow.component(publication)
5869
}
5970
}

0 commit comments

Comments
 (0)