Skip to content

Commit 245637a

Browse files
Build: Add runtime dependency guard for bundled artifacts (apache#15855)
Adds a build-time check that prevents accidental transitive dependency leaks into shipped shadow JARs and distribution archives. A checked-in runtime-deps.txt baseline lists every dependency resolved into each bundled artifact. checkRuntimeDeps compares resolved deps against the baseline and fails the build with a clear diff on mismatch, wired into the check lifecycle so it runs in CI automatically. This guards all 11 bundled modules: Spark runtime (3.4, 3.5, 4.0, 4.1), Flink runtime (1.20, 2.0, 2.1), cloud bundles (AWS, Azure, GCP), and Kafka Connect runtime.
1 parent 88d5538 commit 245637a

15 files changed

Lines changed: 175 additions & 0 deletions

File tree

.github/workflows/java-ci.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,3 +126,16 @@ jobs:
126126
java-version: ${{ matrix.jvm }}
127127
- uses: gradle/actions/setup-gradle@0723195856401067f7a2779048b490ace7a47d7c # v5 # zizmor: ignore[cache-poisoning] -- cache writes are restricted to the default branch by setup-gradle
128128
- run: ./gradlew -Pquick=true javadoc
129+
130+
check-runtime-deps:
131+
runs-on: ubuntu-24.04
132+
steps:
133+
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
134+
with:
135+
persist-credentials: false
136+
- uses: actions/setup-java@be666c2fcd27ec809703dec50e508c2fdc7f6654 # v5
137+
with:
138+
distribution: zulu
139+
java-version: 17
140+
- uses: gradle/actions/setup-gradle@0723195856401067f7a2779048b490ace7a47d7c # v5 # zizmor: ignore[cache-poisoning] -- cache writes are restricted to the default branch by setup-gradle
141+
- run: ./gradlew checkAllRuntimeDeps -q

aws-bundle/build.gradle

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,4 +66,6 @@ project(":iceberg-aws-bundle") {
6666
jar {
6767
enabled = false
6868
}
69+
70+
apply from: "${rootDir}/runtime-deps.gradle"
6971
}

azure-bundle/build.gradle

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,4 +52,6 @@ project(":iceberg-azure-bundle") {
5252
jar {
5353
enabled = false
5454
}
55+
56+
apply from: "${rootDir}/runtime-deps.gradle"
5557
}

build.gradle

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,15 @@ allprojects {
120120
}
121121
}
122122

123+
tasks.register('checkAllRuntimeDeps') {
124+
description = 'Validates runtime dependency baselines for all subprojects that have them'
125+
group = 'verification'
126+
127+
dependsOn subprojects.collect { subproject ->
128+
subproject.tasks.matching { it.name == 'checkRuntimeDeps' }
129+
}
130+
}
131+
123132
subprojects {
124133
if (it.name == 'iceberg-bom') {
125134
// the BOM does not build anything, the code below expects "source code"

dev/.rat-excludes

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,3 +29,4 @@ sitemap.xml
2929
.python-version
3030
**/*_index.md
3131
**/.venv/**
32+
**/runtime-deps.txt

flink/v1.20/build.gradle

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -266,4 +266,6 @@ project(":iceberg-flink:iceberg-flink-runtime-${flinkMajorVersion}") {
266266
jar {
267267
enabled = false
268268
}
269+
270+
apply from: "${rootDir}/runtime-deps.gradle"
269271
}

flink/v2.0/build.gradle

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -266,4 +266,6 @@ project(":iceberg-flink:iceberg-flink-runtime-${flinkMajorVersion}") {
266266
jar {
267267
enabled = false
268268
}
269+
270+
apply from: "${rootDir}/runtime-deps.gradle"
269271
}

flink/v2.1/build.gradle

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -266,4 +266,6 @@ project(":iceberg-flink:iceberg-flink-runtime-${flinkMajorVersion}") {
266266
jar {
267267
enabled = false
268268
}
269+
270+
apply from: "${rootDir}/runtime-deps.gradle"
269271
}

gcp-bundle/build.gradle

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,4 +59,6 @@ project(":iceberg-gcp-bundle") {
5959
jar {
6060
enabled = false
6161
}
62+
63+
apply from: "${rootDir}/runtime-deps.gradle"
6264
}

kafka-connect/build.gradle

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,8 @@ project(':iceberg-kafka-connect:iceberg-kafka-connect-runtime') {
254254
check.dependsOn integrationTest
255255

256256
assemble.dependsOn distZip, hiveDistZip
257+
258+
apply from: "${rootDir}/runtime-deps.gradle"
257259
}
258260

259261
project(':iceberg-kafka-connect:iceberg-kafka-connect-transforms') {

0 commit comments

Comments
 (0)