Skip to content

Commit da9c92f

Browse files
authored
migrate build to version catalog (ExpediaGroup#1630)
* migrate build to version catalog [Version Catalog](https://docs.gradle.org/current/userguide/platforms.html#sub:version-catalog) is a preferred mechanism for declaring and sharing project dependencies. Once dependencies are defined in the `libs.versions.toml` file, they can be imported using type safe accessors. Dependent projects (i.e. `examples`, Gradle plugin integration tests and federation compatibility) can also import same version catalog which further simplifies version management. * configure examples to use version catalog * ktlint fix
1 parent 50746d1 commit da9c92f

File tree

29 files changed

+257
-274
lines changed

29 files changed

+257
-274
lines changed

build.gradle.kts

Lines changed: 12 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -37,15 +37,7 @@ allprojects {
3737
}
3838

3939
subprojects {
40-
val kotlinxCoroutinesVersion: String by project
4140
val kotlinJvmVersion: String by project
42-
val kotlinVersion: String by project
43-
val junitVersion: String by project
44-
val mockkVersion: String by project
45-
46-
val detektVersion: String by project
47-
val ktlintVersion: String by project
48-
val jacocoVersion: String by project
4941

5042
val currentProject = this
5143

@@ -70,14 +62,14 @@ subprojects {
7062
dependsOn(jacocoTestCoverageVerification)
7163
}
7264
detekt {
73-
toolVersion = detektVersion
65+
toolVersion = rootProject.project.libs.versions.detekt.get()
7466
config = files("${rootProject.projectDir}/detekt.yml")
7567
}
7668
ktlint {
77-
version.set(ktlintVersion)
69+
version.set(rootProject.project.libs.versions.ktlint.core.get())
7870
}
7971
jacoco {
80-
toolVersion = jacocoVersion
72+
toolVersion = rootProject.project.libs.versions.jacoco.get()
8173
}
8274
jar {
8375
manifest {
@@ -178,15 +170,16 @@ subprojects {
178170
}
179171
}
180172

173+
// typesafe accessors to version catalog do not work in the subprojects/allprojects block, need to use rootProject.project
181174
dependencies {
182-
implementation(kotlin("stdlib", kotlinVersion))
183-
implementation(kotlin("reflect", kotlinVersion))
184-
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-jdk8:$kotlinxCoroutinesVersion")
185-
testImplementation(kotlin("test", kotlinVersion))
186-
testImplementation(kotlin("test-junit5", kotlinVersion))
187-
testImplementation("org.junit.jupiter:junit-jupiter-api:$junitVersion")
188-
testImplementation("org.junit.jupiter:junit-jupiter-engine:$junitVersion")
189-
testImplementation("io.mockk:mockk:$mockkVersion")
175+
implementation(rootProject.project.libs.kotlin.stdlib)
176+
implementation(rootProject.project.libs.kotlin.reflect)
177+
implementation(rootProject.project.libs.kotlinx.coroutines.jdk8)
178+
testImplementation(rootProject.project.libs.kotlin.test)
179+
testImplementation(rootProject.project.libs.kotlin.junit.test)
180+
testImplementation(rootProject.project.libs.junit.api)
181+
testImplementation(rootProject.project.libs.junit.engine)
182+
testImplementation(rootProject.project.libs.mockk)
190183
}
191184
}
192185

clients/graphql-kotlin-client-jackson/build.gradle.kts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
description = "GraphQL client serializer based on Jackson"
22

3-
val jacksonVersion: String by project
4-
53
dependencies {
64
api(project(path = ":graphql-kotlin-client"))
7-
api("com.fasterxml.jackson.module:jackson-module-kotlin:$jacksonVersion")
5+
api(libs.jackson)
86
}
97

108
tasks {

clients/graphql-kotlin-client-serialization/build.gradle.kts

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,10 @@ plugins {
44
kotlin("plugin.serialization")
55
}
66

7-
val kotlinxCoroutinesVersion: String by project
8-
val kotlinxSerializationVersion: String by project
9-
107
dependencies {
118
api(project(path = ":graphql-kotlin-client"))
12-
api("org.jetbrains.kotlinx:kotlinx-coroutines-core:$kotlinxCoroutinesVersion")
13-
api("org.jetbrains.kotlinx:kotlinx-serialization-json:$kotlinxSerializationVersion")
9+
api(libs.kotlinx.coroutines.core)
10+
api(libs.kotlinx.serialization.json)
1411
}
1512

1613
tasks {
Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
description = "A lightweight typesafe GraphQL HTTP Client"
22

3-
val kotlinxCoroutinesVersion: String by project
4-
53
dependencies {
6-
api("org.jetbrains.kotlinx:kotlinx-coroutines-core:$kotlinxCoroutinesVersion")
4+
api(libs.kotlinx.coroutines.core)
75
}

clients/graphql-kotlin-ktor-client/build.gradle.kts

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,15 @@ plugins {
44
kotlin("plugin.serialization")
55
}
66

7-
val ktorVersion: String by project
8-
val wireMockVersion: String by project
9-
107
dependencies {
118
api(project(path = ":graphql-kotlin-client"))
129
api(project(path = ":graphql-kotlin-client-serialization"))
13-
api("io.ktor:ktor-client-cio:$ktorVersion")
14-
api("io.ktor:ktor-client-serialization:$ktorVersion")
10+
api(libs.ktor.client.cio)
11+
api(libs.ktor.client.serialization)
1512
testImplementation(project(path = ":graphql-kotlin-client-jackson"))
16-
testImplementation("io.ktor:ktor-client-okhttp:$ktorVersion")
17-
testImplementation("io.ktor:ktor-client-logging:$ktorVersion")
18-
testImplementation("com.github.tomakehurst:wiremock-jre8:$wireMockVersion")
13+
testImplementation(libs.ktor.client.logging)
14+
testImplementation(libs.ktor.client.okhttp)
15+
testImplementation(libs.wiremock.jre8)
1916
}
2017

2118
tasks {

clients/graphql-kotlin-spring-client/build.gradle.kts

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,14 @@ plugins {
44
kotlin("plugin.serialization")
55
}
66

7-
val kotlinxCoroutinesVersion: String by project
8-
val springVersion: String by project
9-
val springBootVersion: String by project
10-
val wireMockVersion: String by project
11-
127
dependencies {
138
api(project(path = ":graphql-kotlin-client"))
149
api(project(path = ":graphql-kotlin-client-jackson"))
15-
api("org.jetbrains.kotlinx:kotlinx-coroutines-reactor:$kotlinxCoroutinesVersion")
16-
api("org.springframework:spring-webflux:$springVersion")
17-
api("org.springframework.boot:spring-boot-starter-reactor-netty:$springBootVersion")
10+
api(libs.kotlinx.coroutines.reactor)
11+
api(libs.spring.webflux)
12+
api(libs.spring.boot.netty)
1813
testImplementation(project(path = ":graphql-kotlin-client-serialization"))
19-
testImplementation("com.github.tomakehurst:wiremock-jre8:$wireMockVersion")
14+
testImplementation(libs.wiremock.jre8)
2015
}
2116

2217
tasks {

examples/build.gradle.kts

Lines changed: 9 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -35,26 +35,18 @@ subprojects {
3535
this.ext[key.toString()] = value
3636
}
3737

38-
val icuVersion: String by project
39-
val junitVersion: String by project
40-
val kotlinVersion: String by project
41-
val kotlinxCoroutinesVersion: String by project
42-
43-
val detektVersion: String by project
44-
val ktlintVersion: String by project
45-
4638
apply(plugin = "kotlin")
4739
apply(plugin = "io.gitlab.arturbosch.detekt")
4840
apply(plugin = "org.jlleitschuh.gradle.ktlint")
4941

5042
dependencies {
51-
implementation(kotlin("stdlib", kotlinVersion))
52-
implementation(kotlin("reflect", kotlinVersion))
53-
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-jdk8:$kotlinxCoroutinesVersion")
54-
implementation("com.ibm.icu:icu4j:$icuVersion")
55-
testImplementation(kotlin("test-junit5", kotlinVersion))
56-
testImplementation("org.junit.jupiter:junit-jupiter-api:$junitVersion")
57-
testImplementation("org.junit.jupiter:junit-jupiter-engine:$junitVersion")
43+
implementation(rootProject.project.libs.kotlin.stdlib)
44+
implementation(rootProject.project.libs.kotlin.reflect)
45+
implementation(rootProject.project.libs.kotlinx.coroutines.jdk8)
46+
implementation(rootProject.project.libs.icu)
47+
testImplementation(rootProject.project.libs.kotlin.junit.test)
48+
testImplementation(rootProject.project.libs.junit.api)
49+
testImplementation(rootProject.project.libs.junit.engine)
5850
}
5951

6052
tasks.withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile> {
@@ -66,11 +58,11 @@ subprojects {
6658

6759
tasks {
6860
detekt {
69-
toolVersion = detektVersion
61+
toolVersion = rootProject.project.libs.versions.detekt.get()
7062
config = files(File(rootDir.parent, "detekt.yml").absolutePath)
7163
}
7264
ktlint {
73-
version.set(ktlintVersion)
65+
version.set(rootProject.project.libs.versions.ktlint.core.get())
7466
}
7567
jar {
7668
enabled = false

examples/client/build.gradle.kts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,8 @@ import com.github.tomakehurst.wiremock.standalone.WireMockServerRunner
22
import java.net.ServerSocket
33

44
buildscript {
5-
// cannot access project at this time
6-
val wireMockVersion: String = "2.26.2"
75
dependencies {
8-
classpath("com.github.tomakehurst:wiremock-jre8-standalone:$wireMockVersion")
6+
classpath(libs.wiremock.standalone)
97
}
108
}
119

examples/client/gradle-client/build.gradle.kts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ plugins {
1313
val ktorVersion: String by project
1414
dependencies {
1515
implementation("com.expediagroup", "graphql-kotlin-ktor-client")
16-
implementation("io.ktor:ktor-client-okhttp:$ktorVersion")
17-
implementation("io.ktor:ktor-client-logging-jvm:$ktorVersion")
16+
implementation(libs.ktor.client.okhttp)
17+
implementation(libs.ktor.client.jvm.logging)
1818
}
1919

2020
application {

examples/client/maven-client/build.gradle.kts

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,23 +2,19 @@ import java.time.Duration
22

33
description = "Example usage of Maven plugin to generate GraphQL Kotlin Client"
44

5-
val kotlinJvmVersion: String by project
6-
val kotlinVersion: String by project
7-
val kotlinxCoroutinesVersion: String by project
8-
val reactorVersion: String by project
9-
105
dependencies {
116
implementation("com.expediagroup", "graphql-kotlin-spring-client")
127
}
138

149
tasks {
10+
val kotlinJvmVersion: String by project
1511
/* Gradle is used to invoke maven wrapper */
1612
val mavenEnvironmentVariables = mapOf(
1713
"graphqlKotlinVersion" to project.version,
1814
"kotlinJvmTarget" to kotlinJvmVersion,
19-
"kotlinVersion" to kotlinVersion,
20-
"kotlinxCoroutinesVersion" to kotlinxCoroutinesVersion,
21-
"reactorVersion" to reactorVersion
15+
"kotlinVersion" to libs.versions.kotlin.get(),
16+
"kotlinxCoroutinesVersion" to libs.versions.kotlinx.coroutines.get(),
17+
"reactorVersion" to libs.versions.reactor.core.get()
2218
)
2319
val wireMockServerPort: Int? = ext.get("wireMockServerPort") as? Int
2420
val mavenBuild by register("mavenBuild") {

examples/federation/products-subgraph/build.gradle.kts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,9 @@ plugins {
66
id("com.expediagroup.graphql")
77
}
88

9-
val springBootVersion: String by project
109
dependencies {
1110
implementation("com.expediagroup", "graphql-kotlin-spring-server")
12-
testImplementation("org.springframework.boot", "spring-boot-starter-test", springBootVersion)
11+
testImplementation(libs.spring.boot.test)
1312

1413
graphqlSDL("com.expediagroup", "graphql-kotlin-federated-hooks-provider")
1514
}

examples/federation/reviews-subgraph/build.gradle.kts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,9 @@ plugins {
66
id("com.expediagroup.graphql")
77
}
88

9-
val springBootVersion: String by project
109
dependencies {
1110
implementation("com.expediagroup", "graphql-kotlin-spring-server")
12-
testImplementation("org.springframework.boot", "spring-boot-starter-test", springBootVersion)
11+
testImplementation(libs.spring.boot.test)
1312

1413
graphqlSDL("com.expediagroup", "graphql-kotlin-federated-hooks-provider")
1514
}

examples/server/ktor-server/build.gradle.kts

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,12 @@ application {
99
mainClass.set("io.ktor.server.netty.EngineMain")
1010
}
1111

12-
val kotlinxCoroutinesVersion: String by project
13-
val ktorVersion: String by project
14-
val logbackVersion: String by project
15-
1612
dependencies {
1713
implementation("com.expediagroup", "graphql-kotlin-server")
18-
implementation("io.ktor", "ktor-server-core", ktorVersion)
19-
implementation("io.ktor", "ktor-server-netty", ktorVersion)
20-
implementation("ch.qos.logback", "logback-classic", logbackVersion)
21-
implementation("org.jetbrains.kotlinx", "kotlinx-coroutines-jdk8", kotlinxCoroutinesVersion)
14+
implementation(libs.ktor.server.core)
15+
implementation(libs.ktor.server.netty)
16+
implementation(libs.logback)
17+
implementation(libs.kotlinx.coroutines.jdk8)
2218
}
2319

2420
graphql {

examples/server/ktor-server/gradle.properties

Lines changed: 0 additions & 1 deletion
This file was deleted.

examples/server/spring-server/build.gradle.kts

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,12 @@ plugins {
66
id("com.expediagroup.graphql")
77
}
88

9-
val springBootVersion: String by project
10-
val reactorVersion: String by project
11-
129
dependencies {
1310
implementation("com.expediagroup", "graphql-kotlin-spring-server")
1411
implementation("com.expediagroup", "graphql-kotlin-hooks-provider")
15-
implementation("org.springframework.boot", "spring-boot-starter-validation", springBootVersion)
16-
testImplementation("org.springframework.boot:spring-boot-starter-test:$springBootVersion")
17-
testImplementation("io.projectreactor:reactor-test:$reactorVersion")
12+
implementation(libs.spring.boot.validation)
13+
testImplementation(libs.spring.boot.test)
14+
testImplementation(libs.reactor.test)
1815
}
1916

2017
graphql {

examples/settings.gradle.kts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,18 @@
1+
dependencyResolutionManagement {
2+
versionCatalogs {
3+
create("libs") {
4+
from(files("../gradle/libs.versions.toml"))
5+
6+
// examples specific libs
7+
library("ktor-client-jvm-logging", "io.ktor", "ktor-client-logging-jvm").versionRef("ktor")
8+
library("ktor-server-core", "io.ktor", "ktor-server-core").versionRef("ktor")
9+
library("ktor-server-netty", "io.ktor", "ktor-server-netty").versionRef("ktor")
10+
library("logback", "ch.qos.logback", "logback-classic").version("1.2.1")
11+
library("spring-boot-validation", "org.springframework.boot", "spring-boot-starter-validation").versionRef("spring-boot")
12+
}
13+
}
14+
}
15+
116
pluginManagement {
217
val properties = java.util.Properties()
318
properties.load(File(rootDir.parent, "gradle.properties").inputStream())

executions/graphql-kotlin-automatic-persisted-queries/build.gradle.kts

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,7 @@
11
description = "Automatic Persisted Queries"
22

3-
val junitVersion: String by project
4-
val graphQLJavaVersion: String by project
5-
63
dependencies {
7-
api("com.graphql-java:graphql-java:$graphQLJavaVersion")
8-
testImplementation("org.junit.jupiter:junit-jupiter-api:$junitVersion")
9-
testImplementation("org.junit.jupiter:junit-jupiter-engine:$junitVersion")
4+
api(libs.graphql.java)
105
}
116

127
tasks {

executions/graphql-kotlin-dataloader-instrumentation/build.gradle.kts

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,12 @@
11
description = "Data Loader Instrumentations"
22

3-
val junitVersion: String by project
4-
val graphQLJavaVersion: String by project
5-
val reactorVersion: String by project
6-
val reactorExtensionsVersion: String by project
7-
83
dependencies {
94
api(project(path = ":graphql-kotlin-dataloader"))
10-
api("com.graphql-java:graphql-java:$graphQLJavaVersion") {
5+
api(libs.graphql.java) {
116
exclude(group = "com.graphql-java", module = "java-dataloader")
127
}
13-
testImplementation("io.projectreactor.kotlin:reactor-kotlin-extensions:$reactorExtensionsVersion")
14-
testImplementation("io.projectreactor:reactor-core:$reactorVersion")
15-
testImplementation("org.junit.jupiter:junit-jupiter-api:$junitVersion")
16-
testImplementation("org.junit.jupiter:junit-jupiter-engine:$junitVersion")
8+
testImplementation(libs.reactor.core)
9+
testImplementation(libs.reactor.extensions)
1710
}
1811

1912
tasks {

executions/graphql-kotlin-dataloader/build.gradle.kts

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,9 @@
11
description = "Graphql Kotlin Data Loader"
22

3-
val junitVersion: String by project
4-
val graphQLJavaDataLoaderVersion: String by project
5-
val reactorVersion: String by project
6-
val reactorExtensionsVersion: String by project
7-
83
dependencies {
9-
api("com.graphql-java:java-dataloader:$graphQLJavaDataLoaderVersion")
10-
testImplementation("io.projectreactor.kotlin:reactor-kotlin-extensions:$reactorExtensionsVersion")
11-
testImplementation("io.projectreactor:reactor-core:$reactorVersion")
12-
testImplementation("org.junit.jupiter:junit-jupiter-api:$junitVersion")
13-
testImplementation("org.junit.jupiter:junit-jupiter-engine:$junitVersion")
4+
api(libs.dataloader)
5+
testImplementation(libs.reactor.core)
6+
testImplementation(libs.reactor.extensions)
147
}
158

169
tasks {

0 commit comments

Comments
 (0)