Skip to content

Commit b65b9cb

Browse files
authored
chore: use a version catalog (#1061)
1 parent 72e71ce commit b65b9cb

File tree

21 files changed

+258
-213
lines changed

21 files changed

+258
-213
lines changed

.builder/actions/set_upstream_versions.py

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,10 @@ def run(self, env):
2828

2929
print("discovered dependency versions: {}".format(discovered_versions))
3030
if "smithy-kotlin" in discovered_versions:
31-
_replace_gradle_property(proj, "smithyKotlinVersion", discovered_versions["smithy-kotlin"])
31+
_replace_version_catalog_version(proj, "smithy-kotlin-version", discovered_versions["smithy-kotlin"])
3232

3333
if "aws-crt-kotlin" in discovered_versions:
34-
_replace_gradle_property(proj, "crtKotlinVersion", discovered_versions["aws-crt-kotlin"])
34+
_replace_gradle_property(proj, "crt-kotlin-version", discovered_versions["aws-crt-kotlin"])
3535

3636

3737
def _replace_gradle_property(proj, prop_name, new_value):
@@ -53,6 +53,24 @@ def _replace_gradle_property(proj, prop_name, new_value):
5353
else:
5454
f.write(line)
5555

56+
def _replace_version_catalog_version(proj, prop_name, new_value):
57+
"""
58+
Replaces the named version catalog version with the value if the version exists in `libs.versions.toml`
59+
"""
60+
version_catalog = os.path.join(proj.path, "gradle", "libs.versions.toml")
61+
62+
with open(version_catalog, "r") as f:
63+
lines = f.readlines()
64+
65+
with open(version_catalog, "w") as f:
66+
for line in lines:
67+
needle = "{} =".format(prop_name)
68+
if needle in line:
69+
replacement = "{} = \"{}\"\n".format(prop_name, new_value)
70+
f.write(replacement)
71+
print("replaced {} with {}".format(line.strip(), replacement.strip()))
72+
else:
73+
f.write(line)
5674

5775
def _get_dependency_version(env, dep):
5876
"""

aws-runtime/aws-config/build.gradle.kts

Lines changed: 21 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -12,74 +12,53 @@ plugins {
1212
description = "Support for AWS configuration"
1313
extra["moduleName"] = "aws.sdk.kotlin.runtime.config"
1414

15-
val smithyKotlinVersion: String by project
16-
val kotestVersion: String by project
17-
val coroutinesVersion: String by project
18-
val atomicFuVersion: String by project
19-
20-
buildscript {
21-
val atomicFuVersion: String by project
22-
23-
repositories {
24-
mavenCentral()
25-
}
26-
27-
dependencies {
28-
classpath("org.jetbrains.kotlinx:atomicfu-gradle-plugin:$atomicFuVersion")
29-
}
30-
}
3115
apply(plugin = "kotlinx-atomicfu")
3216

3317
kotlin {
3418
sourceSets {
3519
commonMain {
3620
dependencies {
3721
api(project(":aws-runtime:aws-core"))
38-
api("aws.smithy.kotlin:aws-credentials:$smithyKotlinVersion")
39-
implementation("aws.smithy.kotlin:http:$smithyKotlinVersion")
40-
implementation("aws.smithy.kotlin:http-auth:$smithyKotlinVersion")
41-
implementation("aws.smithy.kotlin:telemetry-api:$smithyKotlinVersion")
42-
implementation("aws.smithy.kotlin:http-client-engine-default:$smithyKotlinVersion")
22+
api(libs.smithy.kotlin.aws.credentials)
23+
implementation(libs.smithy.kotlin.http)
24+
implementation(libs.smithy.kotlin.http.auth)
25+
implementation(libs.smithy.kotlin.telemetry.api)
26+
implementation(libs.smithy.kotlin.http.client.engine.default)
4327
implementation(project(":aws-runtime:aws-http"))
4428

4529
// parsing common JSON credentials responses
46-
implementation("aws.smithy.kotlin:serde-json:$smithyKotlinVersion")
30+
implementation(libs.smithy.kotlin.serde.json)
4731

48-
// additional dependencies required by generated sts provider
49-
implementation("aws.smithy.kotlin:http-client:$smithyKotlinVersion")
50-
implementation("aws.smithy.kotlin:serde-form-url:$smithyKotlinVersion")
51-
implementation("aws.smithy.kotlin:serde-xml:$smithyKotlinVersion")
52-
implementation("aws.smithy.kotlin:aws-xml-protocols:$smithyKotlinVersion")
53-
implementation("aws.smithy.kotlin:aws-protocol-core:$smithyKotlinVersion")
32+
// additional dependencies required by generated clients
33+
implementation(libs.bundles.smithy.kotlin.service.client)
5434
implementation(project(":aws-runtime:aws-endpoint"))
55-
implementation("aws.smithy.kotlin:aws-signing-common:$smithyKotlinVersion")
56-
implementation("aws.smithy.kotlin:aws-signing-default:$smithyKotlinVersion")
57-
implementation("aws.smithy.kotlin:http-auth-aws:$smithyKotlinVersion")
58-
implementation("aws.smithy.kotlin:telemetry-defaults:$smithyKotlinVersion")
35+
36+
// additional dependencies required by generated sts provider
37+
implementation(libs.smithy.kotlin.serde.xml)
38+
implementation(libs.smithy.kotlin.serde.formurl)
39+
implementation(libs.smithy.kotlin.aws.xml.protocols)
5940

6041
// additional dependencies required by generated sso provider(s)
61-
implementation("aws.smithy.kotlin:aws-json-protocols:$smithyKotlinVersion")
42+
implementation(libs.smithy.kotlin.aws.json.protocols)
6243

6344
// atomics
64-
implementation("org.jetbrains.kotlinx:atomicfu:$atomicFuVersion")
45+
implementation(libs.kotlinx.atomicfu)
6546

6647
// coroutines
67-
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:$coroutinesVersion")
48+
implementation(libs.kotlinx.coroutines.core)
6849
}
6950
}
7051
commonTest {
7152
dependencies {
72-
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-test:$coroutinesVersion")
73-
implementation("aws.smithy.kotlin:http-test:$smithyKotlinVersion")
74-
val kotlinxSerializationVersion: String by project
75-
val mockkVersion: String by project
76-
implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:$kotlinxSerializationVersion")
77-
implementation("io.mockk:mockk:$mockkVersion")
53+
implementation(libs.kotlinx.coroutines.test)
54+
implementation(libs.smithy.kotlin.http.test)
55+
implementation(libs.kotlinx.serialization.json)
56+
implementation(libs.mockk)
7857
}
7958
}
8059
jvmTest {
8160
dependencies {
82-
implementation("io.kotest:kotest-runner-junit5:$kotestVersion")
61+
implementation(libs.kotest.runner.junit5)
8362
}
8463
}
8564

aws-runtime/aws-core/build.gradle.kts

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,21 +7,18 @@ description = "AWS client runtime core"
77
extra["displayName"] = "AWS :: SDK :: Kotlin :: Client Runtime"
88
extra["moduleName"] = "aws.sdk.kotlin.runtime"
99

10-
val smithyKotlinVersion: String by project
11-
val coroutinesVersion: String by project
12-
1310
kotlin {
1411
sourceSets {
1512
commonMain {
1613
dependencies {
17-
api("aws.smithy.kotlin:runtime-core:$smithyKotlinVersion")
18-
api("aws.smithy.kotlin:smithy-client:$smithyKotlinVersion")
14+
api(libs.smithy.kotlin.runtime.core)
15+
api(libs.smithy.kotlin.smithy.client)
1916
}
2017
}
2118

2219
commonTest {
2320
dependencies {
24-
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-test:$coroutinesVersion")
21+
implementation(libs.kotlinx.coroutines.test)
2522
}
2623
}
2724

aws-runtime/aws-endpoint/build.gradle.kts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,14 @@ description = "AWS Endpoint Support"
77
extra["displayName"] = "AWS :: SDK :: Kotlin :: Endpoint"
88
extra["moduleName"] = "aws.sdk.kotlin.runtime.endpoint"
99

10-
val smithyKotlinVersion: String by project
11-
1210
kotlin {
1311
sourceSets {
1412
commonMain {
1513
dependencies {
1614
implementation(project(":aws-runtime:aws-core"))
1715
// exposes Endpoint
18-
api("aws.smithy.kotlin:http-client:$smithyKotlinVersion")
19-
api("aws.smithy.kotlin:aws-signing-common:$smithyKotlinVersion")
16+
api(libs.smithy.kotlin.http.client)
17+
api(libs.smithy.kotlin.aws.signing.common)
2018
}
2119
}
2220

aws-runtime/aws-http/build.gradle.kts

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,24 +7,21 @@ description = "HTTP core for AWS service clients"
77
extra["displayName"] = "AWS :: SDK :: Kotlin :: HTTP"
88
extra["moduleName"] = "aws.sdk.kotlin.runtime.http"
99

10-
val coroutinesVersion: String by project
11-
val smithyKotlinVersion: String by project
12-
1310
kotlin {
1411
sourceSets {
1512
commonMain {
1613
dependencies {
1714
api(project(":aws-runtime:aws-core"))
1815
api(project(":aws-runtime:aws-endpoint"))
19-
api("aws.smithy.kotlin:aws-signing-common:$smithyKotlinVersion")
20-
api("aws.smithy.kotlin:http-client:$smithyKotlinVersion")
16+
api(libs.smithy.kotlin.aws.signing.common)
17+
api(libs.smithy.kotlin.http.client)
2118
}
2219
}
2320

2421
commonTest {
2522
dependencies {
26-
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-test:$coroutinesVersion")
27-
implementation("aws.smithy.kotlin:http-test:$smithyKotlinVersion")
23+
implementation(libs.kotlinx.coroutines.test)
24+
api(libs.smithy.kotlin.http.test)
2825
}
2926
}
3027

aws-runtime/build.gradle.kts

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,17 @@ import aws.sdk.kotlin.gradle.kmp.*
77

88
description = "AWS client runtime support for generated service clients"
99

10+
@Suppress("DSL_SCOPE_VIOLATION") // TODO: Remove once https://youtrack.jetbrains.com/issue/KTIJ-19369 is fixed
1011
plugins {
11-
id("org.jetbrains.dokka")
12-
id("org.jetbrains.kotlinx.binary-compatibility-validator") version "0.12.1"
12+
alias(libs.plugins.dokka)
13+
alias(libs.plugins.kotlinx.binary.compatibility.validator)
1314
jacoco
1415
}
1516

1617
val sdkVersion: String by project
1718

18-
val kotestVersion: String by project
19-
val slf4jVersion: String by project
19+
// capture locally - scope issue with custom KMP plugin
20+
val libraries = libs
2021

2122
subprojects {
2223
if (!needsKmpConfigured) return@subprojects
@@ -39,14 +40,14 @@ subprojects {
3940

4041
named("commonTest") {
4142
dependencies {
42-
implementation("io.kotest:kotest-assertions-core:$kotestVersion")
43+
implementation(libraries.kotest.assertions.core)
4344
}
4445
}
4546

4647
named("jvmTest") {
4748
dependencies {
48-
implementation("io.kotest:kotest-assertions-core-jvm:$kotestVersion")
49-
implementation("org.slf4j:slf4j-simple:$slf4jVersion")
49+
implementation(libraries.kotest.assertions.core.jvm)
50+
implementation(libraries.slf4j.simple)
5051
}
5152
}
5253
}

build.gradle.kts

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@ import aws.sdk.kotlin.gradle.util.typedProp
88
import java.net.URL
99

1010
buildscript {
11+
// NOTE: buildscript classpath for the root project is the parent classloader for the subprojects, we
12+
// only need to add e.g. atomic-fu and build-plugins here for imports and plugins to be available in subprojects.
1113
dependencies {
12-
// Add our custom gradle plugin(s) to buildscript classpath (comes from github source)
13-
// NOTE: buildscript classpath for the root project is the parent classloader for the subprojects, we
14-
// only need to include it here, imports in subprojects will work automagically
14+
classpath(libs.kotlinx.atomicfu.plugin)
1515
classpath("aws.sdk.kotlin:build-plugins") {
1616
version {
1717
require("0.2.2")
@@ -21,8 +21,8 @@ buildscript {
2121
}
2222

2323
plugins {
24-
kotlin("jvm") version "1.8.22" apply false
25-
id("org.jetbrains.dokka")
24+
@Suppress("DSL_SCOPE_VIOLATION") // TODO: Remove once https://youtrack.jetbrains.com/issue/KTIJ-19369 is fixed
25+
alias(libs.plugins.dokka)
2626
}
2727

2828
// configures (KMP) subprojects with our own KMP conventions and some default dependencies
@@ -72,12 +72,11 @@ subprojects {
7272

7373
val smithyKotlinPackageListUrl: String? by project
7474
val smithyKotlinDocBaseUrl: String? by project
75-
val smithyKotlinVersion: String by project
7675

7776
// Configure Dokka to link to smithy-kotlin types if specified in properties
7877
// These optional properties are supplied api the api docs build job but are unneeded otherwise
7978
smithyKotlinDocBaseUrl.takeUnless { it.isNullOrEmpty() }?.let { docBaseUrl ->
80-
val expandedDocBaseUrl = docBaseUrl.replace("\$smithyKotlinVersion", smithyKotlinVersion)
79+
val expandedDocBaseUrl = docBaseUrl.replace("\$smithyKotlinVersion", libs.versions.smithy.kotlin.version.get())
8180
dokkaSourceSets.configureEach {
8281
externalDocumentationLink {
8382
url.set(URL(expandedDocBaseUrl))

codegen/protocol-tests/build.gradle.kts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,8 @@ plugins {
1111

1212
description = "Smithy protocol test suite"
1313

14-
val smithyVersion: String by project
1514
dependencies {
16-
implementation("software.amazon.smithy:smithy-aws-protocol-tests:$smithyVersion")
15+
implementation(libs.smithy.aws.protocol.tests)
1716
}
1817

1918
data class ProtocolTest(val projectionName: String, val serviceShapeId: String, val sdkId: String? = null) {
@@ -79,7 +78,7 @@ tasks.named<SmithyBuild>("generateSmithyProjections") {
7978
addCompileClasspath = true
8079

8180
// ensure the generated clients use the same version of the runtime as the aws aws-runtime
82-
val smithyKotlinVersion: String by project
81+
val smithyKotlinVersion = libs.versions.smithy.kotlin.version.get()
8382
doFirst {
8483
System.setProperty("smithy.kotlin.codegen.clientRuntimeVersion", smithyKotlinVersion)
8584
}

codegen/sdk/build.gradle.kts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,9 @@ plugins {
2323
}
2424

2525
buildscript {
26-
val smithyVersion: String by project
2726
dependencies {
28-
classpath("software.amazon.smithy:smithy-model:$smithyVersion")
29-
classpath("software.amazon.smithy:smithy-aws-traits:$smithyVersion")
27+
classpath(libs.smithy.model)
28+
classpath(libs.smithy.aws.traits)
3029
}
3130
}
3231

@@ -246,7 +245,7 @@ fun parseMembership(rawList: String?): Membership {
246245
when {
247246
item.startsWith('-') -> exclusions.add(item.substring(1))
248247
item.startsWith('+') -> inclusions.add(item.substring(1))
249-
else -> error("Must specify inclusion (+) or exclusion (-) prefix character to $item.")
248+
else -> inclusions.add(item)
250249
}
251250
}
252251

codegen/smithy-aws-kotlin-codegen/build.gradle.kts

Lines changed: 19 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -14,34 +14,28 @@ description = "Codegen support for AWS protocols"
1414
group = "software.amazon.smithy.kotlin"
1515
version = sdkVersion
1616

17-
val smithyVersion: String by project
18-
val kotestVersion: String by project
19-
val kotlinVersion: String by project
20-
val junitVersion: String by project
21-
val smithyKotlinVersion: String by project
2217
val kotlinJVMTargetVersion: String by project
23-
val slf4jVersion: String by project
24-
val kotlinxSerializationVersion: String by project
2518

2619
dependencies {
27-
implementation(kotlin("stdlib-jdk8"))
28-
api("software.amazon.smithy.kotlin:smithy-kotlin-codegen:$smithyKotlinVersion")
29-
30-
api("software.amazon.smithy:smithy-aws-traits:$smithyVersion")
31-
api("software.amazon.smithy:smithy-aws-iam-traits:$smithyVersion")
32-
api("software.amazon.smithy:smithy-aws-cloudformation-traits:$smithyVersion")
33-
api("software.amazon.smithy:smithy-protocol-test-traits:$smithyVersion")
34-
implementation("software.amazon.smithy:smithy-aws-endpoints:$smithyVersion")
35-
36-
testImplementation("org.junit.jupiter:junit-jupiter:$junitVersion")
37-
testImplementation("org.junit.jupiter:junit-jupiter-params:$junitVersion")
38-
testImplementation("io.kotest:kotest-assertions-core-jvm:$kotestVersion")
39-
testImplementation("org.jetbrains.kotlin:kotlin-test-junit5:$kotlinVersion")
40-
testImplementation("software.amazon.smithy.kotlin:smithy-kotlin-codegen-testutils:$smithyKotlinVersion")
41-
42-
testImplementation("org.slf4j:slf4j-api:$slf4jVersion")
43-
testImplementation("org.slf4j:slf4j-simple:$slf4jVersion")
44-
testImplementation("org.jetbrains.kotlinx:kotlinx-serialization-json:$kotlinxSerializationVersion")
20+
21+
implementation(libs.kotlin.stdlib.jdk8)
22+
api(libs.smithy.kotlin.codegen)
23+
24+
api(libs.smithy.aws.traits)
25+
api(libs.smithy.aws.iam.traits)
26+
api(libs.smithy.aws.cloudformation.traits)
27+
api(libs.smithy.protocol.test.traits)
28+
implementation(libs.smithy.aws.endpoints)
29+
30+
testImplementation(libs.junit.jupiter)
31+
testImplementation(libs.junit.jupiter.params)
32+
testImplementation(libs.kotest.assertions.core.jvm)
33+
testImplementation(libs.kotlin.test.junit5)
34+
testImplementation(libs.smithy.kotlin.codegen.testutils)
35+
36+
testImplementation(libs.slf4j.api)
37+
testImplementation(libs.slf4j.simple)
38+
testImplementation(libs.kotlinx.serialization.json)
4539
}
4640

4741
val generateSdkRuntimeVersion by tasks.registering {

0 commit comments

Comments
 (0)