33 * SPDX-License-Identifier: Apache-2.0
44 */
55
6- import aws.sdk.kotlin.gradle.codegen.dsl.generateSmithyProjections
76import aws.sdk.kotlin.gradle.codegen.dsl.smithyKotlinPlugin
8- import aws.sdk.kotlin.gradle.codegen.smithyKotlinProjectionSrcDir
7+ import aws.sdk.kotlin.shared.CodegenTest
8+ import aws.sdk.kotlin.shared.Model
99
10- plugins {
11- alias(libs.plugins.kotlin.jvm)
12- alias(libs.plugins.aws.kotlin.repo.tools.smithybuild)
13- }
14-
15- description = " Smithy rules engine codegen integration test suite"
16-
17- data class Test (
18- val projectionName : String ,
19- val protocolName : String ,
20- val modelTemplate : File ,
21- ) {
22- val model: File
23- get() = layout.buildDirectory.file(" $projectionName /model.smithy" ).get().asFile
24- }
10+ description = " AWS SDK for Kotlin's rules engine codegen integration test suite"
2511
2612val tests = listOf (
27- Test (" operationContextParams" , " operationContextParams" , file(" operation-context-params.smithy" )),
13+ CodegenTest (
14+ " operationContextParams" ,
15+ Model (" operation-context-params.smithy" ),
16+ " aws.sdk.kotlin.test#TestService" ,
17+ ),
2818)
2919
30- fun fillInModel (output : File , protocolName : String , template : File ) {
31- val input = template.readText()
32- val opTraits = when (protocolName) {
33- " restJson1" , " restXml" -> """ @http(method: "POST", uri: "/test-eventstream", code: 200)"""
34- else -> " "
35- }
36- val replaced = input
37- .replace(" {protocol-name}" , protocolName)
38- .replace(" {op-traits}" , opTraits)
39-
40- output.parentFile.mkdirs()
41- output.writeText(replaced)
42- }
43-
44- val testServiceShapeId = " aws.sdk.kotlin.test#TestService"
4520smithyBuild {
4621 tests.forEach { test ->
47-
48- projections.register(test.projectionName) {
49- imports = listOf (test.model.absolutePath)
22+ projections.register(test.name) {
23+ imports = listOf (layout.projectDirectory.file(test.model.path + test.model.fileName).asFile.absolutePath)
5024 transforms = listOf (
5125 """
5226 {
5327 "name": "includeServices",
5428 "args": {
55- "services": ["$testServiceShapeId "]
29+ "services": ["${test.serviceShapeId} "]
5630 }
5731 }
5832 """ ,
5933 )
60-
6134 smithyKotlinPlugin {
62- serviceShapeId = testServiceShapeId
63- packageName = " aws.sdk.kotlin.test.${test.projectionName .lowercase()} "
35+ serviceShapeId = test.serviceShapeId
36+ packageName = " aws.sdk.kotlin.test.${test.name .lowercase()} "
6437 packageVersion = " 1.0"
6538 buildSettings {
6639 generateFullProject = false
@@ -74,85 +47,3 @@ smithyBuild {
7447 }
7548 }
7649}
77-
78- val codegen by configurations.getting
79- dependencies {
80- codegen(project(" :codegen:aws-sdk-codegen" ))
81- codegen(libs.smithy.cli)
82- codegen(libs.smithy.model)
83- }
84-
85- tasks.generateSmithyBuild {
86- doFirst {
87- tests.forEach { test -> fillInModel(test.model, test.protocolName, test.modelTemplate) }
88- }
89- }
90-
91- tasks.generateSmithyProjections {
92- doFirst {
93- // ensure the generated tests use the same version of the runtime as the aws aws-runtime
94- val smithyKotlinRuntimeVersion = libs.versions.smithy.kotlin.runtime.version.get()
95- System .setProperty(" smithy.kotlin.codegen.clientRuntimeVersion" , smithyKotlinRuntimeVersion)
96- }
97- }
98-
99- val optinAnnotations = listOf (
100- " kotlin.RequiresOptIn" ,
101- " aws.smithy.kotlin.runtime.InternalApi" ,
102- " aws.sdk.kotlin.runtime.InternalSdkApi" ,
103- )
104-
105- kotlin.sourceSets.all {
106- optinAnnotations.forEach { languageSettings.optIn(it) }
107- }
108-
109- kotlin.sourceSets.getByName(" test" ) {
110- smithyBuild.projections.forEach {
111- kotlin.srcDir(smithyBuild.smithyKotlinProjectionSrcDir(it.name))
112- }
113- }
114-
115- tasks.withType< org.jetbrains.kotlin.gradle.tasks.KotlinCompile > {
116- dependsOn(tasks.generateSmithyProjections)
117- // generated clients have quite a few warnings
118- kotlinOptions.allWarningsAsErrors = false
119- }
120-
121- tasks.test {
122- useJUnitPlatform()
123- testLogging {
124- events(" passed" , " skipped" , " failed" )
125- showStandardStreams = true
126- showStackTraces = true
127- showExceptions = true
128- exceptionFormat = org.gradle.api.tasks.testing.logging.TestExceptionFormat .FULL
129- }
130- }
131-
132- dependencies {
133-
134- implementation(libs.kotlinx.coroutines.core)
135-
136- testImplementation(libs.kotlin.test)
137- testImplementation(libs.kotlin.test.junit5)
138- testImplementation(libs.kotlinx.coroutines.test)
139-
140- testImplementation(libs.smithy.kotlin.smithy.test)
141- testImplementation(libs.smithy.kotlin.aws.signing.default)
142- testImplementation(libs.smithy.kotlin.telemetry.api)
143-
144- // have to manually add all the dependencies of the generated client(s)
145- // doing it this way (as opposed to doing what we do for protocol-tests) allows
146- // the tests to work without a publish to maven-local step at the cost of maintaining
147- // this set of dependencies manually
148- // <-- BEGIN GENERATED DEPENDENCY LIST -->
149- implementation(libs.bundles.smithy.kotlin.service.client)
150- implementation(libs.smithy.kotlin.aws.event.stream)
151- implementation(project(" :aws-runtime:aws-http" ))
152- implementation(libs.smithy.kotlin.aws.json.protocols)
153- implementation(libs.smithy.kotlin.serde.json)
154- api(project(" :aws-runtime:aws-config" ))
155- api(project(" :aws-runtime:aws-core" ))
156- api(project(" :aws-runtime:aws-endpoint" ))
157- // <-- END GENERATED DEPENDENCY LIST -->
158- }
0 commit comments