Skip to content

Commit 3216ba9

Browse files
committed
[SPARK-49400] Use Gradle Version Catalog
### What changes were proposed in this pull request? This PR aims to use a standard `Gradle Version Catalog`. - https://docs.gradle.org/current/userguide/platforms.html#sub:conventional-dependencies-toml ### Why are the changes needed? Currently, `gradle.properties` has all predefined versions, but it's not a good place. Gradle provides a standard way, `Gradle Version Catalog`, via `libs.versions.toml`, which is supported by CIs and other tools. We had better follow the standard in order to simplify the code and reduce the maintenance burden. ``` - implementation("org.apache.spark:spark-kubernetes_$scalaVersion:$sparkVersion") { + implementation(libs.spark.kubernetes) { ``` ### Does this PR introduce _any_ user-facing change? No. This is a dev-only change. ### How was this patch tested? Pass the CIs. ### Was this patch authored or co-authored using generative AI tooling? No. Closes #109 from dongjoon-hyun/SPARK-49400. Authored-by: Dongjoon Hyun <[email protected]> Signed-off-by: Dongjoon Hyun <[email protected]>
1 parent c965d70 commit 3216ba9

File tree

6 files changed

+119
-79
lines changed

6 files changed

+119
-79
lines changed

build.gradle

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,9 @@ buildscript {
2323
}
2424
}
2525
dependencies {
26-
classpath "com.github.spotbugs.snom:spotbugs-gradle-plugin:${spotBugsGradlePluginVersion}"
27-
classpath "com.diffplug.spotless:spotless-plugin-gradle:${spotlessPluginVersion}"
28-
classpath "com.github.johnrengelman:shadow:${shadowJarPluginVersion}"
26+
classpath "${libs.spotbugs.gradle.plugin.get()}"
27+
classpath "${libs.spotless.plugin.gradle.get()}"
28+
classpath "${libs.shadow.get()}"
2929
}
3030
}
3131

