Skip to content

Commit 07cdcba

Browse files
authored
[#5585] improvement(bundles): Refactor bundle jars and provide core jars that does not contains hadoop-{aws,gcp,aliyun,azure} (#5806)
### What changes were proposed in this pull request? Provide another kind of bundle jars that does not contains hadoop-{aws,gcp,aliyun,azure} like aws-mini, gcp-mini. ### Why are the changes needed? To make it works in a wide range of Hadoop version Fix: #5585 ### Does this PR introduce _any_ user-facing change? N/A ### How was this patch tested? Existing UTs and ITs
1 parent d49e7eb commit 07cdcba

File tree

51 files changed

+570
-192
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+570
-192
lines changed

authorizations/authorization-chain/build.gradle.kts

+5-5
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ dependencies {
8181
exclude("net.java.dev.jna")
8282
exclude("javax.ws.rs")
8383
exclude("org.eclipse.jetty")
84+
exclude("org.apache.hadoop", "hadoop-common")
8485
}
8586
testImplementation("org.apache.spark:spark-hive_$scalaVersion:$sparkVersion")
8687
testImplementation("org.apache.spark:spark-sql_$scalaVersion:$sparkVersion") {
@@ -93,11 +94,10 @@ dependencies {
9394
testImplementation("org.apache.kyuubi:kyuubi-spark-authz-shaded_$scalaVersion:$kyuubiVersion") {
9495
exclude("com.sun.jersey")
9596
}
96-
testImplementation(libs.hadoop3.client)
97-
testImplementation(libs.hadoop3.common) {
98-
exclude("com.sun.jersey")
99-
exclude("javax.servlet", "servlet-api")
100-
}
97+
98+
testImplementation(libs.hadoop3.client.api)
99+
testImplementation(libs.hadoop3.client.runtime)
100+
101101
testImplementation(libs.hadoop3.hdfs) {
102102
exclude("com.sun.jersey")
103103
exclude("javax.servlet", "servlet-api")

authorizations/authorization-ranger/build.gradle.kts

+6-5
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,12 @@ dependencies {
6767
exclude("net.java.dev.jna")
6868
exclude("javax.ws.rs")
6969
exclude("org.eclipse.jetty")
70+
// Conflicts with hadoop-client-api used in hadoop-catalog.
71+
exclude("org.apache.hadoop", "hadoop-common")
7072
}
73+
implementation(libs.hadoop3.client.api)
74+
implementation(libs.hadoop3.client.runtime)
75+
7176
implementation(libs.rome)
7277
compileOnly(libs.lombok)
7378
testRuntimeOnly(libs.junit.jupiter.engine)
@@ -92,11 +97,7 @@ dependencies {
9297
testImplementation("org.apache.kyuubi:kyuubi-spark-authz-shaded_$scalaVersion:$kyuubiVersion") {
9398
exclude("com.sun.jersey")
9499
}
95-
testImplementation(libs.hadoop3.client)
96-
testImplementation(libs.hadoop3.common) {
97-
exclude("com.sun.jersey")
98-
exclude("javax.servlet", "servlet-api")
99-
}
100+
100101
testImplementation(libs.hadoop3.hdfs) {
101102
exclude("com.sun.jersey")
102103
exclude("javax.servlet", "servlet-api")

build.gradle.kts

+3-5
Original file line numberDiff line numberDiff line change
@@ -779,7 +779,7 @@ tasks {
779779
!it.name.startsWith("client") && !it.name.startsWith("filesystem") && !it.name.startsWith("spark") && !it.name.startsWith("iceberg") && it.name != "trino-connector" &&
780780
it.name != "integration-test" && it.name != "bundled-catalog" && !it.name.startsWith("flink") &&
781781
it.name != "integration-test" && it.name != "hive-metastore-common" && !it.name.startsWith("flink") &&
782-
it.name != "gcp-bundle" && it.name != "aliyun-bundle" && it.name != "aws-bundle" && it.name != "azure-bundle" && it.name != "hadoop-common"
782+
it.parent?.name != "bundles" && it.name != "hadoop-common"
783783
) {
784784
from(it.configurations.runtimeClasspath)
785785
into("distribution/package/libs")
@@ -799,10 +799,8 @@ tasks {
799799
!it.name.startsWith("integration-test") &&
800800
!it.name.startsWith("flink") &&
801801
!it.name.startsWith("trino-connector") &&
802-
it.name != "bundled-catalog" &&
803-
it.name != "hive-metastore-common" && it.name != "gcp-bundle" &&
804-
it.name != "aliyun-bundle" && it.name != "aws-bundle" && it.name != "azure-bundle" &&
805-
it.name != "hadoop-common" && it.name != "docs"
802+
it.name != "hive-metastore-common" &&
803+
it.name != "docs" && it.name != "hadoop-common" && it.parent?.name != "bundles"
806804
) {
807805
dependsOn("${it.name}:build")
808806
from("${it.name}/build/libs")

bundles/aliyun-bundle/build.gradle.kts

+11-27
Original file line numberDiff line numberDiff line change
@@ -25,32 +25,12 @@ plugins {
2525
}
2626

2727
dependencies {
28-
compileOnly(project(":api"))
29-
compileOnly(project(":core"))
30-
compileOnly(project(":catalogs:catalog-common"))
31-
compileOnly(project(":catalogs:catalog-hadoop"))
32-
compileOnly(project(":catalogs:hadoop-common")) {
33-
exclude("*")
34-
}
35-
compileOnly(libs.hadoop3.common)
36-
37-
implementation(libs.aliyun.credentials.sdk)
28+
implementation(project(":bundles:aliyun"))
29+
implementation(libs.commons.collections3)
30+
implementation(libs.hadoop3.client.api)
31+
implementation(libs.hadoop3.client.runtime)
3832
implementation(libs.hadoop3.oss)
39-
40-
// Aliyun oss SDK depends on this package, and JDK >= 9 requires manual add
41-
// https://www.alibabacloud.com/help/en/oss/developer-reference/java-installation?spm=a2c63.p38356.0.i1
42-
implementation(libs.sun.activation)
43-
44-
// oss needs StringUtils from commons-lang3 or the following error will occur in 3.3.0
45-
// java.lang.NoClassDefFoundError: org/apache/commons/lang3/StringUtils
46-
// org.apache.hadoop.fs.aliyun.oss.AliyunOSSFileSystemStore.initialize(AliyunOSSFileSystemStore.java:111)
47-
// org.apache.hadoop.fs.aliyun.oss.AliyunOSSFileSystem.initialize(AliyunOSSFileSystem.java:323)
48-
// org.apache.hadoop.fs.FileSystem.createFileSystem(FileSystem.java:3611)
49-
implementation(libs.commons.lang3)
50-
51-
implementation(project(":catalogs:catalog-common")) {
52-
exclude("*")
53-
}
33+
implementation(libs.httpclient)
5434
}
5535

5636
tasks.withType(ShadowJar::class.java) {
@@ -60,8 +40,12 @@ tasks.withType(ShadowJar::class.java) {
6040
mergeServiceFiles()
6141

6242
// Relocate dependencies to avoid conflicts
63-
relocate("org.jdom", "org.apache.gravitino.shaded.org.jdom")
64-
relocate("org.apache.commons.lang3", "org.apache.gravitino.shaded.org.apache.commons.lang3")
43+
relocate("org.jdom", "org.apache.gravitino.aliyun.shaded.org.jdom")
44+
relocate("org.apache.commons.lang3", "org.apache.gravitino.aliyun.shaded.org.apache.commons.lang3")
45+
relocate("com.fasterxml.jackson", "org.apache.gravitino.aliyun.shaded.com.fasterxml.jackson")
46+
relocate("com.google.common", "org.apache.gravitino.aliyun.shaded.com.google.common")
47+
relocate("org.apache.http", "org.apache.gravitino.aliyun.shaded.org.apache.http")
48+
relocate("org.apache.commons.collections", "org.apache.gravitino.aliyun.shaded.org.apache.commons.collections")
6549
}
6650

6751
tasks.jar {

bundles/aliyun/build.gradle.kts

+87
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one
3+
* or more contributor license agreements. See the NOTICE file
4+
* distributed with this work for additional information
5+
* regarding copyright ownership. The ASF licenses this file
6+
* to you under the Apache License, Version 2.0 (the
7+
* "License"); you may not use this file except in compliance
8+
* with the License. You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
19+
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
20+
21+
plugins {
22+
`maven-publish`
23+
id("java")
24+
alias(libs.plugins.shadow)
25+
}
26+
27+
dependencies {
28+
compileOnly(project(":api"))
29+
compileOnly(project(":catalogs:catalog-common"))
30+
compileOnly(project(":catalogs:catalog-hadoop"))
31+
compileOnly(project(":core"))
32+
compileOnly(libs.hadoop3.client.api)
33+
compileOnly(libs.hadoop3.client.runtime)
34+
compileOnly(libs.hadoop3.oss)
35+
36+
implementation(project(":catalogs:catalog-common")) {
37+
exclude("*")
38+
}
39+
implementation(project(":catalogs:hadoop-common")) {
40+
exclude("*")
41+
}
42+
43+
implementation(libs.aliyun.credentials.sdk)
44+
implementation(libs.commons.collections3)
45+
46+
// oss needs StringUtils from commons-lang3 or the following error will occur in 3.3.0
47+
// java.lang.NoClassDefFoundError: org/apache/commons/lang3/StringUtils
48+
// org.apache.hadoop.fs.aliyun.oss.AliyunOSSFileSystemStore.initialize(AliyunOSSFileSystemStore.java:111)
49+
// org.apache.hadoop.fs.aliyun.oss.AliyunOSSFileSystem.initialize(AliyunOSSFileSystem.java:323)
50+
// org.apache.hadoop.fs.FileSystem.createFileSystem(FileSystem.java:3611)
51+
implementation(libs.commons.lang3)
52+
implementation(libs.guava)
53+
54+
implementation(libs.httpclient)
55+
implementation(libs.jackson.databind)
56+
implementation(libs.jackson.annotations)
57+
implementation(libs.jackson.datatype.jdk8)
58+
implementation(libs.jackson.datatype.jsr310)
59+
60+
// Aliyun oss SDK depends on this package, and JDK >= 9 requires manual add
61+
// https://www.alibabacloud.com/help/en/oss/developer-reference/java-installation?spm=a2c63.p38356.0.i1
62+
implementation(libs.sun.activation)
63+
}
64+
65+
tasks.withType(ShadowJar::class.java) {
66+
isZip64 = true
67+
configurations = listOf(project.configurations.runtimeClasspath.get())
68+
archiveClassifier.set("")
69+
mergeServiceFiles()
70+
71+
// Relocate dependencies to avoid conflicts
72+
relocate("org.jdom", "org.apache.gravitino.aliyun.shaded.org.jdom")
73+
relocate("org.apache.commons.lang3", "org.apache.gravitino.aliyun.shaded.org.apache.commons.lang3")
74+
relocate("com.fasterxml.jackson", "org.apache.gravitino.aliyun.shaded.com.fasterxml.jackson")
75+
relocate("com.google.common", "org.apache.gravitino.aliyun.shaded.com.google.common")
76+
relocate("org.apache.http", "org.apache.gravitino.aliyun.shaded.org.apache.http")
77+
relocate("org.apache.commons.collections", "org.apache.gravitino.aliyun.shaded.org.apache.commons.collections")
78+
}
79+
80+
tasks.jar {
81+
dependsOn(tasks.named("shadowJar"))
82+
archiveClassifier.set("empty")
83+
}
84+
85+
tasks.compileJava {
86+
dependsOn(":catalogs:catalog-hadoop:runtimeJars")
87+
}

bundles/aws-bundle/build.gradle.kts

+7-17
Original file line numberDiff line numberDiff line change
@@ -25,30 +25,20 @@ plugins {
2525
}
2626

2727
dependencies {
28-
compileOnly(project(":api"))
29-
compileOnly(project(":core"))
30-
compileOnly(project(":catalogs:catalog-common"))
31-
compileOnly(project(":catalogs:catalog-hadoop"))
32-
compileOnly(project(":catalogs:hadoop-common")) {
33-
exclude("*")
34-
}
35-
compileOnly(libs.hadoop3.common)
36-
37-
implementation(libs.aws.iam)
38-
implementation(libs.aws.policy)
39-
implementation(libs.aws.sts)
40-
implementation(libs.commons.lang3)
28+
implementation(project(":bundles:aws"))
4129
implementation(libs.hadoop3.aws)
42-
implementation(project(":catalogs:catalog-common")) {
43-
exclude("*")
44-
}
30+
implementation(libs.hadoop3.client.api)
31+
implementation(libs.hadoop3.client.runtime)
4532
}
4633

4734
tasks.withType(ShadowJar::class.java) {
4835
isZip64 = true
4936
configurations = listOf(project.configurations.runtimeClasspath.get())
50-
relocate("org.apache.commons", "org.apache.gravitino.aws.shaded.org.apache.commons")
5137
archiveClassifier.set("")
38+
39+
relocate("org.apache.commons.lang3", "org.apache.gravitino.aws.shaded.org.apache.commons.lang3")
40+
relocate("com.google.common", "org.apache.gravitino.aws.shaded.com.google.common")
41+
relocate("com.fasterxml.jackson", "org.apache.gravitino.aws.shaded.com.fasterxml.jackson")
5242
}
5343

5444
tasks.jar {

bundles/aws/build.gradle.kts

+68
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one
3+
* or more contributor license agreements. See the NOTICE file
4+
* distributed with this work for additional information
5+
* regarding copyright ownership. The ASF licenses this file
6+
* to you under the Apache License, Version 2.0 (the
7+
* "License"); you may not use this file except in compliance
8+
* with the License. You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
19+
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
20+
21+
plugins {
22+
`maven-publish`
23+
id("java")
24+
alias(libs.plugins.shadow)
25+
}
26+
27+
dependencies {
28+
compileOnly(project(":api"))
29+
compileOnly(project(":catalogs:catalog-common"))
30+
compileOnly(project(":catalogs:catalog-hadoop"))
31+
compileOnly(project(":core"))
32+
compileOnly(libs.hadoop3.aws)
33+
compileOnly(libs.hadoop3.client.api)
34+
compileOnly(libs.hadoop3.client.runtime)
35+
36+
implementation(project(":catalogs:catalog-common")) {
37+
exclude("*")
38+
}
39+
implementation(project(":catalogs:hadoop-common")) {
40+
exclude("*")
41+
}
42+
43+
implementation(libs.aws.iam)
44+
implementation(libs.aws.policy)
45+
implementation(libs.aws.sts)
46+
implementation(libs.commons.lang3)
47+
implementation(libs.hadoop3.aws)
48+
implementation(libs.guava)
49+
}
50+
51+
tasks.withType(ShadowJar::class.java) {
52+
isZip64 = true
53+
configurations = listOf(project.configurations.runtimeClasspath.get())
54+
archiveClassifier.set("")
55+
56+
relocate("org.apache.commons.lang3", "org.apache.gravitino.aws.shaded.org.apache.commons.lang3")
57+
relocate("com.google.common", "org.apache.gravitino.aws.shaded.com.google.common")
58+
relocate("com.fasterxml.jackson", "org.apache.gravitino.aws.shaded.com.fasterxml.jackson")
59+
}
60+
61+
tasks.jar {
62+
dependsOn(tasks.named("shadowJar"))
63+
archiveClassifier.set("empty")
64+
}
65+
66+
tasks.compileJava {
67+
dependsOn(":catalogs:catalog-hadoop:runtimeJars")
68+
}

0 commit comments

Comments
 (0)