This is an automated email from the ASF dual-hosted git repository.
jerryshao pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/gravitino.git
The following commit(s) were added to refs/heads/main by this push:
new bd8bfc0558 [#13171] fix(build): Stop publishing shaded runtime jars'
bundled dependencies (#14997)
bd8bfc0558 is described below
commit bd8bfc055853922d86246b11d50748898427683d
Author: Yuhui <[email protected]>
AuthorDate: Wed Nov 18 19:18:15 2026 +0800
[#13171] fix(build): Stop publishing shaded runtime jars' bundled
dependencies (#14997)
### What changes were proposed in this pull request?
Move shaded jar inputs to a private `shadedDependencies` configuration
so they are no longer exposed in published POMs or Gradle metadata.
Cover all Spark/Flink runtime variants, `client-java-runtime`, and
`filesystem-hadoop3-runtime`, and add `verifyShadedRuntimePom` to
`check`.
Supersedes #13712, including support for Flink 2.2. The original author
remains the commit author.
### Why are the changes needed?
Resolving the Spark 3.5 runtime by coordinate downloads 31 artifacts (46
MB), including unshaded copies of classes already in the jar, which can
cause classpath conflicts.
Fixes #13171
### Does this PR introduce _any_ user-facing change?
Yes. The affected runtime artifacts no longer declare dependencies
already bundled in their shaded jars.
### How was this patch tested?
Verified dependency-free POMs and Gradle metadata for all eight runtime
modules, built their shaded jars, and ran their `test` tasks. Also ran
`./gradlew spotlessApply`.
---------
Co-authored-by: dennismdejong <[email protected]>
---
build.gradle.kts | 84 +++++++++++++++++++
clients/client-java-runtime/build.gradle.kts | 54 +++++++++++--
.../client/TestRuntimePublicationConsumer.java | 94 ++++++++++++++++++++++
.../filesystem-hadoop3-runtime/build.gradle.kts | 27 ++++---
.../v1.19/flink-runtime/build.gradle.kts | 15 +++-
.../v1.20/flink-runtime/build.gradle.kts | 15 +++-
.../v2.1/flink-runtime/build.gradle.kts | 19 +++--
.../v2.2/flink-runtime/build.gradle.kts | 19 +++--
.../v3.5/spark-runtime/build.gradle.kts | 17 +++-
.../v4.0/spark-runtime/build.gradle.kts | 17 +++-
10 files changed, 323 insertions(+), 38 deletions(-)
diff --git a/build.gradle.kts b/build.gradle.kts
index 7a7f2e3d68..553275c762 100644
--- a/build.gradle.kts
+++ b/build.gradle.kts
@@ -27,21 +27,27 @@ import com.github.jk1.license.filter.LicenseBundleNormalizer
import com.github.jk1.license.render.InventoryHtmlReportRenderer
import com.github.jk1.license.render.ReportRenderer
import com.github.vlsi.gradle.dsl.configureEach
+import groovy.json.JsonSlurper
import net.ltgt.gradle.errorprone.errorprone
import org.apache.tools.zip.ZipEntry
import org.apache.tools.zip.ZipOutputStream
import org.gradle.api.attributes.java.TargetJvmVersion
+import org.gradle.api.publish.maven.tasks.GenerateMavenPom
+import org.gradle.api.publish.tasks.GenerateModuleMetadata
import org.gradle.api.services.BuildService
import org.gradle.api.services.BuildServiceParameters
import org.gradle.api.tasks.testing.logging.TestExceptionFormat
import org.gradle.internal.hash.ChecksumService
import org.gradle.internal.os.OperatingSystem
import org.gradle.kotlin.dsl.support.serviceOf
+import org.w3c.dom.Element
+import org.w3c.dom.Node
import java.io.IOException
import java.nio.ByteBuffer
import java.util.Locale
import java.util.Properties
import java.util.zip.ZipFile
+import javax.xml.parsers.DocumentBuilderFactory
Locale.setDefault(Locale.US)
@@ -1003,6 +1009,84 @@ subprojects {
dependsOn(bundledLegalFiles)
transform(LegalFilesTransformer(bundledLegalFiles.get().outputArchive.get().asFile))
}
+
+ // A module that declares a `shadedDependencies` configuration packages
those inputs into its
+ // shaded jar, so they must not be republished as dependencies: consumers
resolving the
+ // coordinate would otherwise download unshaded copies of the classes the
jar already contains.
+ // See https://github.com/apache/gravitino/issues/13171
+ afterEvaluate {
+ if (configurations.findByName("shadedDependencies") == null) {
+ return@afterEvaluate
+ }
+ // The plain `jar` is an empty placeholder (classifier `empty`); the
actual content lives in
+ // the shaded jar. Point the ordinary Java variants at the shaded jar so
consumers resolving
+ // through Gradle module metadata get the implementation classes.
Otherwise `runtimeElements`
+ // selects the empty jar and, with the bundled inputs no longer
published as dependencies,
+ // consumers receive neither the classes nor the transitive dependencies.
+ listOf("apiElements", "runtimeElements").forEach { variantName ->
+ configurations.named(variantName) {
+ outgoing.artifacts.clear()
+ outgoing.artifact(tasks.named("shadowJar"))
+ }
+ }
+ val generatePom =
tasks.named<GenerateMavenPom>("generatePomFileForMavenJavaPublication")
+ val verifyShadedRuntimePom = tasks.register("verifyShadedRuntimePom") {
+ group = "verification"
+ description = "Fails when a self-contained shaded artifact republishes
bundled inputs."
+ val pom = generatePom.map { it.destination }
+ dependsOn(generatePom)
+ doLast {
+ val document =
DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(pom.get())
+ val published = document.getElementsByTagName("dependency")
+ check(published.length == 0) {
+ val coordinates =
+ (0 until published.length).joinToString { index ->
+ val element = published.item(index) as Element
+ val children = (0 until element.childNodes.length).map {
element.childNodes.item(it) }
+ fun childText(name: String) =
+ children
+ .firstOrNull { it.nodeType == Node.ELEMENT_NODE &&
it.nodeName == name }
+ ?.textContent
+ "${childText("groupId")}:${childText("artifactId")}"
+ }
+ "${project.path} publishes dependencies its jar already contains:
$coordinates"
+ }
+ }
+ }
+ val generateMetadata =
+
tasks.named<GenerateModuleMetadata>("generateMetadataFileForMavenJavaPublication")
+ val shadedJarName = tasks.named<ShadowJar>("shadowJar").flatMap {
it.archiveFileName }
+ val verifyShadedRuntimeModuleMetadata =
+ tasks.register("verifyShadedRuntimeModuleMetadata") {
+ group = "verification"
+ description =
+ "Fails when the ordinary Java variants do not expose the shaded
jar, or republish bundled dependencies."
+ dependsOn(generateMetadata)
+ val metadataFile = generateMetadata.flatMap { it.outputFile }
+ doLast {
+ @Suppress("UNCHECKED_CAST")
+ val variants =
+ (JsonSlurper().parse(metadataFile.get().asFile) as Map<String,
Any>)["variants"]
+ as List<Map<String, Any>>
+ listOf("apiElements", "runtimeElements").forEach { variantName ->
+ val variant = variants.first { it["name"] == variantName }
+
+ @Suppress("UNCHECKED_CAST")
+ val files = (variant["files"] as List<Map<String, String>>).map
{ it["name"] }
+ check(files == listOf(shadedJarName.get())) {
+ "${project.path} variant $variantName publishes $files instead
of the shaded jar ${shadedJarName.get()}"
+ }
+ check((variant["dependencies"] as? List<*>).orEmpty().isEmpty())
{
+ "${project.path} variant $variantName republishes dependencies
its jar already contains"
+ }
+ }
+ }
+ }
+ tasks.named("check") {
+ dependsOn(verifyShadedRuntimePom)
+ dependsOn(verifyShadedRuntimeModuleMetadata)
+ }
+ }
}
if (project.path == ":clients:cli") {
configureBundledLegalFiles(provider {
listOf(configurations.runtimeClasspath.get()) }, provider {
configurations.runtimeClasspath.get() })
diff --git a/clients/client-java-runtime/build.gradle.kts
b/clients/client-java-runtime/build.gradle.kts
index 7fedd73946..3e21c2fdc5 100644
--- a/clients/client-java-runtime/build.gradle.kts
+++ b/clients/client-java-runtime/build.gradle.kts
@@ -32,16 +32,26 @@ configurations.all {
}
}
+// Everything packaged into the shaded runtime jar. Declaring these as
`implementation` would make
+// Gradle publish them as `runtime` scoped POM dependencies and list them in
the Gradle module
+// metadata, so resolving the coordinate would download the modules and
third-party libraries the
+// jar already contains. See https://github.com/apache/gravitino/issues/13171
+val shadedDependencies by configurations.creating {
+ isCanBeConsumed = false
+ isCanBeResolved = true
+}
+
dependencies {
- implementation(project(":clients:client-java"))
+ shadedDependencies(project(":clients:client-java"))
testImplementation(libs.junit.jupiter.api)
+ testImplementation(gradleTestKit())
testRuntimeOnly(libs.junit.jupiter.engine)
}
tasks.withType<ShadowJar>(ShadowJar::class.java) {
isZip64 = true
- configurations = listOf(project.configurations.runtimeClasspath.get())
+ configurations = listOf(shadedDependencies)
archiveClassifier.set("")
// Exclude server-side JDBC pooling utilities. These classes reference
commons-dbcp2 which is
@@ -67,18 +77,52 @@ tasks.jar {
archiveClassifier.set("empty")
}
+// Stage the generated publication as a plain Maven-layout repository for
+// TestRuntimePublicationConsumer. This avoids publishToMavenLocal, whose
signing tasks require a
+// signatory that local and CI test runs do not have.
+val consumerArtifactName = "${rootProject.name.lowercase()}-${project.name}"
+val consumerRepo = layout.buildDirectory.dir("consumer-test-repo")
+val stageRuntimePublication by tasks.registering(Sync::class) {
+ dependsOn(
+ "shadowJar",
+ "generatePomFileForMavenJavaPublication",
+ "generateMetadataFileForMavenJavaPublication"
+ )
+ into(
+ consumerRepo.map {
+ it.dir("${project.group.toString().replace('.',
'/')}/$consumerArtifactName/${project.version}")
+ }
+ )
+ from(layout.buildDirectory.file("publications/MavenJava/pom-default.xml")) {
+ rename { "$consumerArtifactName-${project.version}.pom" }
+ }
+ from(layout.buildDirectory.file("publications/MavenJava/module.json")) {
+ rename { "$consumerArtifactName-${project.version}.module" }
+ }
+ from(tasks.named<ShadowJar>("shadowJar").flatMap { it.archiveFile })
+}
+
tasks.test {
useJUnitPlatform()
val runtimeJar = tasks.named<ShadowJar>("shadowJar")
dependsOn(runtimeJar)
+ // TestRuntimePublicationConsumer resolves the staged coordinate from
consumerRepo.
+ dependsOn(stageRuntimePublication)
+ inputs.dir(consumerRepo)
inputs.file(runtimeJar.flatMap { it.archiveFile })
inputs.dir(rootProject.file("dev/release/maven"))
- inputs.files(configurations.runtimeClasspath)
+ inputs.files(shadedDependencies)
+ systemProperty(
+ "runtimeCoordinate",
+ "${project.group}:$consumerArtifactName:${project.version}"
+ )
+ systemProperty("expectedRuntimeJar", runtimeJar.get().archiveFileName.get())
+ systemProperty("consumerRepo", consumerRepo.get().asFile.absolutePath)
doFirst {
systemProperty("artifactPath",
runtimeJar.get().archiveFile.get().asFile.absolutePath)
systemProperty("legalTemplates",
rootProject.file("dev/release/maven").absolutePath)
- systemProperty("dependencyJars",
configurations.runtimeClasspath.get().asPath)
-
configurations.runtimeClasspath.get().resolvedConfiguration.resolvedArtifacts.forEach
{ artifact ->
+ systemProperty("dependencyJars", shadedDependencies.asPath)
+ shadedDependencies.resolvedConfiguration.resolvedArtifacts.forEach {
artifact ->
val id = artifact.moduleVersion.id
val classifier = artifact.classifier?.let { "/$it" } ?: ""
systemProperty("dependencyPrefix.${artifact.file.name}",
"META-INF/licenses/${id.group}/${id.name}/${id.version}$classifier/")
diff --git
a/clients/client-java-runtime/src/test/java/org/apache/gravitino/client/TestRuntimePublicationConsumer.java
b/clients/client-java-runtime/src/test/java/org/apache/gravitino/client/TestRuntimePublicationConsumer.java
new file mode 100644
index 0000000000..3075ea3be7
--- /dev/null
+++
b/clients/client-java-runtime/src/test/java/org/apache/gravitino/client/TestRuntimePublicationConsumer.java
@@ -0,0 +1,94 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.gravitino.client;
+
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+import java.io.IOException;
+import java.nio.charset.StandardCharsets;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import org.gradle.testkit.runner.BuildResult;
+import org.gradle.testkit.runner.GradleRunner;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.io.TempDir;
+
+/**
+ * Verifies the published runtime artifact from an ordinary Gradle consumer's
perspective: the
+ * standard Java variants must expose the shaded jar without republishing the
dependencies bundled
+ * into it. See https://github.com/apache/gravitino/issues/13171
+ */
+class TestRuntimePublicationConsumer {
+ @TempDir Path consumerProject;
+
+ @Test
+ void testGradleConsumerResolvesShadedJarWithoutBundledDependencies() throws
IOException {
+ String coordinate = System.getProperty("runtimeCoordinate");
+ String expectedJar = System.getProperty("expectedRuntimeJar");
+ String repo = System.getProperty("consumerRepo");
+ write("settings.gradle", "rootProject.name = 'runtime-consumer'\n");
+ write(
+ "build.gradle",
+ """
+ plugins { id 'java' }
+ repositories { maven { url = findProperty('repoUrl') } }
+ dependencies { implementation '%s' }
+ tasks.register('verifyConsumer', JavaExec) {
+ dependsOn compileJava
+ classpath = sourceSets.main.runtimeClasspath
+ mainClass = 'Consumer'
+ doFirst {
+ def artifacts = configurations.runtimeClasspath.files
+ println "RUNTIME ARTIFACTS: " + artifacts.collect { it.name }
+ assert artifacts.size() == 1 : "Expected only the shaded jar, got:
" + artifacts
+ assert artifacts[0].name == '%s' : "Expected the shaded jar, got:
" + artifacts[0]
+ }
+ }
+ """
+ .formatted(coordinate, expectedJar));
+ write(
+ "src/main/java/Consumer.java",
+ """
+ import org.apache.gravitino.client.GravitinoClient;
+
+ public class Consumer {
+ public static void main(String[] args) throws Exception {
+ // Compile-time reference: fails compilation if apiElements lacks
the class.
+ Class<GravitinoClient> type = GravitinoClient.class;
+ Class<?> loaded = Class.forName(type.getName());
+ System.out.println("LOADED: " + loaded.getName());
+ }
+ }
+ """);
+
+ BuildResult result =
+ GradleRunner.create()
+ .withProjectDir(consumerProject.toFile())
+ .withArguments("verifyConsumer", "-PrepoUrl=" + repo,
"--stacktrace")
+ .build();
+ assertTrue(
+ result.getOutput().contains("LOADED:
org.apache.gravitino.client.GravitinoClient"),
+ result.getOutput());
+ }
+
+ private void write(String relativePath, String content) throws IOException {
+ Path file = consumerProject.resolve(relativePath);
+ Files.createDirectories(file.getParent());
+ Files.writeString(file, content, StandardCharsets.UTF_8);
+ }
+}
diff --git a/clients/filesystem-hadoop3-runtime/build.gradle.kts
b/clients/filesystem-hadoop3-runtime/build.gradle.kts
index fb252ac43d..b43120d987 100644
--- a/clients/filesystem-hadoop3-runtime/build.gradle.kts
+++ b/clients/filesystem-hadoop3-runtime/build.gradle.kts
@@ -25,22 +25,31 @@ plugins {
alias(libs.plugins.shadow)
}
+// Everything packaged into the shaded runtime jar. Declaring these as
`implementation` would make
+// Gradle publish them as `runtime` scoped POM dependencies and list them in
the Gradle module
+// metadata, so resolving the coordinate would download the modules and
third-party libraries the
+// jar already contains. See https://github.com/apache/gravitino/issues/13171
+val shadedDependencies by configurations.creating {
+ isCanBeConsumed = false
+ isCanBeResolved = true
+}
+
dependencies {
- implementation(project(":bundles:aliyun"))
- implementation(project(":bundles:aws"))
- implementation(project(":bundles:azure"))
- implementation(project(":bundles:gcp"))
- implementation(project(":bundles:tencent"))
- implementation(project(":clients:filesystem-hadoop3")) {
+ shadedDependencies(project(":bundles:aliyun"))
+ shadedDependencies(project(":bundles:aws"))
+ shadedDependencies(project(":bundles:azure"))
+ shadedDependencies(project(":bundles:gcp"))
+ shadedDependencies(project(":bundles:tencent"))
+ shadedDependencies(project(":clients:filesystem-hadoop3")) {
exclude(group = "org.slf4j")
}
- implementation(project(":clients:client-java-runtime", configuration =
"shadow"))
- implementation(libs.commons.lang3)
+ shadedDependencies(project(":clients:client-java-runtime", configuration =
"shadow"))
+ shadedDependencies(libs.commons.lang3)
}
tasks.withType<ShadowJar>(ShadowJar::class.java) {
isZip64 = true
- configurations = listOf(project.configurations.runtimeClasspath.get())
+ configurations = listOf(shadedDependencies)
archiveClassifier.set("")
// Strip shaded slf4j-api brought in by :clients:client-java-runtime —
Hadoop classpaths
diff --git a/flink-connector/v1.19/flink-runtime/build.gradle.kts
b/flink-connector/v1.19/flink-runtime/build.gradle.kts
index f9792df561..b4114d364d 100644
--- a/flink-connector/v1.19/flink-runtime/build.gradle.kts
+++ b/flink-connector/v1.19/flink-runtime/build.gradle.kts
@@ -43,9 +43,18 @@ configurations.all {
}
}
+// Everything packaged into the shaded runtime jar. Declaring these as
`implementation` would make
+// Gradle publish them as `runtime` scoped POM dependencies and list them in
the Gradle module
+// metadata, so resolving the connector coordinate would download the modules
and third-party
+// libraries the jar already contains. See
https://github.com/apache/gravitino/issues/13171
+val shadedDependencies by configurations.creating {
+ isCanBeConsumed = false
+ isCanBeResolved = true
+}
+
dependencies {
- implementation(project(":clients:client-java-runtime", configuration =
"shadow"))
- implementation(project(":flink-connector:flink-1.19"))
+ shadedDependencies(project(":clients:client-java-runtime", configuration =
"shadow"))
+ shadedDependencies(project(":flink-connector:flink-1.19"))
testImplementation(libs.junit.jupiter.api)
testRuntimeOnly(libs.junit.jupiter.engine)
@@ -55,7 +64,7 @@ val shadowJarTask = tasks.named<ShadowJar>("shadowJar")
shadowJarTask.configure {
isZip64 = true
- configurations = listOf(project.configurations.runtimeClasspath.get())
+ configurations = listOf(shadedDependencies)
archiveFileName.set("$baseName-$version.jar")
archiveClassifier.set("")
mergeServiceFiles()
diff --git a/flink-connector/v1.20/flink-runtime/build.gradle.kts
b/flink-connector/v1.20/flink-runtime/build.gradle.kts
index da3dd17670..db9cc9d249 100644
--- a/flink-connector/v1.20/flink-runtime/build.gradle.kts
+++ b/flink-connector/v1.20/flink-runtime/build.gradle.kts
@@ -43,9 +43,18 @@ configurations.all {
}
}
+// Everything packaged into the shaded runtime jar. Declaring these as
`implementation` would make
+// Gradle publish them as `runtime` scoped POM dependencies and list them in
the Gradle module
+// metadata, so resolving the connector coordinate would download the modules
and third-party
+// libraries the jar already contains. See
https://github.com/apache/gravitino/issues/13171
+val shadedDependencies by configurations.creating {
+ isCanBeConsumed = false
+ isCanBeResolved = true
+}
+
dependencies {
- implementation(project(":clients:client-java-runtime", configuration =
"shadow"))
- implementation(project(":flink-connector:flink-1.20"))
+ shadedDependencies(project(":clients:client-java-runtime", configuration =
"shadow"))
+ shadedDependencies(project(":flink-connector:flink-1.20"))
testImplementation(libs.junit.jupiter.api)
testRuntimeOnly(libs.junit.jupiter.engine)
@@ -55,7 +64,7 @@ val shadowJarTask = tasks.named<ShadowJar>("shadowJar")
shadowJarTask.configure {
isZip64 = true
- configurations = listOf(project.configurations.runtimeClasspath.get())
+ configurations = listOf(shadedDependencies)
archiveFileName.set("$baseName-$version.jar")
archiveClassifier.set("")
mergeServiceFiles()
diff --git a/flink-connector/v2.1/flink-runtime/build.gradle.kts
b/flink-connector/v2.1/flink-runtime/build.gradle.kts
index 84d56553b5..4a10741e8b 100644
--- a/flink-connector/v2.1/flink-runtime/build.gradle.kts
+++ b/flink-connector/v2.1/flink-runtime/build.gradle.kts
@@ -43,14 +43,23 @@ configurations.all {
}
}
+// Everything packaged into the shaded runtime jar. Declaring these as
`implementation` would make
+// Gradle publish them as `runtime` scoped POM dependencies and list them in
the Gradle module
+// metadata, so resolving the connector coordinate would download the modules
and third-party
+// libraries the jar already contains. See
https://github.com/apache/gravitino/issues/13171
+val shadedDependencies by configurations.creating {
+ isCanBeConsumed = false
+ isCanBeResolved = true
+}
+
dependencies {
- implementation(project(":clients:client-java-runtime", configuration =
"shadow"))
- implementation(project(":flink-connector:flink-2.1"))
+ shadedDependencies(project(":clients:client-java-runtime", configuration =
"shadow"))
+ shadedDependencies(project(":flink-connector:flink-2.1"))
// flink-2.1's own openlineageSqlJava constraint only applies to that
module's compileOnly and
- // testImplementation configurations, so it never reaches this module's
runtimeClasspath (which
+ // testImplementation configurations, so it never reaches this module's
shaded dependencies (which
// shadowJar packages). Depend on it directly here so the shaded runtime jar
ships the patched
// 1.52.0 release instead of the vulnerable 1.32.0 pulled transitively by
flink-connector-jdbc.
- implementation(libs.openlineageSqlJava)
+ shadedDependencies(libs.openlineageSqlJava)
testImplementation(libs.junit.jupiter.api)
testRuntimeOnly(libs.junit.jupiter.engine)
@@ -60,7 +69,7 @@ val shadowJarTask = tasks.named<ShadowJar>("shadowJar")
shadowJarTask.configure {
isZip64 = true
- configurations = listOf(project.configurations.runtimeClasspath.get())
+ configurations = listOf(shadedDependencies)
archiveFileName.set("$baseName-$version.jar")
archiveClassifier.set("")
mergeServiceFiles()
diff --git a/flink-connector/v2.2/flink-runtime/build.gradle.kts
b/flink-connector/v2.2/flink-runtime/build.gradle.kts
index e3b307d8c4..eaeeeb2fc4 100644
--- a/flink-connector/v2.2/flink-runtime/build.gradle.kts
+++ b/flink-connector/v2.2/flink-runtime/build.gradle.kts
@@ -43,14 +43,23 @@ configurations.all {
}
}
+// Everything packaged into the shaded runtime jar. Declaring these as
`implementation` would make
+// Gradle publish them as `runtime` scoped POM dependencies and list them in
the Gradle module
+// metadata, so resolving the connector coordinate would download the modules
and third-party
+// libraries the jar already contains. See
https://github.com/apache/gravitino/issues/13171
+val shadedDependencies by configurations.creating {
+ isCanBeConsumed = false
+ isCanBeResolved = true
+}
+
dependencies {
- implementation(project(":clients:client-java-runtime", configuration =
"shadow"))
- implementation(project(":flink-connector:flink-2.2"))
+ shadedDependencies(project(":clients:client-java-runtime", configuration =
"shadow"))
+ shadedDependencies(project(":flink-connector:flink-2.2"))
// flink-2.2's own openlineageSqlJava constraint only applies to that
module's compileOnly and
- // testImplementation configurations, so it never reaches this module's
runtimeClasspath (which
+ // testImplementation configurations, so it never reaches this module's
shaded dependencies (which
// shadowJar packages). Depend on it directly here so the shaded runtime jar
ships the patched
// 1.52.0 release instead of the vulnerable 1.32.0 pulled transitively by
flink-connector-jdbc.
- implementation(libs.openlineageSqlJava)
+ shadedDependencies(libs.openlineageSqlJava)
testImplementation(libs.junit.jupiter.api)
testRuntimeOnly(libs.junit.jupiter.engine)
@@ -60,7 +69,7 @@ val shadowJarTask = tasks.named<ShadowJar>("shadowJar")
shadowJarTask.configure {
isZip64 = true
- configurations = listOf(project.configurations.runtimeClasspath.get())
+ configurations = listOf(shadedDependencies)
archiveFileName.set("$baseName-$version.jar")
archiveClassifier.set("")
mergeServiceFiles()
diff --git a/spark-connector/v3.5/spark-runtime/build.gradle.kts
b/spark-connector/v3.5/spark-runtime/build.gradle.kts
index 4c5a05925e..52b25aa29e 100644
--- a/spark-connector/v3.5/spark-runtime/build.gradle.kts
+++ b/spark-connector/v3.5/spark-runtime/build.gradle.kts
@@ -29,13 +29,22 @@ val sparkVersion: String = libs.versions.spark35.get()
val sparkMajorVersion: String = sparkVersion.substringBeforeLast(".")
val baseName =
"${rootProject.name}-spark-connector-runtime-${sparkMajorVersion}_$scalaVersion"
+// Everything packaged into the shaded runtime jar. Declaring these as
`implementation` would make
+// Gradle publish them as `runtime` scoped POM dependencies and list them in
the Gradle module
+// metadata, so resolving the connector coordinate would download the modules
and third-party
+// libraries the jar already contains. See
https://github.com/apache/gravitino/issues/13171
+val shadedDependencies by configurations.creating {
+ isCanBeConsumed = false
+ isCanBeResolved = true
+}
+
dependencies {
- implementation(project(":clients:client-java-runtime", configuration =
"shadow"))
+ shadedDependencies(project(":clients:client-java-runtime", configuration =
"shadow"))
when (sparkMajorVersion) {
"3.5" -> {
val kyuubiVersion: String = libs.versions.kyuubi4spark.get()
- implementation(project(":spark-connector:spark-3.5"))
-
implementation("org.apache.kyuubi:kyuubi-spark-connector-hive_$scalaVersion:$kyuubiVersion")
+ shadedDependencies(project(":spark-connector:spark-3.5"))
+
shadedDependencies("org.apache.kyuubi:kyuubi-spark-connector-hive_$scalaVersion:$kyuubiVersion")
}
else -> throw IllegalArgumentException("Unsupported Spark version:
$sparkMajorVersion")
}
@@ -43,7 +52,7 @@ dependencies {
tasks.withType<ShadowJar>(ShadowJar::class.java) {
isZip64 = true
- configurations = listOf(project.configurations.runtimeClasspath.get())
+ configurations = listOf(shadedDependencies)
archiveFileName.set("$baseName-$version.jar")
archiveClassifier.set("")
diff --git a/spark-connector/v4.0/spark-runtime/build.gradle.kts
b/spark-connector/v4.0/spark-runtime/build.gradle.kts
index 74fa1e8ae1..b61764abae 100644
--- a/spark-connector/v4.0/spark-runtime/build.gradle.kts
+++ b/spark-connector/v4.0/spark-runtime/build.gradle.kts
@@ -31,15 +31,24 @@ val sparkMajorVersion: String =
sparkVersion.substringBeforeLast(".")
val kyuubiVersion: String = libs.versions.kyuubi4spark.get()
val baseName =
"${rootProject.name}-spark-connector-runtime-${sparkMajorVersion}_$scalaVersion"
+// Everything packaged into the shaded runtime jar. Declaring these as
`implementation` would make
+// Gradle publish them as `runtime` scoped POM dependencies and list them in
the Gradle module
+// metadata, so resolving the connector coordinate would download the modules
and third-party
+// libraries the jar already contains. See
https://github.com/apache/gravitino/issues/13171
+val shadedDependencies by configurations.creating {
+ isCanBeConsumed = false
+ isCanBeResolved = true
+}
+
dependencies {
- implementation(project(":clients:client-java-runtime", configuration =
"shadow"))
- implementation(project(":spark-connector:spark-4.0"))
-
implementation("org.apache.kyuubi:kyuubi-spark-connector-hive_$scalaVersion:$kyuubiVersion")
+ shadedDependencies(project(":clients:client-java-runtime", configuration =
"shadow"))
+ shadedDependencies(project(":spark-connector:spark-4.0"))
+
shadedDependencies("org.apache.kyuubi:kyuubi-spark-connector-hive_$scalaVersion:$kyuubiVersion")
}
tasks.withType<ShadowJar>(ShadowJar::class.java) {
isZip64 = true
- configurations = listOf(project.configurations.runtimeClasspath.get())
+ configurations = listOf(shadedDependencies)
archiveFileName.set("$baseName-$version.jar")
archiveClassifier.set("")