This is an automated email from the ASF dual-hosted git repository.
alexey pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/kudu.git
The following commit(s) were added to refs/heads/master by this push:
new 9befb1188 [java][build] KUDU-3610: kudu-client.jar dependencies
9befb1188 is described below
commit 9befb1188ec2c8f75bf81f9cd5b17fec2db8c19b
Author: zchovan <[email protected]>
AuthorDate: Wed Aug 28 10:52:14 2024 +0200
[java][build] KUDU-3610: kudu-client.jar dependencies
As reported in KUDU-3610 Impala build fails with the newly generated
kudu-client.jar pom.xml.
The issue is in the pom generation itself [1], that is being done by
the 'maven-publish' plugin (which is necessary for gradle 7+ due to
the old publish plugin being deprecated).
This means that the content of the jars are correct, however the
generated pom.xml lists some dependencies in incorrect (maven) scopes.
The fix this change proposes is by editing the generated pom xml
structure, so that the shaded dependencies are removed from the
generated pom. This was previously done by the shadow plugin, however
due to API changes this is no longer possible and has to be done in
maven-publish plugin.
Additional manual testing (building Impala) was carried out that
confirmed that the pom is now correct.
[1]
https://discuss.gradle.org/t/maven-publish-plugin-generated-pom-making-dependency-scope-runtime/7494
Change-Id: I607d7c62c585b2aa1bee4ebf7907309e130092da
Reviewed-on: http://gerrit.cloudera.org:8080/21731
Reviewed-by: Alexey Serbin <[email protected]>
Tested-by: Alexey Serbin <[email protected]>
---
java/gradle/publishing.gradle | 15 +++++++++++++
java/gradle/shadow.gradle | 50 -------------------------------------------
java/kudu-client/build.gradle | 6 +++++-
3 files changed, 20 insertions(+), 51 deletions(-)
diff --git a/java/gradle/publishing.gradle b/java/gradle/publishing.gradle
index 56206c0db..e78b8f5af 100644
--- a/java/gradle/publishing.gradle
+++ b/java/gradle/publishing.gradle
@@ -68,6 +68,21 @@ publishing {
}
}
}
+
+ // Remove the shaded dependencies from the generated pom.
+ pom.withXml {
+ def apiDeps = project.configurations.api.allDependencies
+ def shadedDeps = project.configurations.shadow.allDependencies
+ def finalDeps = apiDeps - shadedDeps
+ asNode().dependencies.dependency.findAll{
+ finalDeps.findAll{ dep ->
+ dep.name == it.artifactId*.value()[0][0]
+ }
+ }.each() {
+ logger.info "Removing: ${it.artifactId*.value()[0][0]} from pom"
+ assert it.parent().remove(it)
+ }
+ }
}
}
diff --git a/java/gradle/shadow.gradle b/java/gradle/shadow.gradle
index 1f1786331..4cf0b9a58 100644
--- a/java/gradle/shadow.gradle
+++ b/java/gradle/shadow.gradle
@@ -19,7 +19,6 @@
// consistently when a subproject requires shaded artifacts.
import org.gradle.api.internal.artifacts.publish.ArchivePublishArtifact
-
apply plugin: "com.github.johnrengelman.shadow"
knows.enabled = false // Disable the "easter egg" knows task.
@@ -87,19 +86,6 @@
configurations.implementation.extendsFrom(configurations.compileUnshaded)
// We use afterEvaluate to add additional configuration once all the
definitions
// in the projects build script have been applied
afterEvaluate {
-// Ensure compileUnshaded dependencies are included in the pom.
- tasks.withType(Upload) { task ->
- task.repositories.each {
- configure(it.pom.scopeMappings) {
- // The priority value is arbitrary.
- addMapping(
- MavenPlugin.COMPILE_PRIORITY,
- configurations.compileUnshaded,
- Conf2ScopeMappingContainer.COMPILE)
- }
- }
- }
-
// Ensure we never shade SLF4J unless we explicitly specify it.
// This is a workaround because in the shadow plugin exclusions from
// parent modules are not respected in modules that use them.
@@ -123,39 +109,3 @@ afterEvaluate {
}
}
-// Remove the shaded dependencies from the generated pom.
-// This hack allows the project to support partially shaded jars,
-// where the shadow plugin by default would remove all compile and runtime
dependencies.
-tasks.withType(Upload) {
- def installer = install.repositories.mavenInstaller
- def deployer = uploadArchives.repositories.mavenDeployer
-
- // Handle install and deploy in the same way.
- [installer, deployer]*.pom*.whenConfigured { pom ->
- def filter = shadowJar.getDependencyFilter()
- def configs = shadowJar.getConfigurations()
-
- def shadowDependencies = configs.collectMany {
- // Find all dependencies included in the shaded jar.
- it.resolvedConfiguration.firstLevelModuleDependencies.findAll {
- filter.isIncluded(it)
- }
- }
-
- // Remove the shaded dependencies from the pom.
- shadowDependencies.each { shaded ->
- def depStr =
"${shaded.getModuleGroup()}:${shaded.getModuleName()}:${shaded.getModuleVersion()}"
- logger.info "Excluding ${depStr} from the generated pom."
- pom.dependencies.removeAll { dep ->
- dep.groupId == shaded.getModuleGroup() &&
- dep.artifactId == shaded.getModuleName() &&
- dep.version == shaded.getModuleVersion()
- }
- }
-
- // Re-sort the generated maven dependencies to make pom comparisons easier.
- pom.dependencies = pom.dependencies.sort { dep ->
- "$dep.scope:$dep.optional:$dep.groupId:$dep.artifactId"
- }
- }
-}
\ No newline at end of file
diff --git a/java/kudu-client/build.gradle b/java/kudu-client/build.gradle
index 61abb96ba..abcc5c713 100644
--- a/java/kudu-client/build.gradle
+++ b/java/kudu-client/build.gradle
@@ -15,12 +15,16 @@
// specific language governing permissions and limitations
// under the License.
+plugins {
+ id("java-library")
+}
+
apply from: "$rootDir/gradle/shadow.gradle"
apply from: "$rootDir/gradle/benchmarks.gradle"
dependencies {
implementation project(path: ":kudu-proto")
- implementation libs.protobufJava
+ api libs.protobufJava
// Not shaded in the client JAR because it's part of the public API.
compileUnshaded (libs.async) {