From 86b3f216c312aab567015fc2809eb5d6cb71c013 Mon Sep 17 00:00:00 2001 From: Aaron J Todd Date: Wed, 20 Dec 2023 16:11:57 -0500 Subject: [PATCH 1/4] chore: upgrade to latest smithy-gradle plugin --- bom/build.gradle.kts | 2 +- gradle/libs.versions.toml | 5 +- .../serde-benchmarks/build.gradle.kts | 33 +++++++--- .../nullability-tests/build.gradle.kts | 63 +++++++++---------- .../codegen/paginator-tests/build.gradle.kts | 42 ++++++------- tests/codegen/waiter-tests/build.gradle.kts | 44 +++++++------ 6 files changed, 99 insertions(+), 90 deletions(-) diff --git a/bom/build.gradle.kts b/bom/build.gradle.kts index 9fdc408f0..c0e23752f 100644 --- a/bom/build.gradle.kts +++ b/bom/build.gradle.kts @@ -53,7 +53,7 @@ fun createBomConstraintsAndVersionCatalog() { fun Project.artifactId(target: KotlinTarget): String = when (target) { is KotlinMetadataTarget -> name is KotlinJsTarget -> "$name-js" - else -> "$name-${target.targetName.toLowerCase(Locale.ROOT)}" + else -> "$name-${target.targetName.lowercase()}" } /** diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index cc0edd931..82c210fda 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -14,7 +14,7 @@ crt-kotlin-version = "0.8.2" # codegen smithy-version = "1.42.0" -smithy-gradle-version = "0.7.0" +smithy-gradle-version = "0.9.0" # testing junit-version = "5.10.1" @@ -58,6 +58,7 @@ crt-kotlin = { module = "aws.sdk.kotlin.crt:aws-crt-kotlin", version.ref = "crt- 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-model = { module = "software.amazon.smithy:smithy-model", version.ref = "smithy-version" } smithy-waiters = { module = "software.amazon.smithy:smithy-waiters", version.ref = "smithy-version" } smithy-rules-engine = { module = "software.amazon.smithy:smithy-rules-engine", version.ref = "smithy-version" } smithy-aws-traits = { module = "software.amazon.smithy:smithy-aws-traits", version.ref = "smithy-version" } @@ -92,4 +93,4 @@ kotlin-multiplatform = {id = "org.jetbrains.kotlin.multiplatform", version.ref = 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.13.2" } kotlinx-serialization = { id = "org.jetbrains.kotlin.plugin.serialization", version.ref = "kotlin-version"} -smithy-gradle = { id = "software.amazon.smithy", version.ref = "smithy-gradle-version" } +smithy-gradle-base = { id = "software.amazon.smithy.gradle.smithy-base", version.ref = "smithy-gradle-version" } diff --git a/tests/benchmarks/serde-benchmarks/build.gradle.kts b/tests/benchmarks/serde-benchmarks/build.gradle.kts index f5c5b9b14..e3354b300 100644 --- a/tests/benchmarks/serde-benchmarks/build.gradle.kts +++ b/tests/benchmarks/serde-benchmarks/build.gradle.kts @@ -3,12 +3,12 @@ * SPDX-License-Identifier: Apache-2.0 */ import aws.sdk.kotlin.gradle.dsl.skipPublishing -import software.amazon.smithy.gradle.tasks.SmithyBuild +import software.amazon.smithy.gradle.tasks.SmithyBuildTask plugins { kotlin("multiplatform") - alias(libs.plugins.smithy.gradle) alias(libs.plugins.kotlinx.benchmark) + alias(libs.plugins.smithy.gradle.base) } skipPublishing() @@ -73,19 +73,36 @@ afterEvaluate { } } -tasks["smithyBuildJar"].enabled = false +smithy { + format.set(false) +} val codegen by configurations.creating - dependencies { codegen(project(":tests:benchmarks:serde-benchmarks-codegen")) + codegen(libs.smithy.cli) + codegen(libs.smithy.model) } -val generateSdk = tasks.create("generateSdk") { +// FIXME - probably a bug in smithy gradle base plugin +val configurationsNeededBySmithyGradle = listOf( + "smithyCli", + "smithyBuild", + "runtimeClasspath", +) + .forEach { + configurations.create(it) + } + +val generateSdk = tasks.create("smithyBuild") { group = "codegen" - classpath = configurations.getByName("codegen") - inputs.file(projectDir.resolve("smithy-build.json")) - inputs.files(configurations.getByName("codegen")) + resolvedCliClasspath.set(codegen) + runtimeClasspath.set(codegen) + buildClasspath.set(codegen) + smithyBuildConfigs.set(files("smithy-build.json")) + val modelFiles = fileTree("model") + modelFiles.include("*.smithy") + models.set(modelFiles) } data class BenchmarkModel(val name: String) { diff --git a/tests/codegen/nullability-tests/build.gradle.kts b/tests/codegen/nullability-tests/build.gradle.kts index c169b6cce..d951d3cd6 100644 --- a/tests/codegen/nullability-tests/build.gradle.kts +++ b/tests/codegen/nullability-tests/build.gradle.kts @@ -3,58 +3,53 @@ * SPDX-License-Identifier: Apache-2.0 */ import aws.sdk.kotlin.gradle.dsl.skipPublishing -import org.jetbrains.kotlin.gradle.tasks.KotlinCompile -import software.amazon.smithy.gradle.tasks.SmithyBuild -import software.amazon.smithy.gradle.tasks.Validate as SmithyValidate +import software.amazon.smithy.gradle.tasks.SmithyBuildTask plugins { - kotlin("jvm") - alias(libs.plugins.smithy.gradle) + alias(libs.plugins.kotlin.jvm) + alias(libs.plugins.smithy.gradle.base) } skipPublishing() -val optinAnnotations = listOf("kotlin.RequiresOptIn", "aws.smithy.kotlin.runtime.InternalApi") -kotlin.sourceSets.all { - optinAnnotations.forEach { languageSettings.optIn(it) } -} - -val projectionDirs = listOf( - "smithyprojections/nullability-tests/client-mode/kotlin-codegen", - "smithyprojections/nullability-tests/client-careful-mode/kotlin-codegen", -) - -kotlin.sourceSets.getByName("main") { - projectionDirs.forEach { - kotlin.srcDir(layout.buildDirectory.dir(it)) - } +smithy { + format.set(false) } -tasks.withType { - // generated code has warnings unfortunately - kotlinOptions.allWarningsAsErrors = false -} - -tasks["smithyBuildJar"].enabled = false val codegen by configurations.creating dependencies { codegen(project(":codegen:smithy-kotlin-codegen")) codegen(libs.smithy.cli) + codegen(libs.smithy.model) +} + +val generateSdk = tasks.named("smithyBuild") +generateSdk.configure { + resolvedCliClasspath.set(codegen) + runtimeClasspath.set(codegen) + buildClasspath.set(codegen) } -val generateSdk = tasks.register("generateSdk") { - group = "codegen" - classpath = codegen - inputs.file(projectDir.resolve("smithy-build.json")) - inputs.files(codegen) +val optinAnnotations = listOf("kotlin.RequiresOptIn", "aws.smithy.kotlin.runtime.InternalApi") +kotlin.sourceSets.all { + optinAnnotations.forEach { languageSettings.optIn(it) } } -tasks.named("smithyValidate") { - classpath = codegen +val projections = listOf( + "client-mode", + "client-careful-mode", +) + +kotlin.sourceSets.getByName("main") { + projections.forEach { projectionName -> + kotlin.srcDir(smithy.getPluginProjectionPath(projectionName, "kotlin-codegen").map { it.resolve("src/main/kotlin") }) + } } tasks.withType { dependsOn(generateSdk) + // generated code has warnings unfortunately + kotlinOptions.allWarningsAsErrors = false } tasks.test { @@ -66,12 +61,14 @@ tasks.test { } dependencies { - implementation(libs.kotlinx.coroutines.core) compileOnly(project(":codegen:smithy-kotlin-codegen")) + + implementation(libs.kotlinx.coroutines.core) implementation(project(":runtime:runtime-core")) implementation(project(":runtime:smithy-client")) implementation(project(":runtime:protocol:http-client")) implementation(project(":runtime:observability:telemetry-api")) implementation(project(":runtime:observability:telemetry-defaults")) + testImplementation(libs.kotlin.test.junit5) } diff --git a/tests/codegen/paginator-tests/build.gradle.kts b/tests/codegen/paginator-tests/build.gradle.kts index 7890dbc15..167bd2df6 100644 --- a/tests/codegen/paginator-tests/build.gradle.kts +++ b/tests/codegen/paginator-tests/build.gradle.kts @@ -3,43 +3,40 @@ * SPDX-License-Identifier: Apache-2.0 */ import aws.sdk.kotlin.gradle.dsl.skipPublishing -import software.amazon.smithy.gradle.tasks.SmithyBuild -import software.amazon.smithy.gradle.tasks.Validate as SmithyValidate +import software.amazon.smithy.gradle.tasks.SmithyBuildTask plugins { - kotlin("jvm") - alias(libs.plugins.smithy.gradle) + alias(libs.plugins.kotlin.jvm) + alias(libs.plugins.smithy.gradle.base) } skipPublishing() -val optinAnnotations = listOf("kotlin.RequiresOptIn", "aws.smithy.kotlin.runtime.InternalApi") -kotlin.sourceSets.all { - optinAnnotations.forEach { languageSettings.optIn(it) } -} - -kotlin.sourceSets.getByName("main") { - kotlin.srcDir(layout.buildDirectory.dir("generated-src/src")) - kotlin.srcDir(layout.buildDirectory.dir("smithyprojections/paginator-tests/paginator-tests/kotlin-codegen")) +smithy { + format.set(false) } -tasks["smithyBuildJar"].enabled = false - val codegen by configurations.creating dependencies { codegen(project(":codegen:smithy-kotlin-codegen")) codegen(libs.smithy.cli) + codegen(libs.smithy.model) +} + +val generateSdk = tasks.named("smithyBuild") +generateSdk.configure { + resolvedCliClasspath.set(codegen) + runtimeClasspath.set(codegen) + buildClasspath.set(codegen) } -val generateSdk = tasks.register("generateSdk") { - group = "codegen" - classpath = codegen - inputs.file(projectDir.resolve("smithy-build.json")) - inputs.files(codegen) +val optinAnnotations = listOf("kotlin.RequiresOptIn", "aws.smithy.kotlin.runtime.InternalApi") +kotlin.sourceSets.all { + optinAnnotations.forEach { languageSettings.optIn(it) } } -tasks.named("smithyValidate") { - classpath = codegen +kotlin.sourceSets.getByName("main") { + kotlin.srcDir(smithy.getPluginProjectionPath("paginator-tests", "kotlin-codegen").map { it.resolve("src/main/kotlin") }) } tasks.withType { @@ -55,10 +52,9 @@ tasks.test { } dependencies { + compileOnly(project(":codegen:smithy-kotlin-codegen")) implementation(libs.kotlinx.coroutines.core) - - compileOnly(project(":codegen:smithy-kotlin-codegen")) implementation(project(":runtime:runtime-core")) implementation(project(":runtime:smithy-client")) implementation(project(":runtime:protocol:http-client")) diff --git a/tests/codegen/waiter-tests/build.gradle.kts b/tests/codegen/waiter-tests/build.gradle.kts index b2b35b362..025143daf 100644 --- a/tests/codegen/waiter-tests/build.gradle.kts +++ b/tests/codegen/waiter-tests/build.gradle.kts @@ -3,48 +3,47 @@ * SPDX-License-Identifier: Apache-2.0 */ import aws.sdk.kotlin.gradle.dsl.skipPublishing -import software.amazon.smithy.gradle.tasks.SmithyBuild -import software.amazon.smithy.gradle.tasks.Validate as SmithyValidate +import software.amazon.smithy.gradle.tasks.SmithyBuildTask plugins { - kotlin("jvm") - alias(libs.plugins.smithy.gradle) + alias(libs.plugins.kotlin.jvm) + alias(libs.plugins.smithy.gradle.base) } skipPublishing() -val optinAnnotations = listOf("kotlin.RequiresOptIn", "aws.smithy.kotlin.runtime.InternalApi") -kotlin.sourceSets.all { - optinAnnotations.forEach { languageSettings.optIn(it) } -} - -kotlin.sourceSets.getByName("main") { - kotlin.srcDir(layout.buildDirectory.dir("smithyprojections/waiter-tests/waiter-tests/kotlin-codegen/src/main/kotlin")) +smithy { + format.set(false) } -tasks["smithyBuildJar"].enabled = false - val codegen by configurations.creating dependencies { codegen(project(":codegen:smithy-kotlin-codegen")) codegen(libs.smithy.cli) + codegen(libs.smithy.model) +} + +val generateSdk = tasks.named("smithyBuild") +generateSdk.configure { + resolvedCliClasspath.set(codegen) + runtimeClasspath.set(codegen) + buildClasspath.set(codegen) } -val generateSdk = tasks.register("generateSdk") { - group = "codegen" - classpath = codegen - inputs.file(projectDir.resolve("smithy-build.json")) - inputs.files(codegen) +val optinAnnotations = listOf("kotlin.RequiresOptIn", "aws.smithy.kotlin.runtime.InternalApi") +kotlin.sourceSets.all { + optinAnnotations.forEach { languageSettings.optIn(it) } } -tasks.named("smithyValidate") { - classpath = codegen +kotlin.sourceSets.getByName("main") { + kotlin.srcDir(smithy.getPluginProjectionPath("waiter-tests", "kotlin-codegen").map { it.resolve("src/main/kotlin") }) } tasks.withType { dependsOn(generateSdk) kotlinOptions { - allWarningsAsErrors = false // FIXME Generated waiters code contains lots of warnings + // generated code has warnings unfortunately + allWarningsAsErrors = false } } @@ -57,10 +56,9 @@ tasks.test { } dependencies { + compileOnly(project(":codegen:smithy-kotlin-codegen")) implementation(libs.kotlinx.coroutines.core) - - compileOnly(project(":codegen:smithy-kotlin-codegen")) implementation(project(":runtime:runtime-core")) implementation(project(":runtime:smithy-client")) implementation(project(":runtime:protocol:http-client")) From 530e5b432e982ec8eb7ff718638d8bdf955cfe74 Mon Sep 17 00:00:00 2001 From: Aaron J Todd Date: Fri, 22 Dec 2023 12:26:26 -0500 Subject: [PATCH 2/4] refactor to use custom codegen plugin --- build.gradle.kts | 8 ++++- gradle/libs.versions.toml | 1 - .../serde-benchmarks/build.gradle.kts | 30 +++---------------- .../serde-benchmarks/smithy-build.json | 1 + .../nullability-tests/build.gradle.kts | 21 +++++-------- .../nullability-tests/smithy-build.json | 1 + .../codegen/paginator-tests/build.gradle.kts | 21 +++++-------- .../codegen/paginator-tests/smithy-build.json | 1 + tests/codegen/waiter-tests/build.gradle.kts | 21 +++++-------- tests/codegen/waiter-tests/smithy-build.json | 1 + 10 files changed, 36 insertions(+), 70 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index 918fbdc35..69f050c36 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -13,9 +13,15 @@ buildscript { classpath(libs.kotlinx.atomicfu.plugin) // Add our custom gradle plugin(s) to buildscript classpath (comes from github source) + // NOTE: Anything included in our build plugin is added to the classpath for all projects, + // this includes bundled plugins and their versions. As an example the smithy gradle base + // plugin is used by the smithybuild plugin which means you can't apply it with a different + // version directly because it's already on the classpath. + // FIXME - if we publish this plugin it would fix a lot of things classpath("aws.sdk.kotlin:build-plugins") { version { - require("0.3.1") + // require("0.3.1") + branch = "smithy-build-plugin" } } } diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 82c210fda..8f83e7397 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -93,4 +93,3 @@ kotlin-multiplatform = {id = "org.jetbrains.kotlin.multiplatform", version.ref = 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.13.2" } kotlinx-serialization = { id = "org.jetbrains.kotlin.plugin.serialization", version.ref = "kotlin-version"} -smithy-gradle-base = { id = "software.amazon.smithy.gradle.smithy-base", version.ref = "smithy-gradle-version" } diff --git a/tests/benchmarks/serde-benchmarks/build.gradle.kts b/tests/benchmarks/serde-benchmarks/build.gradle.kts index e3354b300..0b48c20ba 100644 --- a/tests/benchmarks/serde-benchmarks/build.gradle.kts +++ b/tests/benchmarks/serde-benchmarks/build.gradle.kts @@ -3,12 +3,11 @@ * SPDX-License-Identifier: Apache-2.0 */ import aws.sdk.kotlin.gradle.dsl.skipPublishing -import software.amazon.smithy.gradle.tasks.SmithyBuildTask plugins { kotlin("multiplatform") alias(libs.plugins.kotlinx.benchmark) - alias(libs.plugins.smithy.gradle.base) + id("aws.sdk.kotlin.gradle.smithybuild") } skipPublishing() @@ -73,36 +72,15 @@ afterEvaluate { } } -smithy { - format.set(false) -} - -val codegen by configurations.creating +val codegen by configurations.getting dependencies { codegen(project(":tests:benchmarks:serde-benchmarks-codegen")) codegen(libs.smithy.cli) codegen(libs.smithy.model) } -// FIXME - probably a bug in smithy gradle base plugin -val configurationsNeededBySmithyGradle = listOf( - "smithyCli", - "smithyBuild", - "runtimeClasspath", -) - .forEach { - configurations.create(it) - } - -val generateSdk = tasks.create("smithyBuild") { - group = "codegen" - resolvedCliClasspath.set(codegen) - runtimeClasspath.set(codegen) - buildClasspath.set(codegen) +tasks.generateSmithyProjections { smithyBuildConfigs.set(files("smithy-build.json")) - val modelFiles = fileTree("model") - modelFiles.include("*.smithy") - models.set(modelFiles) } data class BenchmarkModel(val name: String) { @@ -120,7 +98,7 @@ val benchmarkModels = listOf( val stageGeneratedSources = tasks.register("stageGeneratedSources") { group = "codegen" - dependsOn(generateSdk) + dependsOn(tasks.generateSmithyProjections) doLast { benchmarkModels.forEach { copy { diff --git a/tests/benchmarks/serde-benchmarks/smithy-build.json b/tests/benchmarks/serde-benchmarks/smithy-build.json index 1cd86db66..a6fbe58d7 100644 --- a/tests/benchmarks/serde-benchmarks/smithy-build.json +++ b/tests/benchmarks/serde-benchmarks/smithy-build.json @@ -1,5 +1,6 @@ { "version": "1.0", + "sources": ["model"], "projections": { "twitter": { "transforms": [ diff --git a/tests/codegen/nullability-tests/build.gradle.kts b/tests/codegen/nullability-tests/build.gradle.kts index d951d3cd6..4c1c120dd 100644 --- a/tests/codegen/nullability-tests/build.gradle.kts +++ b/tests/codegen/nullability-tests/build.gradle.kts @@ -2,32 +2,25 @@ * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. * SPDX-License-Identifier: Apache-2.0 */ +import aws.sdk.kotlin.gradle.codegen.smithyKotlinProjectionSrcDir import aws.sdk.kotlin.gradle.dsl.skipPublishing -import software.amazon.smithy.gradle.tasks.SmithyBuildTask plugins { alias(libs.plugins.kotlin.jvm) - alias(libs.plugins.smithy.gradle.base) + id("aws.sdk.kotlin.gradle.smithybuild") } skipPublishing() -smithy { - format.set(false) -} - -val codegen by configurations.creating +val codegen by configurations.getting dependencies { codegen(project(":codegen:smithy-kotlin-codegen")) codegen(libs.smithy.cli) codegen(libs.smithy.model) } -val generateSdk = tasks.named("smithyBuild") -generateSdk.configure { - resolvedCliClasspath.set(codegen) - runtimeClasspath.set(codegen) - buildClasspath.set(codegen) +tasks.generateSmithyProjections { + smithyBuildConfigs.set(files("smithy-build.json")) } val optinAnnotations = listOf("kotlin.RequiresOptIn", "aws.smithy.kotlin.runtime.InternalApi") @@ -42,12 +35,12 @@ val projections = listOf( kotlin.sourceSets.getByName("main") { projections.forEach { projectionName -> - kotlin.srcDir(smithy.getPluginProjectionPath(projectionName, "kotlin-codegen").map { it.resolve("src/main/kotlin") }) + kotlin.srcDir(smithyBuild.smithyKotlinProjectionSrcDir(projectionName)) } } tasks.withType { - dependsOn(generateSdk) + dependsOn(tasks.generateSmithyProjections) // generated code has warnings unfortunately kotlinOptions.allWarningsAsErrors = false } diff --git a/tests/codegen/nullability-tests/smithy-build.json b/tests/codegen/nullability-tests/smithy-build.json index e3fbf90d1..13d01f890 100644 --- a/tests/codegen/nullability-tests/smithy-build.json +++ b/tests/codegen/nullability-tests/smithy-build.json @@ -1,5 +1,6 @@ { "version": "1.0", + "sources": ["model/nullability.smithy"], "projections": { "client-mode": { "transforms": [ diff --git a/tests/codegen/paginator-tests/build.gradle.kts b/tests/codegen/paginator-tests/build.gradle.kts index 167bd2df6..0ef6e1d99 100644 --- a/tests/codegen/paginator-tests/build.gradle.kts +++ b/tests/codegen/paginator-tests/build.gradle.kts @@ -2,32 +2,25 @@ * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. * SPDX-License-Identifier: Apache-2.0 */ +import aws.sdk.kotlin.gradle.codegen.smithyKotlinProjectionSrcDir import aws.sdk.kotlin.gradle.dsl.skipPublishing -import software.amazon.smithy.gradle.tasks.SmithyBuildTask plugins { alias(libs.plugins.kotlin.jvm) - alias(libs.plugins.smithy.gradle.base) + id("aws.sdk.kotlin.gradle.smithybuild") } skipPublishing() -smithy { - format.set(false) -} - -val codegen by configurations.creating +val codegen by configurations.getting dependencies { codegen(project(":codegen:smithy-kotlin-codegen")) codegen(libs.smithy.cli) codegen(libs.smithy.model) } -val generateSdk = tasks.named("smithyBuild") -generateSdk.configure { - resolvedCliClasspath.set(codegen) - runtimeClasspath.set(codegen) - buildClasspath.set(codegen) +tasks.generateSmithyProjections { + smithyBuildConfigs.set(files("smithy-build.json")) } val optinAnnotations = listOf("kotlin.RequiresOptIn", "aws.smithy.kotlin.runtime.InternalApi") @@ -36,11 +29,11 @@ kotlin.sourceSets.all { } kotlin.sourceSets.getByName("main") { - kotlin.srcDir(smithy.getPluginProjectionPath("paginator-tests", "kotlin-codegen").map { it.resolve("src/main/kotlin") }) + kotlin.srcDir(smithyBuild.smithyKotlinProjectionSrcDir("paginator-tests")) } tasks.withType { - dependsOn(generateSdk) + dependsOn(tasks.generateSmithyProjections) } tasks.test { diff --git a/tests/codegen/paginator-tests/smithy-build.json b/tests/codegen/paginator-tests/smithy-build.json index 50865d002..2cedcd719 100644 --- a/tests/codegen/paginator-tests/smithy-build.json +++ b/tests/codegen/paginator-tests/smithy-build.json @@ -1,5 +1,6 @@ { "version": "1.0", + "sources": ["model/paginated-operations.smithy"], "projections": { "paginator-tests": { "transforms": [ diff --git a/tests/codegen/waiter-tests/build.gradle.kts b/tests/codegen/waiter-tests/build.gradle.kts index 025143daf..88dde6eb2 100644 --- a/tests/codegen/waiter-tests/build.gradle.kts +++ b/tests/codegen/waiter-tests/build.gradle.kts @@ -2,32 +2,25 @@ * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. * SPDX-License-Identifier: Apache-2.0 */ +import aws.sdk.kotlin.gradle.codegen.smithyKotlinProjectionSrcDir import aws.sdk.kotlin.gradle.dsl.skipPublishing -import software.amazon.smithy.gradle.tasks.SmithyBuildTask plugins { alias(libs.plugins.kotlin.jvm) - alias(libs.plugins.smithy.gradle.base) + id("aws.sdk.kotlin.gradle.smithybuild") } skipPublishing() -smithy { - format.set(false) -} - -val codegen by configurations.creating +val codegen by configurations.getting dependencies { codegen(project(":codegen:smithy-kotlin-codegen")) codegen(libs.smithy.cli) codegen(libs.smithy.model) } -val generateSdk = tasks.named("smithyBuild") -generateSdk.configure { - resolvedCliClasspath.set(codegen) - runtimeClasspath.set(codegen) - buildClasspath.set(codegen) +tasks.generateSmithyProjections { + smithyBuildConfigs.set(files("smithy-build.json")) } val optinAnnotations = listOf("kotlin.RequiresOptIn", "aws.smithy.kotlin.runtime.InternalApi") @@ -36,11 +29,11 @@ kotlin.sourceSets.all { } kotlin.sourceSets.getByName("main") { - kotlin.srcDir(smithy.getPluginProjectionPath("waiter-tests", "kotlin-codegen").map { it.resolve("src/main/kotlin") }) + kotlin.srcDir(smithyBuild.smithyKotlinProjectionSrcDir("waiter-tests")) } tasks.withType { - dependsOn(generateSdk) + dependsOn(tasks.generateSmithyProjections) kotlinOptions { // generated code has warnings unfortunately allWarningsAsErrors = false diff --git a/tests/codegen/waiter-tests/smithy-build.json b/tests/codegen/waiter-tests/smithy-build.json index b21592868..73b9d3978 100644 --- a/tests/codegen/waiter-tests/smithy-build.json +++ b/tests/codegen/waiter-tests/smithy-build.json @@ -1,5 +1,6 @@ { "version": "1.0", + "sources": ["model"], "projections": { "waiter-tests": { "transforms": [ From 16f58ec73bbf8703b2bfcb9514066239c6511cf4 Mon Sep 17 00:00:00 2001 From: Aaron J Todd Date: Thu, 28 Dec 2023 16:07:11 -0500 Subject: [PATCH 3/4] remove unused repos --- settings.gradle.kts | 2 -- 1 file changed, 2 deletions(-) diff --git a/settings.gradle.kts b/settings.gradle.kts index 7924e2c8d..1b97b3a8b 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -7,8 +7,6 @@ pluginManagement { repositories { mavenLocal() mavenCentral() - maven("https://plugins.gradle.org/m2/") - google() gradlePluginPortal() } } From eaa4fa832c216061f07e3310beb71c7bb14af992 Mon Sep 17 00:00:00 2001 From: Aaron J Todd Date: Fri, 29 Dec 2023 14:02:10 -0500 Subject: [PATCH 4/4] use released plugin version --- build.gradle.kts | 3 +-- tests/codegen/nullability-tests/build.gradle.kts | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index 69f050c36..87edd398f 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -20,8 +20,7 @@ buildscript { // FIXME - if we publish this plugin it would fix a lot of things classpath("aws.sdk.kotlin:build-plugins") { version { - // require("0.3.1") - branch = "smithy-build-plugin" + require("0.3.2") } } } diff --git a/tests/codegen/nullability-tests/build.gradle.kts b/tests/codegen/nullability-tests/build.gradle.kts index 4c1c120dd..2680c48bb 100644 --- a/tests/codegen/nullability-tests/build.gradle.kts +++ b/tests/codegen/nullability-tests/build.gradle.kts @@ -41,7 +41,7 @@ kotlin.sourceSets.getByName("main") { tasks.withType { dependsOn(tasks.generateSmithyProjections) - // generated code has warnings unfortunately + // FIXME - generated code has warnings unfortunately, see https://github.com/awslabs/aws-sdk-kotlin/issues/1169 kotlinOptions.allWarningsAsErrors = false }