Skip to content

Commit ae2423b

Browse files
ting-yuanneetopia
authored andcommitted
Print missing deps when packing KSP2 uber jar
1 parent e7fb6d1 commit ae2423b

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

kotlin-analysis-api/build.gradle.kts

+27
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
2+
import java.io.ByteArrayOutputStream
23

34
description = "Kotlin Symbol Processing implementation using Kotlin Analysis API"
45

@@ -23,6 +24,7 @@ plugins {
2324
}
2425

2526
val depSourceJars by configurations.creating
27+
val depJarsForCheck by configurations.creating
2628

2729
dependencies {
2830
listOf(
@@ -91,6 +93,10 @@ dependencies {
9193
implementation(project(":common-util"))
9294

9395
testImplementation(kotlin("stdlib", aaKotlinBaseVersion))
96+
97+
depJarsForCheck("org.jetbrains.kotlin", "kotlin-stdlib", aaKotlinBaseVersion)
98+
depJarsForCheck(project(":api"))
99+
depJarsForCheck(project(":common-deps"))
94100
}
95101

96102
sourceSets.main {
@@ -123,6 +129,27 @@ tasks.withType<ShadowJar>() {
123129
archiveClassifier.set("")
124130
minimize()
125131
mergeServiceFiles()
132+
133+
doLast {
134+
// Checks for missing dependencies
135+
val jarJar = archiveFile.get().asFile
136+
val depJars = depJarsForCheck.resolve().map(File::getPath)
137+
val stdout = ByteArrayOutputStream()
138+
try {
139+
exec {
140+
executable = "jdeps"
141+
args = listOf(
142+
"--multi-release", "base",
143+
"--missing-deps",
144+
"-cp", depJars.joinToString(":"), jarJar.path
145+
)
146+
standardOutput = stdout
147+
}
148+
} catch (e: org.gradle.process.internal.ExecException) {
149+
logger.warn(e.message)
150+
}
151+
logger.warn(stdout.toString())
152+
}
126153
}
127154

128155
tasks {

0 commit comments

Comments
 (0)