Skip to content

Commit 45e3a8d

Browse files
build: put all transitive dependencies as provided in the POM as well
Excluded dependencies will not be written into the POM. This is needed so that dependency analysis on the client side works on the correct set of dependencies. If clients manually compute transitive dependencies they do not know about our exclusions.
1 parent ff26fe5 commit 45e3a8d

File tree

1 file changed

+25
-2
lines changed

1 file changed

+25
-2
lines changed

build.gradle.kts

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -369,7 +369,30 @@ fun MavenPom.includeAdditionalInfo() {
369369
}
370370
}
371371

372-
fun MavenPom.addBundledDependencies() = bundledDependencies.forEach { addDependency(it, "provided") }
372+
fun MavenPom.addBundledDependencies() {
373+
val seen = mutableSetOf<ResolvedDependency>()
374+
val queue = ArrayDeque<ResolvedDependency>()
375+
376+
// Visit each bundled dependency, including its transitive dependencies if so configured, so that the exact set
377+
// of used JARs ends up in the POM as provided dependencies.
378+
for (config in bundledDependencies) {
379+
queue.addAll(config.resolvedConfiguration.firstLevelModuleDependencies)
380+
381+
while (!queue.isEmpty()) {
382+
val dep = queue.removeFirst()
383+
if (seen.add(dep)) {
384+
addDependency(
385+
dep.moduleGroup,
386+
dep.moduleName,
387+
dep.moduleVersion,
388+
dep.moduleArtifacts.first().type,
389+
"provided"
390+
)
391+
queue.addAll(dep.children)
392+
}
393+
}
394+
}
395+
}
373396

374397
publishing {
375398
repositories {
@@ -407,6 +430,7 @@ publishing {
407430

408431
pom.addDependency(languageLibs)
409432
pom.includeAdditionalInfo()
433+
pom.addBundledDependencies()
410434
}
411435

412436
create<MavenPublication>("tests") {
@@ -420,7 +444,6 @@ publishing {
420444
moduleVersion = project.version.toString(),
421445
type = "zip"
422446
)
423-
pom.addBundledDependencies()
424447
pom.includeAdditionalInfo()
425448
}
426449
val runtimesDir = file(artifactsDir).resolve("org.iets3.opensource/org.iets3.core.os/languages/iets3.core.os")

0 commit comments

Comments
 (0)