From b65b9cb2681e008ca6532584b49e028bf9e50f8d Mon Sep 17 00:00:00 2001 From: Aaron Todd Date: Thu, 5 Oct 2023 12:48:15 -0400 Subject: [PATCH] chore: use a version catalog (#1061) --- .builder/actions/set_upstream_versions.py | 22 +++- aws-runtime/aws-config/build.gradle.kts | 63 +++------ aws-runtime/aws-core/build.gradle.kts | 9 +- aws-runtime/aws-endpoint/build.gradle.kts | 6 +- aws-runtime/aws-http/build.gradle.kts | 11 +- aws-runtime/build.gradle.kts | 15 ++- build.gradle.kts | 13 +- codegen/protocol-tests/build.gradle.kts | 5 +- codegen/sdk/build.gradle.kts | 7 +- .../build.gradle.kts | 44 +++---- dokka-aws/build.gradle.kts | 5 +- gradle.properties | 22 ---- gradle/libs.versions.toml | 123 ++++++++++++++++++ gradle/sdk-plugins/build.gradle.kts | 23 +--- gradle/sdk-plugins/settings.gradle.kts | 8 ++ .../gradle/codegen/tasks/SmithyTasks.kt | 8 +- services/build.gradle.kts | 21 ++- settings.gradle.kts | 4 - .../service-benchmarks/build.gradle.kts | 21 +-- tests/codegen/event-stream/build.gradle.kts | 35 ++--- tests/e2e-test-util/build.gradle.kts | 6 +- 21 files changed, 258 insertions(+), 213 deletions(-) create mode 100644 gradle/libs.versions.toml diff --git a/.builder/actions/set_upstream_versions.py b/.builder/actions/set_upstream_versions.py index bcd604f7601..2429eb71c7b 100644 --- a/.builder/actions/set_upstream_versions.py +++ b/.builder/actions/set_upstream_versions.py @@ -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): @@ -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): """ diff --git a/aws-runtime/aws-config/build.gradle.kts b/aws-runtime/aws-config/build.gradle.kts index f441d684045..1db845ea76f 100644 --- a/aws-runtime/aws-config/build.gradle.kts +++ b/aws-runtime/aws-config/build.gradle.kts @@ -12,22 +12,6 @@ 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 { @@ -35,51 +19,46 @@ kotlin { 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) } } diff --git a/aws-runtime/aws-core/build.gradle.kts b/aws-runtime/aws-core/build.gradle.kts index 8d6bccb814a..42e90f200e7 100644 --- a/aws-runtime/aws-core/build.gradle.kts +++ b/aws-runtime/aws-core/build.gradle.kts @@ -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) } } diff --git a/aws-runtime/aws-endpoint/build.gradle.kts b/aws-runtime/aws-endpoint/build.gradle.kts index 461478faf2e..c910984754d 100644 --- a/aws-runtime/aws-endpoint/build.gradle.kts +++ b/aws-runtime/aws-endpoint/build.gradle.kts @@ -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) } } diff --git a/aws-runtime/aws-http/build.gradle.kts b/aws-runtime/aws-http/build.gradle.kts index 6c9b9de157a..c91aa409876 100644 --- a/aws-runtime/aws-http/build.gradle.kts +++ b/aws-runtime/aws-http/build.gradle.kts @@ -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) } } diff --git a/aws-runtime/build.gradle.kts b/aws-runtime/build.gradle.kts index 9b913a45338..0cb52a65341 100644 --- a/aws-runtime/build.gradle.kts +++ b/aws-runtime/build.gradle.kts @@ -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 @@ -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) } } } diff --git a/build.gradle.kts b/build.gradle.kts index 76acb35c701..70c6d303d08 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -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") @@ -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 @@ -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)) diff --git a/codegen/protocol-tests/build.gradle.kts b/codegen/protocol-tests/build.gradle.kts index 42d14f7968c..0e207b34714 100644 --- a/codegen/protocol-tests/build.gradle.kts +++ b/codegen/protocol-tests/build.gradle.kts @@ -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) { @@ -79,7 +78,7 @@ tasks.named("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) } diff --git a/codegen/sdk/build.gradle.kts b/codegen/sdk/build.gradle.kts index dce7e884ffb..9ffbff02fea 100644 --- a/codegen/sdk/build.gradle.kts +++ b/codegen/sdk/build.gradle.kts @@ -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) } } @@ -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) } } diff --git a/codegen/smithy-aws-kotlin-codegen/build.gradle.kts b/codegen/smithy-aws-kotlin-codegen/build.gradle.kts index 2b91d0b6b9e..36186044fd7 100644 --- a/codegen/smithy-aws-kotlin-codegen/build.gradle.kts +++ b/codegen/smithy-aws-kotlin-codegen/build.gradle.kts @@ -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 { diff --git a/dokka-aws/build.gradle.kts b/dokka-aws/build.gradle.kts index f714f284e53..f469a769443 100644 --- a/dokka-aws/build.gradle.kts +++ b/dokka-aws/build.gradle.kts @@ -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 { diff --git a/gradle.properties b/gradle.properties index 42813273ebb..b4f789afb73 100644 --- a/gradle.properties +++ b/gradle.properties @@ -8,33 +8,11 @@ org.gradle.jvmargs=-Xmx6g -XX:MaxMetaspaceSize=2G # sdk sdkVersion=0.32.4-SNAPSHOT -# codegen -smithyVersion=1.39.0 -smithyGradleVersion=0.6.0 -# smithy-kotlin codegen and runtime are versioned together -smithyKotlinVersion=0.27.5 - # kotlin kotlinVersion=1.8.22 -dokkaVersion=1.7.10 # kotlin JVM kotlinJVMTargetVersion=1.8 -# kotlin libraries -coroutinesVersion=1.7.3 -atomicFuVersion=0.19.0 -kotlinxSerializationVersion=1.4.1 -ktorVersion=2.3.3 - -# testing/utility -junitVersion=5.9.2 -kotestVersion=5.5.4 -jacocoVersion=0.8.8 -mockkVersion=1.13.3 - -# logging - JVM -slf4jVersion=2.0.6 - # dokka config (values specified at build-time as needed) smithyKotlinDocBaseUrl=https://sdk.amazonaws.com/kotlin/api/smithy-kotlin/api/$smithyKotlinVersion/ \ No newline at end of file diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml new file mode 100644 index 00000000000..49b34559a3d --- /dev/null +++ b/gradle/libs.versions.toml @@ -0,0 +1,123 @@ +[versions] +kotlin-version = "1.8.22" +dokka-version = "1.7.10" + +# libs +coroutines-version = "1.7.3" +atomicfu-version = "0.19.0" + +# smithy-kotlin codegen and runtime are versioned together +smithy-kotlin-version = "0.27.5" + +# codegen +smithy-version = "1.39.0" +smithy-gradle-version = "0.6.0" + +# testing +junit-version = "5.9.2" +kotest-version = "5.5.4" +kotlinx-benchmark-version = "0.4.7" +kotlinx-serialization-version = "1.4.1" +mockk-version = "1.13.3" +slf4j-version = "2.0.6" + + +[libraries] +kotlin-stdlib = { module = "org.jetbrains.kotlin:kotlin-stdlib", version.ref = "kotlin-version"} +kotlin-stdlib-jdk8 = { module = "org.jetbrains.kotlin:kotlin-stdlib-jdk8", version.ref = "kotlin-version"} +kotlin-test = { module = "org.jetbrains.kotlin:kotlin-test", version.ref = "kotlin-version" } +kotlin-test-junit5 = { module = "org.jetbrains.kotlin:kotlin-test-junit5", version.ref = "kotlin-version" } +dokka-core = { module = "org.jetbrains.dokka:dokka-core", version.ref = "dokka-version" } +dokka-base = { module = "org.jetbrains.dokka:dokka-base", version.ref = "dokka-version" } + +kotlinx-atomicfu = { module = "org.jetbrains.kotlinx:atomicfu", version.ref = "atomicfu-version" } +kotlinx-atomicfu-plugin = { module = "org.jetbrains.kotlinx:atomicfu-gradle-plugin", version.ref = "atomicfu-version" } + +kotlinx-coroutines-debug = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-debug", version.ref = "coroutines-version" } +kotlinx-coroutines-test = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-test", version.ref = "coroutines-version" } +kotlinx-coroutines-core = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-core", version.ref = "coroutines-version" } +kotlinx-coroutines-jdk8 = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-jdk8", version.ref = "coroutines-version" } +kotlinx-coroutines-slf4j = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-slf4j", version.ref = "coroutines-version" } + +slf4j-api = { module = "org.slf4j:slf4j-api", version.ref = "slf4j-version" } +slf4j-simple = { module = "org.slf4j:slf4j-simple", version.ref = "slf4j-version" } + +smithy-kotlin-aws-credentials = { module = "aws.smithy.kotlin:aws-credentials", version.ref = "smithy-kotlin-version" } +smithy-kotlin-aws-event-stream = { module = "aws.smithy.kotlin:aws-event-stream", version.ref = "smithy-kotlin-version" } +smithy-kotlin-aws-signing-common = { module = "aws.smithy.kotlin:aws-signing-common", version.ref = "smithy-kotlin-version" } +smithy-kotlin-aws-signing-default = { module = "aws.smithy.kotlin:aws-signing-default", version.ref = "smithy-kotlin-version" } +smithy-kotlin-runtime-core = { module = "aws.smithy.kotlin:runtime-core", version.ref = "smithy-kotlin-version" } +smithy-kotlin-smithy-client = { module = "aws.smithy.kotlin:smithy-client", version.ref = "smithy-kotlin-version" } +smithy-kotlin-smithy-test = { module = "aws.smithy.kotlin:smithy-test", version.ref = "smithy-kotlin-version" } +smithy-kotlin-identity-api = { module = "aws.smithy.kotlin:identity-api", version.ref = "smithy-kotlin-version" } +smithy-kotlin-http = { module = "aws.smithy.kotlin:http", version.ref = "smithy-kotlin-version" } +smithy-kotlin-http-auth = { module = "aws.smithy.kotlin:http-auth", version.ref = "smithy-kotlin-version" } +smithy-kotlin-http-auth-aws = { module = "aws.smithy.kotlin:http-auth-aws", version.ref = "smithy-kotlin-version" } +smithy-kotlin-http-client = { module = "aws.smithy.kotlin:http-client", version.ref = "smithy-kotlin-version" } +smithy-kotlin-http-client-engine-default = { module = "aws.smithy.kotlin:http-client-engine-default", version.ref = "smithy-kotlin-version" } +smithy-kotlin-http-client-engine-crt = { module = "aws.smithy.kotlin:http-client-engine-crt", version.ref = "smithy-kotlin-version" } +smithy-kotlin-http-test = { module = "aws.smithy.kotlin:http-test", version.ref = "smithy-kotlin-version" } +smithy-kotlin-serde-core = { module = "aws.smithy.kotlin:serde", version.ref = "smithy-kotlin-version" } +smithy-kotlin-serde-json = { module = "aws.smithy.kotlin:serde-json", version.ref = "smithy-kotlin-version" } +smithy-kotlin-serde-xml = { module = "aws.smithy.kotlin:serde-xml", version.ref = "smithy-kotlin-version" } +smithy-kotlin-serde-formurl = { module = "aws.smithy.kotlin:serde-form-url", version.ref = "smithy-kotlin-version" } +smithy-kotlin-aws-protocol-core = { module = "aws.smithy.kotlin:aws-protocol-core", version.ref = "smithy-kotlin-version" } +smithy-kotlin-aws-xml-protocols = { module = "aws.smithy.kotlin:aws-xml-protocols", version.ref = "smithy-kotlin-version" } +smithy-kotlin-aws-json-protocols = { module = "aws.smithy.kotlin:aws-json-protocols", version.ref = "smithy-kotlin-version" } +smithy-kotlin-telemetry-api = { module = "aws.smithy.kotlin:telemetry-api", version.ref = "smithy-kotlin-version" } +smithy-kotlin-telemetry-defaults = { module = "aws.smithy.kotlin:telemetry-defaults", version.ref = "smithy-kotlin-version" } +smithy-kotlin-testing = { module = "aws.smithy.kotlin:testing", version.ref = "smithy-kotlin-version" } + +smithy-kotlin-codegen = { module = "software.amazon.smithy.kotlin:smithy-kotlin-codegen", version.ref = "smithy-kotlin-version" } +smithy-kotlin-codegen-testutils = { module = "software.amazon.smithy.kotlin:smithy-kotlin-codegen-testutils", version.ref = "smithy-kotlin-version" } + +smithy-codegen-core = { module = "software.amazon.smithy:smithy-codegen-core", version.ref = "smithy-version" } +smithy-cli = { module = "software.amazon.smithy:smithy-cli", version.ref = "smithy-version" } +smithy-waiters = { module = "software.amazon.smithy:smithy-waiters", version.ref = "smithy-version" } +smithy-aws-endpoints = { module = "software.amazon.smithy:smithy-aws-endpoints", version.ref = "smithy-version" } +smithy-aws-traits = { module = "software.amazon.smithy:smithy-aws-traits", version.ref = "smithy-version" } +smithy-aws-protocol-tests = { module = "software.amazon.smithy:smithy-aws-protocol-tests", version.ref = "smithy-version" } +smithy-aws-iam-traits = { module = "software.amazon.smithy:smithy-aws-iam-traits", version.ref = "smithy-version" } +smithy-aws-cloudformation-traits = { module = "software.amazon.smithy:smithy-aws-cloudformation-traits", version.ref = "smithy-version" } +smithy-model = { module = "software.amazon.smithy:smithy-model", version.ref = "smithy-version" } +smithy-protocol-test-traits = { module = "software.amazon.smithy:smithy-protocol-test-traits", version.ref = "smithy-version" } +smithy-gradle-plugin = { module = "software.amazon.smithy:smithy-gradle-plugin", version.ref = "smithy-gradle-version" } + +junit-jupiter = { module = "org.junit.jupiter:junit-jupiter", version.ref = "junit-version" } +junit-jupiter-params = { module = "org.junit.jupiter:junit-jupiter-params", version.ref = "junit-version" } + +kotest-assertions-core = { module = "io.kotest:kotest-assertions-core", version.ref = "kotest-version" } +kotest-assertions-core-jvm = { module = "io.kotest:kotest-assertions-core-jvm", version.ref = "kotest-version" } +kotest-runner-junit5 = { module = "io.kotest:kotest-runner-junit5", version.ref = "kotest-version" } +kotlinx-benchmark-runtime = { module = "org.jetbrains.kotlinx:kotlinx-benchmark-runtime", version.ref = "kotlinx-benchmark-version" } +kotlinx-serialization-json = { module = "org.jetbrains.kotlinx:kotlinx-serialization-json", version.ref = "kotlinx-serialization-version" } +mockk = { module = "io.mockk:mockk", version.ref = "mockk-version" } + +[bundles] +# bundle of smithy-kotlin dependencies all AWS service clients have +smithy-kotlin-service-client = [ + "smithy-kotlin-runtime-core", + "smithy-kotlin-smithy-client", + "smithy-kotlin-http-client", + "smithy-kotlin-http-client-engine-default", + "smithy-kotlin-http", + "smithy-kotlin-http-auth", + "smithy-kotlin-http-auth-aws", + "smithy-kotlin-aws-protocol-core", + "smithy-kotlin-serde-core", + "smithy-kotlin-aws-signing-common", + "smithy-kotlin-aws-signing-default", + "smithy-kotlin-identity-api", + "smithy-kotlin-aws-credentials", + "smithy-kotlin-telemetry-api", + "smithy-kotlin-telemetry-defaults", +] + +[plugins] +dokka = { id = "org.jetbrains.dokka", version.ref = "dokka-version"} +kotlin-jvm = {id = "org.jetbrains.kotlin.jvm", version.ref = "kotlin-version" } +kotlin-multiplatform = {id = "org.jetbrains.kotlin.multiplatform", version.ref = "kotlin-version" } +kotlinx-benchmark = { id = "org.jetbrains.kotlinx.benchmark", version.ref = "kotlinx-benchmark-version" } +kotlinx-binary-compatibility-validator = { id = "org.jetbrains.kotlinx.binary-compatibility-validator", version = "0.12.1" } +kotlinx-serialization = { id = "org.jetbrains.kotlin.plugin.serialization", version.ref = "kotlin-version"} +smithy-gradle = { id = "software.amazon.smithy", version.ref = "smithy-gradle-version" } diff --git a/gradle/sdk-plugins/build.gradle.kts b/gradle/sdk-plugins/build.gradle.kts index 28b19e29c8e..2654f6284ed 100644 --- a/gradle/sdk-plugins/build.gradle.kts +++ b/gradle/sdk-plugins/build.gradle.kts @@ -2,7 +2,6 @@ * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. * SPDX-License-Identifier: Apache-2.0 */ -import java.util.Properties buildscript { repositories { mavenLocal() @@ -21,26 +20,10 @@ repositories { gradlePluginPortal() } -fun loadVersions() { - val gradleProperties = Properties() - val propertiesFile: File = file("../../gradle.properties") - if (propertiesFile.exists()) { - propertiesFile.inputStream().use { gradleProperties.load(it) } - } - gradleProperties.forEach { - project.ext.set(it.key.toString(), it.value) - } -} -// use the versions from aws-sdk-kotlin/gradle.properties -loadVersions() - -val smithyVersion: String by project -val smithyGradleVersion: String by project - dependencies { - implementation("software.amazon.smithy:smithy-gradle-plugin:$smithyGradleVersion") - implementation("software.amazon.smithy:smithy-model:$smithyVersion") - implementation("software.amazon.smithy:smithy-aws-traits:$smithyVersion") + implementation(libs.smithy.gradle.plugin) + implementation(libs.smithy.model) + implementation(libs.smithy.aws.traits) implementation(gradleApi()) } diff --git a/gradle/sdk-plugins/settings.gradle.kts b/gradle/sdk-plugins/settings.gradle.kts index 3f5b92ac74b..51b5d9f0314 100644 --- a/gradle/sdk-plugins/settings.gradle.kts +++ b/gradle/sdk-plugins/settings.gradle.kts @@ -3,3 +3,11 @@ * SPDX-License-Identifier: Apache-2.0 */ rootProject.name = "sdk-plugins" + +dependencyResolutionManagement { + versionCatalogs { + create("libs") { + from(files("../libs.versions.toml")) + } + } +} diff --git a/gradle/sdk-plugins/src/main/kotlin/aws/sdk/kotlin/gradle/codegen/tasks/SmithyTasks.kt b/gradle/sdk-plugins/src/main/kotlin/aws/sdk/kotlin/gradle/codegen/tasks/SmithyTasks.kt index 4c9573db589..d7a1752838f 100644 --- a/gradle/sdk-plugins/src/main/kotlin/aws/sdk/kotlin/gradle/codegen/tasks/SmithyTasks.kt +++ b/gradle/sdk-plugins/src/main/kotlin/aws/sdk/kotlin/gradle/codegen/tasks/SmithyTasks.kt @@ -10,8 +10,9 @@ import aws.sdk.kotlin.gradle.codegen.dsl.codegenExtension import aws.sdk.kotlin.gradle.codegen.dsl.withObjectMember import org.gradle.api.Project import org.gradle.api.artifacts.Configuration +import org.gradle.api.artifacts.VersionCatalogsExtension import org.gradle.kotlin.dsl.dependencies -import org.gradle.kotlin.dsl.provideDelegate +import org.gradle.kotlin.dsl.getByType import org.gradle.kotlin.dsl.register import software.amazon.smithy.gradle.tasks.SmithyBuild import software.amazon.smithy.model.node.Node @@ -112,10 +113,13 @@ private fun Project.createCodegenConfiguration(): Configuration { internal fun Project.createSmithyCliConfiguration(): Configuration { // see: https://github.com/awslabs/smithy-gradle-plugin/blob/main/src/main/java/software/amazon/smithy/gradle/SmithyPlugin.java#L119 val smithyCliConfig = configurations.maybeCreate("smithyCli") + + // FIXME - this is tightly coupled to our project + val versionCatalog = extensions.getByType().named("libs") + val smithyVersion = versionCatalog.findVersion("smithy-version").get() dependencies { // smithy plugin requires smithy-cli to be on the classpath, for whatever reason configuring the plugin // from this plugin doesn't work correctly so we explicitly set it - val smithyVersion: String by project smithyCliConfig("software.amazon.smithy:smithy-cli:$smithyVersion") // add aws traits to the compile classpath so that the smithy build task can discover them diff --git a/services/build.gradle.kts b/services/build.gradle.kts index d1504fd81bb..86bdb534241 100644 --- a/services/build.gradle.kts +++ b/services/build.gradle.kts @@ -8,16 +8,12 @@ import aws.sdk.kotlin.gradle.util.typedProp import java.time.LocalDateTime plugins { - id("org.jetbrains.dokka") `maven-publish` + @Suppress("DSL_SCOPE_VIOLATION") // TODO: Remove once https://youtrack.jetbrains.com/issue/KTIJ-19369 is fixed + alias(libs.plugins.dokka) } val sdkVersion: String by project -val smithyKotlinVersion: String by project -val kotlinVersion: String by project -val coroutinesVersion: String by project -val kotestVersion: String by project -val slf4jVersion: String by project val optinAnnotations = listOf( "aws.smithy.kotlin.runtime.InternalApi", @@ -25,6 +21,9 @@ val optinAnnotations = listOf( "kotlin.RequiresOptIn", ) +// capture locally - scope issue with custom KMP plugin +val libraries = libs + subprojects { group = "aws.sdk.kotlin" version = sdkVersion @@ -53,7 +52,7 @@ subprojects { kotlin.srcDir("generated-src/test") dependencies { - implementation("org.jetbrains.kotlinx:kotlinx-coroutines-test:$coroutinesVersion") + implementation(libraries.kotlinx.coroutines.test) } } } @@ -68,11 +67,11 @@ subprojects { dependsOn(sourceSets.getByName("jvmMain")) dependencies { - api("aws.smithy.kotlin:testing:$smithyKotlinVersion") - implementation(kotlin("test")) - implementation(kotlin("test-junit5")) + api(libraries.smithy.kotlin.testing) + implementation(libraries.kotlin.test) + implementation(libraries.kotlin.test.junit5) implementation(project(":tests:e2e-test-util")) - implementation("org.slf4j:slf4j-simple:$slf4jVersion") + implementation(libraries.slf4j.simple) } } diff --git a/settings.gradle.kts b/settings.gradle.kts index 23351a8a2a8..98fc80a8a9a 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -13,12 +13,8 @@ pluginManagement { // configure default plugin versions plugins { val kotlinVersion: String by settings - val dokkaVersion: String by settings - val smithyGradleVersion: String by settings - id("org.jetbrains.dokka") version dokkaVersion id("org.jetbrains.kotlin.jvm") version kotlinVersion id("org.jetbrains.kotlin.multiplatform") version kotlinVersion - id("software.amazon.smithy") version smithyGradleVersion } } diff --git a/tests/benchmarks/service-benchmarks/build.gradle.kts b/tests/benchmarks/service-benchmarks/build.gradle.kts index 66d756d8a83..d5628f61d22 100644 --- a/tests/benchmarks/service-benchmarks/build.gradle.kts +++ b/tests/benchmarks/service-benchmarks/build.gradle.kts @@ -3,17 +3,6 @@ * SPDX-License-Identifier: Apache-2.0 */ import aws.sdk.kotlin.gradle.dsl.skipPublishing -buildscript { - repositories { - mavenCentral() - } - - val atomicFuVersion: String by project - - dependencies { - classpath("org.jetbrains.kotlinx:atomicfu-gradle-plugin:$atomicFuVersion") - } -} plugins { kotlin("multiplatform") @@ -51,16 +40,12 @@ if (missingServices.isEmpty()) { optinAnnotations.forEach { languageSettings.optIn(it) } } - val atomicFuVersion: String by project - val coroutinesVersion: String by project - val smithyKotlinVersion: String by project - commonMain { dependencies { - api("aws.smithy.kotlin:runtime-core:$smithyKotlinVersion") + api(libs.smithy.kotlin.runtime.core) implementation(project(":aws-runtime:aws-core")) - implementation("org.jetbrains.kotlinx:atomicfu:$atomicFuVersion") - implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:$coroutinesVersion") + implementation(libs.kotlinx.atomicfu) + implementation(libs.kotlinx.coroutines.core) requiredServices.forEach { implementation(project(":services:$it")) } } diff --git a/tests/codegen/event-stream/build.gradle.kts b/tests/codegen/event-stream/build.gradle.kts index 3cc63a0c444..1c9818c6d42 100644 --- a/tests/codegen/event-stream/build.gradle.kts +++ b/tests/codegen/event-stream/build.gradle.kts @@ -88,7 +88,7 @@ val generateProjectionsTask = tasks.named("generateSmithyProjection addCompileClasspath = true // ensure the generated tests 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) } @@ -128,38 +128,29 @@ tasks.test { } dependencies { - val coroutinesVersion: String by project - val smithyKotlinVersion: String by project - implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:$coroutinesVersion") + implementation(libs.kotlinx.coroutines.core) - testImplementation(kotlin("test")) - testImplementation(kotlin("test-junit5")) - testImplementation("org.jetbrains.kotlinx:kotlinx-coroutines-test:$coroutinesVersion") - testImplementation("aws.smithy.kotlin:smithy-test:$smithyKotlinVersion") - testImplementation("aws.smithy.kotlin:aws-signing-default:$smithyKotlinVersion") - testImplementation("aws.smithy.kotlin:telemetry-api:$smithyKotlinVersion") + testImplementation(libs.kotlin.test) + testImplementation(libs.kotlin.test.junit5) + testImplementation(libs.kotlinx.coroutines.test) + + testImplementation(libs.smithy.kotlin.smithy.test) + testImplementation(libs.smithy.kotlin.aws.signing.default) + testImplementation(libs.smithy.kotlin.telemetry.api) // have to manually add all the dependencies of the generated client(s) // doing it this way (as opposed to doing what we do for protocol-tests) allows // the tests to work without a publish to maven-local step at the cost of maintaining // this set of dependencies manually // <-- BEGIN GENERATED DEPENDENCY LIST --> - implementation("aws.smithy.kotlin:aws-credentials:$smithyKotlinVersion") - implementation("aws.smithy.kotlin:aws-event-stream:$smithyKotlinVersion") + implementation(libs.bundles.smithy.kotlin.service.client) + implementation(libs.smithy.kotlin.aws.event.stream) implementation(project(":aws-runtime:aws-http")) - implementation("aws.smithy.kotlin:aws-protocol-core:$smithyKotlinVersion") - implementation("aws.smithy.kotlin:aws-json-protocols:$smithyKotlinVersion") - implementation("aws.smithy.kotlin:aws-signing-common:$smithyKotlinVersion") - implementation("aws.smithy.kotlin:http-auth-aws:$smithyKotlinVersion") - implementation("aws.smithy.kotlin:http:$smithyKotlinVersion") - implementation("aws.smithy.kotlin:http-client-engine-default:$smithyKotlinVersion") - implementation("aws.smithy.kotlin:telemetry-defaults:$smithyKotlinVersion") - implementation("aws.smithy.kotlin:serde:$smithyKotlinVersion") - implementation("aws.smithy.kotlin:serde-json:$smithyKotlinVersion") + implementation(libs.smithy.kotlin.aws.json.protocols) + implementation(libs.smithy.kotlin.serde.json) api(project(":aws-runtime:aws-config")) api(project(":aws-runtime:aws-core")) api(project(":aws-runtime:aws-endpoint")) - api("aws.smithy.kotlin:runtime-core:$smithyKotlinVersion") // <-- END GENERATED DEPENDENCY LIST --> } diff --git a/tests/e2e-test-util/build.gradle.kts b/tests/e2e-test-util/build.gradle.kts index 43f19754517..d8f8d2cd7f3 100644 --- a/tests/e2e-test-util/build.gradle.kts +++ b/tests/e2e-test-util/build.gradle.kts @@ -8,9 +8,7 @@ plugins { description = "Test utilities for integration and e2e tests" -val smithyKotlinVersion: String by project - dependencies { - api("aws.smithy.kotlin:http-client-engine-default:$smithyKotlinVersion") - api("aws.smithy.kotlin:http-client-engine-crt:$smithyKotlinVersion") + api(libs.smithy.kotlin.http.client.engine.default) + api(libs.smithy.kotlin.http.client.engine.crt) }