Skip to content

Commit a4f7c55

Browse files
authored
build: use Gradle version catalog for dependencies and plugins (#467)
Signed-off-by: Niels Pardon <[email protected]>
1 parent cdd2cf4 commit a4f7c55

File tree

12 files changed

+170
-161
lines changed

12 files changed

+170
-161
lines changed

bom/build.gradle.kts

Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -21,30 +21,12 @@ plugins {
2121

2222
val String.v: String get() = rootProject.extra["$this.version"] as String
2323

24-
// Note: Gradle allows to declare dependency on "bom" as "api",
25-
// and it makes the contraints to be transitively visible
26-
// However Maven can't express that, so the approach is to use Gradle resolution
27-
// and generate pom files with resolved versions
28-
// See https://github.com/gradle/gradle/issues/9866
29-
30-
fun DependencyConstraintHandlerScope.apiv(
31-
notation: String,
32-
versionProp: String = notation.substringAfterLast(':')
33-
) =
34-
"api"(notation + ":" + versionProp.v)
35-
36-
fun DependencyConstraintHandlerScope.runtimev(
37-
notation: String,
38-
versionProp: String = notation.substringAfterLast(':')
39-
) =
40-
"runtime"(notation + ":" + versionProp.v)
41-
4224
javaPlatform {
4325
allowDependencies()
4426
}
4527

4628
dependencies {
47-
api(platform("com.fasterxml.jackson:jackson-bom:${"jackson".v}"))
29+
api(platform(libs.jackson.bom))
4830

4931
// Parenthesis are needed here: https://github.com/gradle/gradle/issues/9248
5032
(constraints) {

build-logic/build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
plugins {
22
`kotlin-dsl`
3-
id("com.diffplug.spotless") version "6.19.0"
3+
alias(libs.plugins.spotless)
44
}
55

66
repositories { gradlePluginPortal() }

build-logic/settings.gradle.kts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
dependencyResolutionManagement {
2+
versionCatalogs { create("libs") { from(files("../gradle/libs.versions.toml")) } }
3+
}

build.gradle.kts

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,25 +7,22 @@ plugins {
77
`maven-publish`
88
id("java")
99
id("idea")
10-
id("com.github.vlsi.gradle-extensions") version "1.74"
11-
id("com.diffplug.spotless") version "7.1.0"
12-
id("org.jreleaser") version "1.18.0" apply false
10+
alias(libs.plugins.gradle.extensions)
11+
alias(libs.plugins.spotless)
12+
alias(libs.plugins.jreleaser) apply false
1313
}
1414

15-
var IMMUTABLES_VERSION = properties.get("immutables.version")
16-
var JUNIT_VERSION = properties.get("junit.version")
17-
var SLF4J_VERSION = properties.get("slf4j.version")
18-
1915
repositories { mavenCentral() }
2016

2117
java { toolchain { languageVersion.set(JavaLanguageVersion.of(17)) } }
2218

2319
dependencies {
24-
testImplementation("org.junit.jupiter:junit-jupiter-api:${JUNIT_VERSION}")
25-
testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:${JUNIT_VERSION}")
26-
implementation("org.slf4j:slf4j-api:${SLF4J_VERSION}")
27-
annotationProcessor("org.immutables:value:${IMMUTABLES_VERSION}")
28-
compileOnly("org.immutables:value-annotations:${IMMUTABLES_VERSION}")
20+
testImplementation(platform(libs.junit.bom))
21+
testImplementation(libs.junit.jupiter.api)
22+
testImplementation(libs.junit.jupiter.engine)
23+
implementation(libs.slf4j.api)
24+
annotationProcessor(libs.immutables.value)
25+
compileOnly(libs.immutables.annotations)
2926
}
3027

3128
val submodulesUpdate by

core/build.gradle.kts

Lines changed: 20 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@ plugins {
1111
id("java-library")
1212
id("idea")
1313
id("antlr")
14-
id("com.google.protobuf") version "0.9.4"
15-
id("com.diffplug.spotless") version "7.1.0"
16-
id("com.gradleup.shadow") version "8.3.8"
17-
id("org.jreleaser")
14+
alias(libs.plugins.protobuf)
15+
alias(libs.plugins.spotless)
16+
alias(libs.plugins.shadow)
17+
alias(libs.plugins.jreleaser)
1818
id("substrait.java-conventions")
1919
}
2020

@@ -99,13 +99,6 @@ jreleaser {
9999
release { github { enabled = false } }
100100
}
101101

102-
val ANTLR_VERSION = properties.get("antlr.version")
103-
val IMMUTABLES_VERSION = properties.get("immutables.version")
104-
val JACKSON_VERSION = properties.get("jackson.version")
105-
val JUNIT_VERSION = properties.get("junit.version")
106-
val SLF4J_VERSION = properties.get("slf4j.version")
107-
val PROTOBUF_VERSION = properties.get("protobuf.version")
108-
109102
// This allows specifying deps to be shadowed so that they don't get included in the POM file
110103
val shadowImplementation by configurations.creating
111104

@@ -114,21 +107,21 @@ configurations[JavaPlugin.COMPILE_ONLY_CONFIGURATION_NAME].extendsFrom(shadowImp
114107
configurations[JavaPlugin.TEST_IMPLEMENTATION_CONFIGURATION_NAME].extendsFrom(shadowImplementation)
115108

116109
dependencies {
117-
testImplementation(platform("org.junit:junit-bom:${JUNIT_VERSION}"))
118-
testImplementation("org.junit.jupiter:junit-jupiter")
119-
testRuntimeOnly("org.junit.platform:junit-platform-launcher")
120-
api("com.google.protobuf:protobuf-java:${PROTOBUF_VERSION}")
121-
implementation("com.fasterxml.jackson.core:jackson-databind:${JACKSON_VERSION}")
122-
implementation("com.fasterxml.jackson.core:jackson-annotations:${JACKSON_VERSION}")
123-
implementation("com.fasterxml.jackson.datatype:jackson-datatype-jdk8:${JACKSON_VERSION}")
124-
implementation("com.fasterxml.jackson.dataformat:jackson-dataformat-yaml:${JACKSON_VERSION}")
125-
api("org.jspecify:jspecify:1.0.0")
126-
127-
antlr("org.antlr:antlr4:${ANTLR_VERSION}")
128-
shadowImplementation("org.antlr:antlr4-runtime:${ANTLR_VERSION}")
129-
implementation("org.slf4j:slf4j-api:${SLF4J_VERSION}")
130-
annotationProcessor("org.immutables:value:${IMMUTABLES_VERSION}")
131-
compileOnly("org.immutables:value-annotations:${IMMUTABLES_VERSION}")
110+
testImplementation(platform(libs.junit.bom))
111+
testImplementation(libs.junit.jupiter)
112+
testRuntimeOnly(libs.junit.platform.launcher)
113+
114+
implementation(platform(libs.jackson.bom))
115+
implementation(libs.bundles.jackson)
116+
117+
api(libs.protobuf.java)
118+
api(libs.jspecify)
119+
120+
antlr(libs.antlr4)
121+
shadowImplementation(libs.antlr4.runtime)
122+
implementation(libs.slf4j.api)
123+
annotationProcessor(libs.immutables.value)
124+
compileOnly(libs.immutables.annotations)
132125
}
133126

134127
configurations[JavaPlugin.API_CONFIGURATION_NAME].let { apiConfiguration ->
@@ -281,4 +274,4 @@ tasks.named<AntlrTask>("generateGrammarSource") {
281274
layout.buildDirectory.dir("generated/sources/antlr/main/java/io/substrait/type").get().asFile
282275
}
283276

284-
protobuf { protoc { artifact = "com.google.protobuf:protoc:${PROTOBUF_VERSION}" } }
277+
protobuf { protoc { artifact = "com.google.protobuf:protoc:" + libs.protoc.get().getVersion() } }

examples/substrait-spark/build.gradle.kts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
plugins {
22
// Apply the application plugin to add support for building a CLI application in Java.
33
id("java")
4-
id("com.diffplug.spotless") version "7.1.0"
4+
alias(libs.plugins.spotless)
55
id("substrait.java-conventions")
66
}
77

@@ -15,8 +15,8 @@ dependencies {
1515

1616
// For a real Spark application, these would not be required since they would be in the Spark
1717
// server classpath
18-
runtimeOnly("org.apache.spark:spark-core_2.12:3.5.1")
19-
runtimeOnly("org.apache.spark:spark-hive_2.12:3.5.1")
18+
runtimeOnly(libs.spark.core)
19+
runtimeOnly(libs.spark.hive)
2020
}
2121

2222
tasks.jar {

gradle.properties

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -7,24 +7,6 @@ org.gradle.parallel=true
77
# Build cache can be disabled with --no-build-cache option
88
org.gradle.caching=true
99

10-
#plugins
11-
com.google.protobuf.version=0.8.10
12-
org.jetbrains.gradle.plugin.idea-ext.version=0.5
13-
kotlin.version=1.5.31
14-
com.github.vlsi.vlsi-release-plugins.version=1.74
15-
16-
# library version
17-
antlr.version=4.13.1
18-
calcite.version=1.40.0
19-
guava.version=32.1.3-jre
20-
immutables.version=2.10.1
21-
jackson.version=2.16.1
22-
junit.version=5.8.1
23-
protobuf.version=3.25.5
24-
slf4j.version=2.0.13
25-
sparkbundle.version=3.4
26-
spark.version=3.4.2
27-
2810
#version that is going to be updated automatically by releases
2911
version = 0.63.0
3012

gradle/libs.versions.toml

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
[versions]
2+
antlr = "4.13.1"
3+
calcite = "1.40.0"
4+
commons-lang3 = "[3.18.0,)"
5+
graal = "22.1.0"
6+
graal-plugin = "0.10.0"
7+
gradle-extensions = "1.74"
8+
guava = "32.1.3-jre"
9+
httpclient5 = "5.4.4"
10+
immutables = "2.10.1"
11+
jackson = "2.16.1"
12+
jreleaser = "1.18.0"
13+
json-smart = "2.5.2"
14+
jspecify = "1.0.0"
15+
junit = "5.8.1"
16+
picocli = "4.7.5"
17+
protobuf-plugin = "0.9.4"
18+
protobuf = "3.25.5"
19+
reflections = "0.9.12"
20+
scala-library = "2.12.16"
21+
scalatest = "3.2.18"
22+
scalatestplus-junit5 = "3.2.18.0"
23+
shadow = "8.3.8"
24+
slf4j = "2.0.13"
25+
spark = "3.4.2"
26+
spotless = "7.1.0"
27+
28+
[libraries]
29+
antlr4 = { module = "org.antlr:antlr4", version.ref = "antlr" }
30+
antlr4-runtime = { module = "org.antlr:antlr4-runtime" , version.ref = "antlr" }
31+
calcite-babel = { module = "org.apache.calcite:calcite-babel", version.ref = "calcite" }
32+
calcite-core = { module = "org.apache.calcite:calcite-core", version.ref = "calcite" }
33+
calcite-plus = { module = "org.apache.calcite:calcite-plus", version.ref = "calcite" }
34+
calcite-server = { module = "org.apache.calcite:calcite-server", version.ref = "calcite" }
35+
commons-lang3 = { module = "org.apache.commons:commons-lang3", version.ref = "commons-lang3" }
36+
graal-sdk = { module = "org.graalvm.sdk:graal-sdk", version.ref = "graal" }
37+
guava = { module = "com.google.guava:guava", version.ref = "guava" }
38+
httpclient5 = { module = "org.apache.httpcomponents.client5:httpclient5", version.ref = "httpclient5" }
39+
immutables-value = { module = "org.immutables:value", version.ref = "immutables" }
40+
immutables-annotations = { module = "org.immutables:value-annotations", version.ref = "immutables" }
41+
jackson-bom = { module = "com.fasterxml.jackson:jackson-bom", version.ref = "jackson" }
42+
jackson-databind = { module = "com.fasterxml.jackson.core:jackson-databind" }
43+
jackson-annotations = { module = "com.fasterxml.jackson.core:jackson-annotations" }
44+
jackson-datatype-jdk8 = { module = "com.fasterxml.jackson.datatype:jackson-datatype-jdk8" }
45+
jackson-dataformat-yaml = { module = "com.fasterxml.jackson.dataformat:jackson-dataformat-yaml" }
46+
json-smart = { module = "net.minidev:json-smart", version.ref = "json-smart" }
47+
jspecify = { module = "org.jspecify:jspecify", version.ref = "jspecify" }
48+
junit-bom = { module = "org.junit:junit-bom", version.ref = "junit" }
49+
junit-jupiter = { module = "org.junit.jupiter:junit-jupiter" }
50+
junit-jupiter-api = { module = "org.junit.jupiter:junit-jupiter-api" }
51+
junit-jupiter-engine = { module = "org.junit.jupiter:junit-jupiter-engine" }
52+
junit-platform-launcher = { module = "org.junit.platform:junit-platform-launcher" }
53+
junit-platform-engine = { module = "org.junit.platform:junit-platform-engine" }
54+
picocli = { module = "info.picocli:picocli", version.ref = "picocli" }
55+
picocli-codegen = { module = "info.picocli:picocli-codegen", version.ref = "picocli" }
56+
protobuf-java = { module = "com.google.protobuf:protobuf-java", version.ref = "protobuf" }
57+
protobuf-java-util = { module = "com.google.protobuf:protobuf-java-util", version.ref = "protobuf" }
58+
protoc = { module = "com.google.protobuf:protoc", version.ref = "protobuf" }
59+
reflections = { module = "org.reflections:reflections", version.ref = "reflections"}
60+
scala-library = { module = "org.scala-lang:scala-library", version.ref = "scala-library" }
61+
scalatest = { module = "org.scalatest:scalatest_2.12", version.ref = "scalatest" }
62+
scalatestplus-junit5 = { module = "org.scalatestplus:junit-5-10_2.12", version.ref = "scalatestplus-junit5" }
63+
slf4j-api = { module = "org.slf4j:slf4j-api", version.ref = "slf4j" }
64+
slf4j-jdk14 = { module = "org.slf4j:slf4j-jdk14", version.ref = "slf4j" }
65+
spark-catalyst = { module = "org.apache.spark:spark-catalyst_2.12", version.ref = "spark" }
66+
spark-core = { module = "org.apache.spark:spark-core_2.12", version.ref = "spark" }
67+
spark-hive = { module = "org.apache.spark:spark-hive_2.12", version.ref = "spark" }
68+
spark-sql = { module = "org.apache.spark:spark-sql_2.12", version.ref = "spark" }
69+
70+
[bundles]
71+
jackson = [ "jackson-databind", "jackson-annotations", "jackson-datatype-jdk8", "jackson-dataformat-yaml" ]
72+
73+
[plugins]
74+
graal = { id = "com.palantir.graal", version.ref = "graal-plugin" }
75+
gradle-extensions = { id = "com.github.vlsi.gradle-extensions", version.ref = "gradle-extensions" }
76+
jreleaser = { id = "org.jreleaser", version.ref = "jreleaser" }
77+
protobuf = { id = "com.google.protobuf", version.ref = "protobuf-plugin" }
78+
shadow = { id = "com.gradleup.shadow", version.ref = "shadow" }
79+
spotless = { id = "com.diffplug.spotless", version.ref = "spotless" }

isthmus-cli/build.gradle.kts

Lines changed: 15 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ import java.nio.charset.StandardCharsets
33
plugins {
44
id("java")
55
id("idea")
6-
id("com.palantir.graal") version "0.10.0"
7-
id("com.diffplug.spotless") version "7.1.0"
6+
alias(libs.plugins.graal)
7+
alias(libs.plugins.spotless)
88
id("substrait.java-conventions")
99
}
1010

@@ -16,39 +16,30 @@ java {
1616

1717
configurations { runtimeClasspath { resolutionStrategy.activateDependencyLocking() } }
1818

19-
val CALCITE_VERSION = properties.get("calcite.version")
20-
val GUAVA_VERSION = properties.get("guava.version")
21-
val IMMUTABLES_VERSION = properties.get("immutables.version")
22-
val JUNIT_VERSION = properties.get("junit.version")
23-
val PROTOBUF_VERSION = properties.get("protobuf.version")
24-
val SLF4J_VERSION = properties.get("slf4j.version")
25-
2619
dependencies {
2720
implementation(project(":core"))
2821
implementation(project(":isthmus"))
29-
testImplementation(platform("org.junit:junit-bom:${JUNIT_VERSION}"))
30-
testImplementation("org.junit.jupiter:junit-jupiter")
31-
testRuntimeOnly("org.junit.platform:junit-platform-launcher")
32-
implementation("org.reflections:reflections:0.9.12")
33-
implementation("com.google.guava:guava:${GUAVA_VERSION}")
34-
implementation("org.graalvm.sdk:graal-sdk:22.1.0")
35-
implementation("info.picocli:picocli:4.7.5")
36-
annotationProcessor("info.picocli:picocli-codegen:4.7.5")
37-
implementation("com.google.protobuf:protobuf-java-util:${PROTOBUF_VERSION}") {
22+
testImplementation(platform(libs.junit.bom))
23+
testImplementation(libs.junit.jupiter)
24+
testRuntimeOnly(libs.junit.platform.launcher)
25+
implementation(libs.reflections)
26+
implementation(libs.guava)
27+
implementation(libs.graal.sdk)
28+
implementation(libs.picocli)
29+
annotationProcessor(libs.picocli.codegen)
30+
implementation(libs.protobuf.java.util) {
3831
exclude("com.google.guava", "guava")
3932
.because("Brings in Guava for Android, which we don't want (and breaks multimaps).")
4033
}
41-
implementation("org.immutables:value-annotations:${IMMUTABLES_VERSION}")
42-
annotationProcessor("org.immutables:value:${IMMUTABLES_VERSION}")
43-
testImplementation("org.apache.calcite:calcite-plus:${CALCITE_VERSION}") {
34+
annotationProcessor(libs.immutables.value)
35+
implementation(libs.immutables.annotations)
36+
testImplementation(libs.calcite.plus) {
4437
exclude(group = "commons-lang", module = "commons-lang")
4538
.because(
4639
"calcite-core brings in commons-lang:commons-lang:2.4 which has a security vulnerability"
4740
)
4841
}
49-
annotationProcessor("com.github.bsideup.jabel:jabel-javac-plugin:0.4.2")
50-
compileOnly("com.github.bsideup.jabel:jabel-javac-plugin:0.4.2")
51-
runtimeOnly("org.slf4j:slf4j-jdk14:${SLF4J_VERSION}")
42+
runtimeOnly(libs.slf4j.jdk14)
5243
}
5344

5445
sourceSets { main { java.srcDir("build/generated/sources/version/") } }

0 commit comments

Comments
 (0)