Skip to content

Commit 73595d3

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 d4f02bf commit 73595d3

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

build.gradle

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -421,8 +421,22 @@ ext.additionalPomInfo = {
421421
}
422422

423423
ext.addBundledDependencies = { MavenPom pom ->
424-
bundledDeps.each {
425-
addDependency(pom, configurations[it.configName], 'provided')
424+
def seen = new HashSet<ResolvedDependency>()
425+
426+
def queue = new ArrayDeque<ResolvedDependency>()
427+
428+
// Visit each bundled dependency including its transitive dependencies if they are included, so that the exact set
429+
// of used JARs ends up in the POM as provided dependencies.
430+
for (bundledDep in bundledDeps) {
431+
queue.addAll(configurations[bundledDep.configName].resolvedConfiguration.firstLevelModuleDependencies)
432+
433+
while (!queue.isEmpty()) {
434+
def dep = queue.removeFirst()
435+
if (seen.add(dep)) {
436+
addDependency(pom, dep.moduleGroup, dep.moduleName, dep.moduleVersion, dep.moduleArtifacts[0].type, 'provided')
437+
queue.addAll(dep.children)
438+
}
439+
}
426440
}
427441
}
428442

0 commit comments

Comments
 (0)