Skip to content

Commit

Permalink
chore: use a version catalog (#1061)
Browse files Browse the repository at this point in the history
  • Loading branch information
aajtodd authored Oct 5, 2023
1 parent 72e71ce commit b65b9cb
Show file tree
Hide file tree
Showing 21 changed files with 258 additions and 213 deletions.
22 changes: 20 additions & 2 deletions .builder/actions/set_upstream_versions.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@ def run(self, env):

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

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


def _replace_gradle_property(proj, prop_name, new_value):
Expand All @@ -53,6 +53,24 @@ def _replace_gradle_property(proj, prop_name, new_value):
else:
f.write(line)

def _replace_version_catalog_version(proj, prop_name, new_value):
"""
Replaces the named version catalog version with the value if the version exists in `libs.versions.toml`
"""
version_catalog = os.path.join(proj.path, "gradle", "libs.versions.toml")

with open(version_catalog, "r") as f:
lines = f.readlines()

with open(version_catalog, "w") as f:
for line in lines:
needle = "{} =".format(prop_name)
if needle in line:
replacement = "{} = \"{}\"\n".format(prop_name, new_value)
f.write(replacement)
print("replaced {} with {}".format(line.strip(), replacement.strip()))
else:
f.write(line)

def _get_dependency_version(env, dep):
"""
Expand Down
63 changes: 21 additions & 42 deletions aws-runtime/aws-config/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -12,74 +12,53 @@ plugins {
description = "Support for AWS configuration"
extra["moduleName"] = "aws.sdk.kotlin.runtime.config"

val smithyKotlinVersion: String by project
val kotestVersion: String by project
val coroutinesVersion: String by project
val atomicFuVersion: String by project

buildscript {
val atomicFuVersion: String by project

repositories {
mavenCentral()
}

dependencies {
classpath("org.jetbrains.kotlinx:atomicfu-gradle-plugin:$atomicFuVersion")
}
}
apply(plugin = "kotlinx-atomicfu")

kotlin {
sourceSets {
commonMain {
dependencies {
api(project(":aws-runtime:aws-core"))
api("aws.smithy.kotlin:aws-credentials:$smithyKotlinVersion")
implementation("aws.smithy.kotlin:http:$smithyKotlinVersion")
implementation("aws.smithy.kotlin:http-auth:$smithyKotlinVersion")
implementation("aws.smithy.kotlin:telemetry-api:$smithyKotlinVersion")
implementation("aws.smithy.kotlin:http-client-engine-default:$smithyKotlinVersion")
api(libs.smithy.kotlin.aws.credentials)
implementation(libs.smithy.kotlin.http)
implementation(libs.smithy.kotlin.http.auth)
implementation(libs.smithy.kotlin.telemetry.api)
implementation(libs.smithy.kotlin.http.client.engine.default)
implementation(project(":aws-runtime:aws-http"))

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

// additional dependencies required by generated sts provider
implementation("aws.smithy.kotlin:http-client:$smithyKotlinVersion")
implementation("aws.smithy.kotlin:serde-form-url:$smithyKotlinVersion")
implementation("aws.smithy.kotlin:serde-xml:$smithyKotlinVersion")
implementation("aws.smithy.kotlin:aws-xml-protocols:$smithyKotlinVersion")
implementation("aws.smithy.kotlin:aws-protocol-core:$smithyKotlinVersion")
// additional dependencies required by generated clients
implementation(libs.bundles.smithy.kotlin.service.client)
implementation(project(":aws-runtime:aws-endpoint"))
implementation("aws.smithy.kotlin:aws-signing-common:$smithyKotlinVersion")
implementation("aws.smithy.kotlin:aws-signing-default:$smithyKotlinVersion")
implementation("aws.smithy.kotlin:http-auth-aws:$smithyKotlinVersion")
implementation("aws.smithy.kotlin:telemetry-defaults:$smithyKotlinVersion")

// additional dependencies required by generated sts provider
implementation(libs.smithy.kotlin.serde.xml)
implementation(libs.smithy.kotlin.serde.formurl)
implementation(libs.smithy.kotlin.aws.xml.protocols)

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

// atomics
implementation("org.jetbrains.kotlinx:atomicfu:$atomicFuVersion")
implementation(libs.kotlinx.atomicfu)

// coroutines
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:$coroutinesVersion")
implementation(libs.kotlinx.coroutines.core)
}
}
commonTest {
dependencies {
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-test:$coroutinesVersion")
implementation("aws.smithy.kotlin:http-test:$smithyKotlinVersion")
val kotlinxSerializationVersion: String by project
val mockkVersion: String by project
implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:$kotlinxSerializationVersion")
implementation("io.mockk:mockk:$mockkVersion")
implementation(libs.kotlinx.coroutines.test)
implementation(libs.smithy.kotlin.http.test)
implementation(libs.kotlinx.serialization.json)
implementation(libs.mockk)
}
}
jvmTest {
dependencies {
implementation("io.kotest:kotest-runner-junit5:$kotestVersion")
implementation(libs.kotest.runner.junit5)
}
}

Expand Down
9 changes: 3 additions & 6 deletions aws-runtime/aws-core/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,18 @@ description = "AWS client runtime core"
extra["displayName"] = "AWS :: SDK :: Kotlin :: Client Runtime"
extra["moduleName"] = "aws.sdk.kotlin.runtime"

val smithyKotlinVersion: String by project
val coroutinesVersion: String by project

kotlin {
sourceSets {
commonMain {
dependencies {
api("aws.smithy.kotlin:runtime-core:$smithyKotlinVersion")
api("aws.smithy.kotlin:smithy-client:$smithyKotlinVersion")
api(libs.smithy.kotlin.runtime.core)
api(libs.smithy.kotlin.smithy.client)
}
}

commonTest {
dependencies {
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-test:$coroutinesVersion")
implementation(libs.kotlinx.coroutines.test)
}
}

Expand Down
6 changes: 2 additions & 4 deletions aws-runtime/aws-endpoint/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,14 @@ description = "AWS Endpoint Support"
extra["displayName"] = "AWS :: SDK :: Kotlin :: Endpoint"
extra["moduleName"] = "aws.sdk.kotlin.runtime.endpoint"

val smithyKotlinVersion: String by project

kotlin {
sourceSets {
commonMain {
dependencies {
implementation(project(":aws-runtime:aws-core"))
// exposes Endpoint
api("aws.smithy.kotlin:http-client:$smithyKotlinVersion")
api("aws.smithy.kotlin:aws-signing-common:$smithyKotlinVersion")
api(libs.smithy.kotlin.http.client)
api(libs.smithy.kotlin.aws.signing.common)
}
}

Expand Down
11 changes: 4 additions & 7 deletions aws-runtime/aws-http/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -7,24 +7,21 @@ description = "HTTP core for AWS service clients"
extra["displayName"] = "AWS :: SDK :: Kotlin :: HTTP"
extra["moduleName"] = "aws.sdk.kotlin.runtime.http"

val coroutinesVersion: String by project
val smithyKotlinVersion: String by project

kotlin {
sourceSets {
commonMain {
dependencies {
api(project(":aws-runtime:aws-core"))
api(project(":aws-runtime:aws-endpoint"))
api("aws.smithy.kotlin:aws-signing-common:$smithyKotlinVersion")
api("aws.smithy.kotlin:http-client:$smithyKotlinVersion")
api(libs.smithy.kotlin.aws.signing.common)
api(libs.smithy.kotlin.http.client)
}
}

commonTest {
dependencies {
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-test:$coroutinesVersion")
implementation("aws.smithy.kotlin:http-test:$smithyKotlinVersion")
implementation(libs.kotlinx.coroutines.test)
api(libs.smithy.kotlin.http.test)
}
}

Expand Down
15 changes: 8 additions & 7 deletions aws-runtime/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,17 @@ import aws.sdk.kotlin.gradle.kmp.*

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

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

val sdkVersion: String by project

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

subprojects {
if (!needsKmpConfigured) return@subprojects
Expand All @@ -39,14 +40,14 @@ subprojects {

named("commonTest") {
dependencies {
implementation("io.kotest:kotest-assertions-core:$kotestVersion")
implementation(libraries.kotest.assertions.core)
}
}

named("jvmTest") {
dependencies {
implementation("io.kotest:kotest-assertions-core-jvm:$kotestVersion")
implementation("org.slf4j:slf4j-simple:$slf4jVersion")
implementation(libraries.kotest.assertions.core.jvm)
implementation(libraries.slf4j.simple)
}
}
}
Expand Down
13 changes: 6 additions & 7 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ import aws.sdk.kotlin.gradle.util.typedProp
import java.net.URL

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

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

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

val smithyKotlinPackageListUrl: String? by project
val smithyKotlinDocBaseUrl: String? by project
val smithyKotlinVersion: String by project

// Configure Dokka to link to smithy-kotlin types if specified in properties
// These optional properties are supplied api the api docs build job but are unneeded otherwise
smithyKotlinDocBaseUrl.takeUnless { it.isNullOrEmpty() }?.let { docBaseUrl ->
val expandedDocBaseUrl = docBaseUrl.replace("\$smithyKotlinVersion", smithyKotlinVersion)
val expandedDocBaseUrl = docBaseUrl.replace("\$smithyKotlinVersion", libs.versions.smithy.kotlin.version.get())
dokkaSourceSets.configureEach {
externalDocumentationLink {
url.set(URL(expandedDocBaseUrl))
Expand Down
5 changes: 2 additions & 3 deletions codegen/protocol-tests/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,8 @@ plugins {

description = "Smithy protocol test suite"

val smithyVersion: String by project
dependencies {
implementation("software.amazon.smithy:smithy-aws-protocol-tests:$smithyVersion")
implementation(libs.smithy.aws.protocol.tests)
}

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

// ensure the generated clients use the same version of the runtime as the aws aws-runtime
val smithyKotlinVersion: String by project
val smithyKotlinVersion = libs.versions.smithy.kotlin.version.get()
doFirst {
System.setProperty("smithy.kotlin.codegen.clientRuntimeVersion", smithyKotlinVersion)
}
Expand Down
7 changes: 3 additions & 4 deletions codegen/sdk/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,9 @@ plugins {
}

buildscript {
val smithyVersion: String by project
dependencies {
classpath("software.amazon.smithy:smithy-model:$smithyVersion")
classpath("software.amazon.smithy:smithy-aws-traits:$smithyVersion")
classpath(libs.smithy.model)
classpath(libs.smithy.aws.traits)
}
}

Expand Down Expand Up @@ -246,7 +245,7 @@ fun parseMembership(rawList: String?): Membership {
when {
item.startsWith('-') -> exclusions.add(item.substring(1))
item.startsWith('+') -> inclusions.add(item.substring(1))
else -> error("Must specify inclusion (+) or exclusion (-) prefix character to $item.")
else -> inclusions.add(item)
}
}

Expand Down
44 changes: 19 additions & 25 deletions codegen/smithy-aws-kotlin-codegen/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -14,34 +14,28 @@ description = "Codegen support for AWS protocols"
group = "software.amazon.smithy.kotlin"
version = sdkVersion

val smithyVersion: String by project
val kotestVersion: String by project
val kotlinVersion: String by project
val junitVersion: String by project
val smithyKotlinVersion: String by project
val kotlinJVMTargetVersion: String by project
val slf4jVersion: String by project
val kotlinxSerializationVersion: String by project

dependencies {
implementation(kotlin("stdlib-jdk8"))
api("software.amazon.smithy.kotlin:smithy-kotlin-codegen:$smithyKotlinVersion")

api("software.amazon.smithy:smithy-aws-traits:$smithyVersion")
api("software.amazon.smithy:smithy-aws-iam-traits:$smithyVersion")
api("software.amazon.smithy:smithy-aws-cloudformation-traits:$smithyVersion")
api("software.amazon.smithy:smithy-protocol-test-traits:$smithyVersion")
implementation("software.amazon.smithy:smithy-aws-endpoints:$smithyVersion")

testImplementation("org.junit.jupiter:junit-jupiter:$junitVersion")
testImplementation("org.junit.jupiter:junit-jupiter-params:$junitVersion")
testImplementation("io.kotest:kotest-assertions-core-jvm:$kotestVersion")
testImplementation("org.jetbrains.kotlin:kotlin-test-junit5:$kotlinVersion")
testImplementation("software.amazon.smithy.kotlin:smithy-kotlin-codegen-testutils:$smithyKotlinVersion")

testImplementation("org.slf4j:slf4j-api:$slf4jVersion")
testImplementation("org.slf4j:slf4j-simple:$slf4jVersion")
testImplementation("org.jetbrains.kotlinx:kotlinx-serialization-json:$kotlinxSerializationVersion")

implementation(libs.kotlin.stdlib.jdk8)
api(libs.smithy.kotlin.codegen)

api(libs.smithy.aws.traits)
api(libs.smithy.aws.iam.traits)
api(libs.smithy.aws.cloudformation.traits)
api(libs.smithy.protocol.test.traits)
implementation(libs.smithy.aws.endpoints)

testImplementation(libs.junit.jupiter)
testImplementation(libs.junit.jupiter.params)
testImplementation(libs.kotest.assertions.core.jvm)
testImplementation(libs.kotlin.test.junit5)
testImplementation(libs.smithy.kotlin.codegen.testutils)

testImplementation(libs.slf4j.api)
testImplementation(libs.slf4j.simple)
testImplementation(libs.kotlinx.serialization.json)
}

val generateSdkRuntimeVersion by tasks.registering {
Expand Down
5 changes: 2 additions & 3 deletions dokka-aws/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,8 @@ plugins {
description = "Custom Dokka plugin for AWS Kotlin SDK API docs"

dependencies {
val dokkaVersion: String by project
compileOnly("org.jetbrains.dokka:dokka-base:$dokkaVersion")
compileOnly("org.jetbrains.dokka:dokka-core:$dokkaVersion")
compileOnly(libs.dokka.base)
compileOnly(libs.dokka.core)
}

tasks.withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile> {
Expand Down
Loading

0 comments on commit b65b9cb

Please sign in to comment.