Skip to content

Commit 9ebe6ac

Browse files
github-actions[bot]coolderliFANNG1
authored
[#3514] improvement(flink-connector): add flink-connector-runtime to build flink connector (#4815)
### What changes were proposed in this pull request? - add flink runtime connector ### Why are the changes needed? Fix: #3514 ### Does this PR introduce _any_ user-facing change? - no ### How was this patch tested? - local test Co-authored-by: Peidian li <38486782+coolderli@users.noreply.github.com> Co-authored-by: fanng <xiaojing@datastrato.com>
1 parent 1fd903e commit 9ebe6ac

33 files changed

+289
-164
lines changed

.github/workflows/flink-integration-test.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,8 @@ jobs:
8686
- name: Flink Integration Test
8787
id: integrationTest
8888
run: |
89-
./gradlew -PskipTests -PtestMode=embedded -PjdkVersion=${{ matrix.java-version }} -PskipDockerTests=false :flink-connector:test --tests "org.apache.gravitino.flink.connector.integration.test.**"
90-
./gradlew -PskipTests -PtestMode=deploy -PjdkVersion=${{ matrix.java-version }} -PskipDockerTests=false :flink-connector:test --tests "org.apache.gravitino.flink.connector.integration.test.**"
89+
./gradlew -PskipTests -PtestMode=embedded -PjdkVersion=${{ matrix.java-version }} -PskipDockerTests=false :flink-connector:flink:test --tests "org.apache.gravitino.flink.connector.integration.test.**"
90+
./gradlew -PskipTests -PtestMode=deploy -PjdkVersion=${{ matrix.java-version }} -PskipDockerTests=false :flink-connector:flink:test --tests "org.apache.gravitino.flink.connector.integration.test.**"
9191
9292
- name: Upload integrate tests reports
9393
uses: actions/upload-artifact@v3
@@ -96,9 +96,9 @@ jobs:
9696
name: flink-connector-integrate-test-reports-${{ matrix.java-version }}
9797
path: |
9898
build/reports
99-
flink-connector/build/flink-connector-integration-test.log
100-
flink-connector/build/*.tar
99+
flink-connector/flink/build/*.log
100+
flink-connector/flink/build/*.tar
101101
distribution/package/logs/gravitino-server.out
102102
distribution/package/logs/gravitino-server.log
103103
catalogs/**/*.log
104-
catalogs/**/*.tar
104+
catalogs/**/*.tar

build.gradle.kts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -736,7 +736,7 @@ tasks {
736736
if (!it.name.startsWith("catalog") &&
737737
!it.name.startsWith("authorization") &&
738738
!it.name.startsWith("client") && !it.name.startsWith("filesystem") && !it.name.startsWith("spark") && !it.name.startsWith("iceberg") && it.name != "trino-connector" &&
739-
it.name != "integration-test" && it.name != "bundled-catalog" && it.name != "flink-connector"
739+
it.name != "integration-test" && it.name != "bundled-catalog" && !it.name.startsWith("flink")
740740
) {
741741
from(it.configurations.runtimeClasspath)
742742
into("distribution/package/libs")
@@ -753,9 +753,9 @@ tasks {
753753
!it.name.startsWith("spark") &&
754754
!it.name.startsWith("iceberg") &&
755755
!it.name.startsWith("integration-test") &&
756+
!it.name.startsWith("flink") &&
756757
it.name != "trino-connector" &&
757-
it.name != "bundled-catalog" &&
758-
it.name != "flink-connector"
758+
it.name != "bundled-catalog"
759759
) {
760760
dependsOn("${it.name}:build")
761761
from("${it.name}/build/libs")

docs/flink-connector/flink-connector.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ This capability allows users to perform federation queries, accessing data from
2323

2424
## How to use it
2525

26-
1. [Build](../how-to-build.md) or [download](https://mvnrepository.com/artifact/org.apache.gravitino/gravitino-flink-connector) the Gravitino flink connector jar, and place it to the classpath of Flink.
26+
1. [Build](../how-to-build.md) or [download](https://mvnrepository.com/artifact/org.apache.gravitino/gravitino-flink-connector-runtime-1.18) the Gravitino flink connector runtime jar, and place it to the classpath of Flink.
2727
2. Configure the Flink configuration to use the Gravitino flink connector.
2828

2929
| Property | Type | Default Value | Description | Required | Since Version |

flink-connector/build.gradle.kts

Lines changed: 3 additions & 154 deletions
Original file line numberDiff line numberDiff line change
@@ -16,158 +16,7 @@
1616
* specific language governing permissions and limitations
1717
* under the License.
1818
*/
19-
plugins {
20-
`maven-publish`
21-
id("java")
22-
id("idea")
23-
}
2419

25-
repositories {
26-
mavenCentral()
27-
}
28-
29-
val flinkVersion: String = libs.versions.flink.get()
30-
31-
// The Flink only support scala 2.12, and all scala api will be removed in a future version.
32-
// You can find more detail at the following issues:
33-
// https://issues.apache.org/jira/browse/FLINK-23986,
34-
// https://issues.apache.org/jira/browse/FLINK-20845,
35-
// https://issues.apache.org/jira/browse/FLINK-13414.
36-
val scalaVersion: String = "2.12"
37-
val artifactName = "gravitino-${project.name}_$scalaVersion"
38-
39-
dependencies {
40-
implementation(project(":api"))
41-
implementation(project(":catalogs:catalog-common"))
42-
implementation(project(":common"))
43-
implementation(project(":core"))
44-
implementation(project(":clients:client-java"))
45-
46-
implementation(libs.bundles.log4j)
47-
implementation(libs.commons.lang3)
48-
implementation(libs.guava)
49-
implementation(libs.httpclient5)
50-
implementation(libs.jackson.databind)
51-
implementation(libs.jackson.annotations)
52-
implementation(libs.jackson.datatype.jdk8)
53-
implementation(libs.jackson.datatype.jsr310)
54-
55-
implementation("org.apache.flink:flink-connector-hive_$scalaVersion:$flinkVersion")
56-
implementation("org.apache.flink:flink-table-common:$flinkVersion")
57-
implementation("org.apache.flink:flink-table-api-java:$flinkVersion")
58-
59-
implementation(libs.hive2.exec) {
60-
artifact {
61-
classifier = "core"
62-
}
63-
exclude("com.fasterxml.jackson.core")
64-
exclude("com.google.code.findbugs", "jsr305")
65-
exclude("com.google.protobuf")
66-
exclude("org.apache.avro")
67-
exclude("org.apache.calcite")
68-
exclude("org.apache.calcite.avatica")
69-
exclude("org.apache.curator")
70-
exclude("org.apache.hadoop", "hadoop-yarn-server-resourcemanager")
71-
exclude("org.apache.logging.log4j")
72-
exclude("org.apache.zookeeper")
73-
exclude("org.eclipse.jetty.aggregate", "jetty-all")
74-
exclude("org.eclipse.jetty.orbit", "javax.servlet")
75-
exclude("org.openjdk.jol")
76-
exclude("org.pentaho")
77-
exclude("org.slf4j")
78-
}
79-
80-
testAnnotationProcessor(libs.lombok)
81-
82-
testCompileOnly(libs.lombok)
83-
testImplementation(project(":integration-test-common", "testArtifacts"))
84-
testImplementation(project(":server"))
85-
testImplementation(project(":server-common"))
86-
testImplementation(libs.junit.jupiter.api)
87-
testImplementation(libs.junit.jupiter.params)
88-
testImplementation(libs.mockito.core)
89-
testImplementation(libs.mysql.driver)
90-
testImplementation(libs.sqlite.jdbc)
91-
testImplementation(libs.testcontainers)
92-
testImplementation(libs.testcontainers.junit.jupiter)
93-
testImplementation(libs.testcontainers.mysql)
94-
95-
testImplementation(libs.hadoop2.common) {
96-
exclude("*")
97-
}
98-
testImplementation(libs.hadoop2.hdfs) {
99-
exclude("com.sun.jersey")
100-
exclude("commons-cli", "commons-cli")
101-
exclude("commons-io", "commons-io")
102-
exclude("commons-codec", "commons-codec")
103-
exclude("commons-logging", "commons-logging")
104-
exclude("javax.servlet", "servlet-api")
105-
exclude("org.mortbay.jetty")
106-
}
107-
testImplementation(libs.hadoop2.mapreduce.client.core) {
108-
exclude("*")
109-
}
110-
testImplementation(libs.hive2.common) {
111-
exclude("org.eclipse.jetty.aggregate", "jetty-all")
112-
exclude("org.eclipse.jetty.orbit", "javax.servlet")
113-
}
114-
testImplementation(libs.hive2.metastore) {
115-
exclude("co.cask.tephra")
116-
exclude("com.github.joshelser")
117-
exclude("com.google.code.findbugs", "jsr305")
118-
exclude("com.google.code.findbugs", "sr305")
119-
exclude("com.tdunning", "json")
120-
exclude("com.zaxxer", "HikariCP")
121-
exclude("io.dropwizard.metricss")
122-
exclude("javax.transaction", "transaction-api")
123-
exclude("org.apache.avro")
124-
exclude("org.apache.curator")
125-
exclude("org.apache.hbase")
126-
exclude("org.apache.hadoop", "hadoop-yarn-server-resourcemanager")
127-
exclude("org.apache.logging.log4j")
128-
exclude("org.apache.parquet", "parquet-hadoop-bundle")
129-
exclude("org.apache.zookeeper")
130-
exclude("org.eclipse.jetty.aggregate", "jetty-all")
131-
exclude("org.eclipse.jetty.orbit", "javax.servlet")
132-
exclude("org.slf4j")
133-
}
134-
testImplementation("org.apache.flink:flink-table-api-bridge-base:$flinkVersion") {
135-
exclude("commons-cli", "commons-cli")
136-
exclude("commons-io", "commons-io")
137-
exclude("com.google.code.findbugs", "jsr305")
138-
}
139-
testImplementation("org.apache.flink:flink-table-planner_$scalaVersion:$flinkVersion")
140-
testImplementation("org.apache.flink:flink-test-utils:$flinkVersion")
141-
142-
testRuntimeOnly(libs.junit.jupiter.engine)
143-
}
144-
145-
tasks.test {
146-
val skipUTs = project.hasProperty("skipTests")
147-
if (skipUTs) {
148-
// Only run integration tests
149-
include("**/integration/**")
150-
}
151-
152-
val skipITs = project.hasProperty("skipITs")
153-
val skipFlinkITs = project.hasProperty("skipFlinkITs")
154-
if (skipITs || skipFlinkITs) {
155-
// Exclude integration tests
156-
exclude("**/integration/**")
157-
} else {
158-
dependsOn(tasks.jar)
159-
dependsOn(":catalogs:catalog-hive:jar")
160-
}
161-
}
162-
163-
tasks.withType<Jar> {
164-
archiveBaseName.set(artifactName)
165-
}
166-
167-
publishing {
168-
publications {
169-
withType<MavenPublication>().configureEach {
170-
artifactId = artifactName
171-
}
172-
}
173-
}
20+
tasks.all {
21+
enabled = false
22+
}
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
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+
id("idea")
25+
alias(libs.plugins.shadow)
26+
}
27+
28+
repositories {
29+
mavenCentral()
30+
}
31+
32+
val flinkVersion: String = libs.versions.flink.get()
33+
val flinkMajorVersion: String = flinkVersion.substringBeforeLast(".")
34+
35+
// The Flink only support scala 2.12, and all scala api will be removed in a future version.
36+
// You can find more detail at the following issues:
37+
// https://issues.apache.org/jira/browse/FLINK-23986,
38+
// https://issues.apache.org/jira/browse/FLINK-20845,
39+
// https://issues.apache.org/jira/browse/FLINK-13414.
40+
val scalaVersion: String = "2.12"
41+
val artifactName = "gravitino-${project.name}_$scalaVersion"
42+
val baseName = "${rootProject.name}-flink-connector-runtime-${flinkMajorVersion}_$scalaVersion"
43+
44+
dependencies {
45+
implementation(project(":clients:client-java-runtime", configuration = "shadow"))
46+
implementation(project(":flink-connector:flink"))
47+
}
48+
49+
tasks.withType<ShadowJar>(ShadowJar::class.java) {
50+
isZip64 = true
51+
configurations = listOf(project.configurations.runtimeClasspath.get())
52+
archiveFileName.set("$baseName-$version.jar")
53+
archiveClassifier.set("")
54+
55+
// Relocate dependencies to avoid conflicts
56+
relocate("com.google", "org.apache.gravitino.shaded.com.google")
57+
relocate("google", "org.apache.gravitino.shaded.google")
58+
relocate("org.apache.hc", "org.apache.gravitino.shaded.org.apache.hc")
59+
relocate("org.apache.commons", "org.apache.gravitino.shaded.org.apache.commons")
60+
}
61+
62+
publishing {
63+
publications {
64+
withType<MavenPublication>().configureEach {
65+
artifactId = baseName
66+
}
67+
}
68+
}
69+
70+
tasks.jar {
71+
dependsOn(tasks.named("shadowJar"))
72+
archiveClassifier.set("empty")
73+
}

0 commit comments

Comments
 (0)