@@ -59,7 +59,7 @@ subprojects {
5959

6060
apply plugin: 'checkstyle'
6161
checkstyle {
62-
toolVersion = checkstyleVersion
62+
toolVersion = libs.versions.checkstyle.get()
6363
configFile = file("$rootDir/config/checkstyle/checkstyle.xml")
6464
ignoreFailures = false
6565
showViolations = true
@@ -68,14 +68,14 @@ subprojects {
6868
apply plugin: 'pmd'
6969
pmd {
7070
ruleSetFiles = files("$rootDir/config/pmd/ruleset.xml")
71-
toolVersion = pmdVersion
71+
toolVersion = libs.versions.pmd.get()
7272
consoleOutput = true
7373
ignoreFailures = false
7474
}
7575

7676
apply plugin: 'com.github.spotbugs'
7777
spotbugs {
78-
toolVersion = spotBugsVersion
78+
toolVersion = libs.versions.spotbugs.tool.get()
7979
afterEvaluate {
8080
reportsDir = file("${project.reporting.baseDir}/findbugs")
8181
}
@@ -85,7 +85,7 @@ subprojects {
8585

8686
apply plugin: 'jacoco'
8787
jacoco {
88-
toolVersion = jacocoVersion
88+
toolVersion = libs.versions.jacoco.get()
8989
}
9090
jacocoTestReport {
9191
dependsOn test

gradle.properties

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -17,33 +17,3 @@
1717

1818
# Gradle
1919
org.gradle.jvmargs=-Xmx4g
20-
21-
# Caution: fabric8 version should be aligned with Spark dependency
22-
fabric8Version=6.13.3
23-
lombokVersion=1.18.32
24-
operatorSDKVersion=4.9.0
25-
okHttpVersion=4.12.0
26-
dropwizardMetricsVersion=4.2.25
27-
28-
# Spark
29-
scalaVersion=2.13
30-
sparkVersion=4.0.0-preview1
31-
32-
# Logging
33-
log4jVersion=2.22.1
34-
35-
# Test
36-
junitVersion=5.10.2
37-
jacocoVersion=0.8.12
38-
mockitoVersion=5.11.0
39-
powerMockVersion=2.0.9
40-
41-
# Build Analysis
42-
checkstyleVersion=10.17.0
43-
pmdVersion=6.55.0
44-
spotBugsGradlePluginVersion=6.0.17
45-
spotBugsVersion=4.8.6
46-
spotlessPluginVersion=6.25.0
47-
48-
# Packaging
49-
shadowJarPluginVersion=8.1.1

gradle/libs.versions.toml

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
# Licensed to the Apache Software Foundation (ASF) under one
2+
# or more contributor license agreements. See the NOTICE file
3+
# distributed with this work for additional information
4+
# regarding copyright ownership. The ASF licenses this file
5+
# to you under the Apache License, Version 2.0 (the
6+
# "License"); you may not use this file except in compliance
7+
# with the License. You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing,
12+
# software distributed under the License is distributed on an
13+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
# KIND, either express or implied. See the License for the
15+
# specific language governing permissions and limitations
16+
# under the License.
17+
[versions]
18+
fabric8 = "6.13.3"
19+
lombok = "1.18.32"
20+
operator-sdk = "4.9.0"
21+
okhttp = "4.12.0"
22+
dropwizard-metrics = "4.2.25"
23+
spark = "4.0.0-preview1"
24+
log4j = "2.22.1"
25+
26+
# Test
27+
junit = "5.10.2"
28+
jacoco = "0.8.12"
29+
mockito = "5.11.0"
30+
powermock = "2.0.9"
31+
32+
# Build Analysis
33+
checkstyle = "10.17.0"
34+
pmd = "6.55.0"
35+
spotbugs-tool = "4.8.6"
36+
spotbugs-plugin = "6.0.17"
37+
spotless-plugin = "6.25.0"
38+
39+
# Packaging
40+
shadow-jar-plugin = "8.1.1"
41+
42+
[libraries]
43+
kubernetes-client = { group = "io.fabric8", name = "kubernetes-client", version.ref = "fabric8" }
44+
kubernetes-httpclient-okhttp = { group = "io.fabric8", name = "kubernetes-httpclient-okhttp", version.ref = "fabric8" }
45+
kubernetes-server-mock = { group = "io.fabric8", name = "kubernetes-server-mock", version.ref = "fabric8" }
46+
crd-generator-apt = { group = "io.fabric8", name = "crd-generator-apt", version.ref = "fabric8" }
47+
okhttp = { group = "com.squareup.okhttp3", name = "okhttp", version.ref = "okhttp" }
48+
mockwebserver = { group = "com.squareup.okhttp3", name = "mockwebserver", version.ref = "okhttp" }
49+
logging-interceptor = { group = "com.squareup.okhttp3", name = "logging-interceptor", version.ref = "okhttp" }
50+
lombok = { group = "org.projectlombok", name = "lombok", version.ref = "lombok" }
51+
log4j-api = { group = "org.apache.logging.log4j", name = "log4j-api", version.ref = "log4j" }
52+
log4j-core = { group = "org.apache.logging.log4j", name = "log4j-core", version.ref = "log4j" }
53+
log4j-slf4j-impl = { group = "org.apache.logging.log4j", name = "log4j-slf4j-impl", version.ref = "log4j" }
54+
log4j-api12 = { group = "org.apache.logging.log4j", name = "log4j-1.2-api", version.ref = "log4j" }
55+
log4j-layout-template-json = { group = "org.apache.logging.log4j", name = "log4j-layout-template-json", version.ref = "log4j" }
56+
operator-framework = { group = "io.javaoperatorsdk", name = "operator-framework", version.ref = "operator-sdk"}
57+
operator-framework-junit5 = { group = "io.javaoperatorsdk", name = "operator-framework-junit-5", version.ref = "operator-sdk"}
58+
spotbugs-annotations = { group = "com.github.spotbugs", name = "spotbugs-annotations", version.ref = "spotbugs-tool"}
59+
metrics-core = { group = "io.dropwizard.metrics", name = "metrics-core", version.ref = "dropwizard-metrics"}
60+
metrics-jvm = { group = "io.dropwizard.metrics", name = "metrics-jvm", version.ref = "dropwizard-metrics"}
61+
spark-core = { group = "org.apache.spark", name = "spark-core_2.13", version.ref = "spark"}
62+
spark-kubernetes = { group = "org.apache.spark", name = "spark-kubernetes_2.13", version.ref = "spark"}
63+
mockito-core = { group = "org.mockito", name = "mockito-core", version.ref = "mockito"}
64+
junit-bom = { group = "org.junit", name = "junit-bom", version.ref = "junit"}
65+
junit-jupiter = { group = "org.junit.jupiter", name = "junit-jupiter", version.ref = "junit"}
66+
junit-platform-launcher = { group = "org.junit.platform", name = "junit-platform-launcher"}
67+
powermock-core = { group = "org.powermock", name = "powermock-core", version.ref = "powermock"}
68+
spotbugs-gradle-plugin = { group = "com.github.spotbugs.snom", name = "spotbugs-gradle-plugin", version.ref = "spotbugs-plugin" }
69+
spotless-plugin-gradle = { group = "com.diffplug.spotless", name = "spotless-plugin-gradle", version.ref = "spotless-plugin" }
70+
shadow = { group = "com.github.johnrengelman", name = "shadow", version.ref = "shadow-jar-plugin"}

spark-operator-api/build.gradle

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -18,23 +18,23 @@
1818
*/
1919
dependencies {
2020
// fabric8
21-
implementation("io.fabric8:kubernetes-client:$fabric8Version") {
21+
implementation(libs.kubernetes.client) {
2222
exclude group: 'com.squareup.okhttp3'
2323
}
24-
compileOnly("io.fabric8:crd-generator-apt:$fabric8Version")
25-
annotationProcessor("io.fabric8:crd-generator-apt:$fabric8Version")
24+
compileOnly(libs.crd.generator.apt)
25+
annotationProcessor(libs.crd.generator.apt)
2626

2727
// utils
28-
implementation("org.projectlombok:lombok:$lombokVersion")
29-
annotationProcessor("org.projectlombok:lombok:$lombokVersion")
28+
implementation(libs.lombok)
29+
annotationProcessor(libs.lombok)
3030

3131
// logging
32-
implementation("org.apache.logging.log4j:log4j-slf4j-impl:$log4jVersion")
33-
implementation("org.apache.logging.log4j:log4j-core:$log4jVersion")
32+
implementation(libs.log4j.slf4j.impl)
33+
implementation(libs.log4j.core)
3434

35-
testImplementation platform("org.junit:junit-bom:$junitVersion")
36-
testImplementation 'org.junit.jupiter:junit-jupiter'
37-
testRuntimeOnly "org.junit.platform:junit-platform-launcher"
35+
testImplementation(platform(libs.junit.bom))
36+
testImplementation(libs.junit.jupiter)
37+
testRuntimeOnly(libs.junit.platform.launcher)
3838
}
3939

4040
test {

spark-operator/build.gradle

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -22,27 +22,27 @@ dependencies {
2222
implementation project(":spark-operator-api")
2323
implementation project(":spark-submission-worker")
2424

25-
implementation("io.javaoperatorsdk:operator-framework:$operatorSDKVersion") {
25+
implementation(libs.operator.framework) {
2626
exclude group: 'com.squareup.okio'
2727
exclude group: 'io.fabric8'
2828
}
29-
implementation("io.fabric8:kubernetes-httpclient-okhttp:$fabric8Version") {
29+
implementation(libs.kubernetes.httpclient.okhttp) {
3030
exclude group: 'com.squareup.okhttp3'
3131
}
32-
implementation("com.squareup.okhttp3:okhttp:$okHttpVersion")
33-
implementation("com.squareup.okhttp3:logging-interceptor:$okHttpVersion")
34-
implementation("com.github.spotbugs:spotbugs-annotations:$spotBugsVersion")
32+
implementation(libs.okhttp)
33+
implementation(libs.logging.interceptor)
34+
implementation(libs.spotbugs.annotations)
3535
// logging
36-
implementation("org.apache.logging.log4j:log4j-api:$log4jVersion")
37-
implementation("org.apache.logging.log4j:log4j-core:$log4jVersion")
38-
implementation("org.apache.logging.log4j:log4j-slf4j-impl:$log4jVersion")
39-
implementation("org.apache.logging.log4j:log4j-1.2-api:$log4jVersion")
40-
implementation("org.apache.logging.log4j:log4j-layout-template-json:$log4jVersion")
36+
implementation(libs.log4j.api)
37+
implementation(libs.log4j.core)
38+
implementation(libs.log4j.slf4j.impl)
39+
implementation(libs.log4j.api12)
40+
implementation(libs.log4j.layout.template.json)
4141

4242
// metrics
43-
implementation("io.dropwizard.metrics:metrics-core:$dropwizardMetricsVersion")
44-
implementation("io.dropwizard.metrics:metrics-jvm:$dropwizardMetricsVersion")
45-
compileOnly("org.apache.spark:spark-core_$scalaVersion:$sparkVersion") {
43+
implementation(libs.metrics.core)
44+
implementation(libs.metrics.jvm)
45+
compileOnly(libs.spark.core) {
4646
exclude group: "com.github.luben"
4747
exclude group: "io.netty", module: "netty-tcnative-boringssl-static"
4848
exclude group: "io.netty", module: "netty-tcnative-classes"
@@ -55,32 +55,32 @@ dependencies {
5555
exclude group: 'com.squareup.okhttp3'
5656
exclude group: 'com.squareup.okio'
5757
}
58-
compileOnly("org.projectlombok:lombok:$lombokVersion")
58+
compileOnly(libs.lombok)
5959

60-
annotationProcessor("org.projectlombok:lombok:$lombokVersion")
61-
annotationProcessor("com.github.spotbugs:spotbugs-annotations:$spotBugsVersion")
60+
annotationProcessor(libs.lombok)
61+
annotationProcessor(libs.spotbugs.annotations)
6262

63-
testImplementation("io.javaoperatorsdk:operator-framework-junit-5:$operatorSDKVersion") {
63+
testImplementation(libs.operator.framework.junit5) {
6464
exclude group: 'com.squareup.okio'
6565
exclude group: 'io.fabric8'
6666
}
67-
testImplementation("io.fabric8:kubernetes-server-mock:$fabric8Version") {
67+
testImplementation(libs.kubernetes.server.mock) {
6868
exclude group: 'junit'
6969
exclude group: 'com.squareup.okhttp3'
7070
}
71-
testImplementation("org.apache.spark:spark-core_$scalaVersion:$sparkVersion") {
71+
testImplementation(libs.spark.core) {
7272
exclude group: 'com.squareup.okio'
7373
exclude group: 'com.squareup.okhttp3'
7474
exclude group: "org.apache.logging.log4j"
7575
exclude group: "org.slf4j"
7676
}
77-
testImplementation("com.squareup.okhttp3:mockwebserver:$okHttpVersion")
78-
testImplementation platform("org.junit:junit-bom:$junitVersion")
79-
testImplementation("org.junit.jupiter:junit-jupiter:$junitVersion")
80-
testImplementation("org.powermock:powermock-core:$powerMockVersion")
81-
testRuntimeOnly("org.junit.platform:junit-platform-launcher")
77+
testImplementation(libs.mockwebserver)
78+
testImplementation platform(libs.junit.bom)
79+
testImplementation(libs.junit.jupiter)
80+
testImplementation(libs.powermock.core)
81+
testRuntimeOnly(libs.junit.platform.launcher)
8282

83-
testImplementation("org.mockito:mockito-core:$mockitoVersion")
83+
testImplementation(libs.mockito.core)
8484
}
8585

8686
test {

spark-submission-worker/build.gradle

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
dependencies {
2020
implementation project(":spark-operator-api")
2121

22-
implementation("org.apache.spark:spark-kubernetes_$scalaVersion:$sparkVersion") {
22+
implementation(libs.spark.kubernetes) {
2323
exclude group: "com.github.luben"
2424
exclude group: "io.netty", module: "netty-tcnative-boringssl-static"
2525
exclude group: "io.netty", module: "netty-tcnative-classes"
@@ -30,13 +30,13 @@ dependencies {
3030
exclude group: 'commons-collections', module: 'commons-collections'
3131
}
3232

33-
compileOnly("org.projectlombok:lombok:$lombokVersion")
34-
annotationProcessor("org.projectlombok:lombok:$lombokVersion")
33+
compileOnly(libs.lombok)
34+
annotationProcessor(libs.lombok)
3535

36-
testImplementation platform("org.junit:junit-bom:$junitVersion")
37-
testImplementation "org.mockito:mockito-core:$mockitoVersion"
38-
testImplementation "org.junit.jupiter:junit-jupiter:$junitVersion"
39-
testRuntimeOnly "org.junit.platform:junit-platform-launcher"
36+
testImplementation(platform(libs.junit.bom))
37+
testImplementation(libs.mockito.core)
38+
testImplementation(libs.junit.jupiter)
39+
testRuntimeOnly(libs.junit.platform.launcher)
4040
}
4141

4242
test {

0 commit comments

Comments
 (0)