diff --git a/aws-runtime/aws-config/build.gradle.kts b/aws-runtime/aws-config/build.gradle.kts index 3d3759115d8..babd65e86c1 100644 --- a/aws-runtime/aws-config/build.gradle.kts +++ b/aws-runtime/aws-config/build.gradle.kts @@ -203,18 +203,10 @@ NOTE: We need the following tasks to depend on codegen for gradle caching/up-to- */ tasks.withType { dependsOn(tasks.generateSmithyProjections) - - compilerOptions { - // generated sts/sso credential providers have quite a few warnings - allWarningsAsErrors.set(false) - } } tasks.withType { dependsOn(tasks.generateSmithyProjections) - compilerOptions { - allWarningsAsErrors.set(false) - } } tasks.withType { diff --git a/aws-runtime/aws-config/common/src/aws/sdk/kotlin/runtime/auth/credentials/ImdsCredentialsProvider.kt b/aws-runtime/aws-config/common/src/aws/sdk/kotlin/runtime/auth/credentials/ImdsCredentialsProvider.kt index 495e3d810d6..c717f8e82e2 100644 --- a/aws-runtime/aws-config/common/src/aws/sdk/kotlin/runtime/auth/credentials/ImdsCredentialsProvider.kt +++ b/aws-runtime/aws-config/common/src/aws/sdk/kotlin/runtime/auth/credentials/ImdsCredentialsProvider.kt @@ -132,7 +132,7 @@ public class ImdsCredentialsProvider( private suspend fun loadProfile() = try { client.value.get(CREDENTIALS_BASE_PATH) } catch (ex: EC2MetadataError) { - if (ex.statusCode == HttpStatusCode.NotFound.value) { + if (ex.status == HttpStatusCode.NotFound) { coroutineContext.info { "Received 404 from IMDS when loading profile information. Hint: This instance may not have an " + "IAM role associated." @@ -142,7 +142,7 @@ public class ImdsCredentialsProvider( } private suspend fun useCachedCredentials(ex: Exception): Credentials? = when { - ex is IOException || ex is EC2MetadataError && ex.statusCode == HttpStatusCode.InternalServerError.value -> { + ex is IOException || ex is EC2MetadataError && ex.status == HttpStatusCode.InternalServerError -> { mu.withLock { previousCredentials?.apply { nextRefresh = clock.now() + DEFAULT_CREDENTIALS_REFRESH_SECONDS.seconds } } diff --git a/aws-runtime/aws-config/common/src/aws/sdk/kotlin/runtime/config/endpoints/AccountIdEndpointMode.kt b/aws-runtime/aws-config/common/src/aws/sdk/kotlin/runtime/config/endpoints/AccountIdEndpointMode.kt index 24380c45eda..3de53aec84d 100644 --- a/aws-runtime/aws-config/common/src/aws/sdk/kotlin/runtime/config/endpoints/AccountIdEndpointMode.kt +++ b/aws-runtime/aws-config/common/src/aws/sdk/kotlin/runtime/config/endpoints/AccountIdEndpointMode.kt @@ -35,5 +35,4 @@ public fun AccountIdEndpointMode.toBusinessMetric(): BusinessMetric = when (this AccountIdEndpointMode.PREFERRED -> SmithyBusinessMetric.ACCOUNT_ID_MODE_PREFERRED AccountIdEndpointMode.DISABLED -> SmithyBusinessMetric.ACCOUNT_ID_MODE_DISABLED AccountIdEndpointMode.REQUIRED -> SmithyBusinessMetric.ACCOUNT_ID_MODE_REQUIRED - else -> throw IllegalStateException("Unexpected AccountIdEndpointMode value: ${this::class.simpleName}") } diff --git a/aws-runtime/aws-config/common/src/aws/sdk/kotlin/runtime/config/imds/TokenMiddleware.kt b/aws-runtime/aws-config/common/src/aws/sdk/kotlin/runtime/config/imds/TokenMiddleware.kt index 68a862b0661..12f03ba8b5c 100644 --- a/aws-runtime/aws-config/common/src/aws/sdk/kotlin/runtime/config/imds/TokenMiddleware.kt +++ b/aws-runtime/aws-config/common/src/aws/sdk/kotlin/runtime/config/imds/TokenMiddleware.kt @@ -66,8 +66,8 @@ internal class TokenMiddleware( return try { when (call.response.status) { HttpStatusCode.OK -> { - val ttl = call.response.headers[X_AWS_EC2_METADATA_TOKEN_TTL_SECONDS]?.toLong() ?: throw EC2MetadataError(200, "No TTL provided in IMDS response") - val token = call.response.body.readAll() ?: throw EC2MetadataError(200, "No token provided in IMDS response") + val ttl = call.response.headers[X_AWS_EC2_METADATA_TOKEN_TTL_SECONDS]?.toLong() ?: throw EC2MetadataError(call.response.status, "No TTL provided in IMDS response") + val token = call.response.body.readAll() ?: throw EC2MetadataError(call.response.status, "No token provided in IMDS response") val expires = clock.now() + ttl.seconds Token(token, expires) } @@ -76,7 +76,7 @@ internal class TokenMiddleware( HttpStatusCode.Forbidden -> "Request forbidden: IMDS is disabled or the caller has insufficient permissions." else -> "Failed to retrieve IMDS token" } - throw EC2MetadataError(call.response.status.value, message) + throw EC2MetadataError(call.response.status, message) } } } finally { diff --git a/aws-runtime/aws-config/common/test/aws/sdk/kotlin/runtime/config/imds/ImdsClientTest.kt b/aws-runtime/aws-config/common/test/aws/sdk/kotlin/runtime/config/imds/ImdsClientTest.kt index 4d492a000e5..59c52d7106c 100644 --- a/aws-runtime/aws-config/common/test/aws/sdk/kotlin/runtime/config/imds/ImdsClientTest.kt +++ b/aws-runtime/aws-config/common/test/aws/sdk/kotlin/runtime/config/imds/ImdsClientTest.kt @@ -200,7 +200,7 @@ class ImdsClientTest { client.get("/latest/metadata") } - assertEquals(HttpStatusCode.Forbidden.value, ex.statusCode) + assertEquals(HttpStatusCode.Forbidden, ex.status) connection.assertRequests() } diff --git a/build.gradle.kts b/build.gradle.kts index e027ebcf246..68f3b665dcc 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -5,6 +5,7 @@ import aws.sdk.kotlin.gradle.dsl.configureLinting import aws.sdk.kotlin.gradle.dsl.configureNexus import aws.sdk.kotlin.gradle.util.typedProp +import org.jetbrains.kotlin.gradle.tasks.KotlinCompile buildscript { // NOTE: buildscript classpath for the root project is the parent classloader for the subprojects, we @@ -38,9 +39,9 @@ val testJavaVersion = typedProp("test.java.version")?.let { } allprojects { - if (rootProject.typedProp("kotlinWarningsAsErrors") == true) { - tasks.withType { - compilerOptions.allWarningsAsErrors = true + tasks.withType { + compilerOptions { + allWarningsAsErrors = true } } diff --git a/codegen/aws-sdk-codegen/src/main/kotlin/aws/sdk/kotlin/codegen/ServiceClientCompanionObjectWriter.kt b/codegen/aws-sdk-codegen/src/main/kotlin/aws/sdk/kotlin/codegen/ServiceClientCompanionObjectWriter.kt index 6f566ba75de..05015161240 100644 --- a/codegen/aws-sdk-codegen/src/main/kotlin/aws/sdk/kotlin/codegen/ServiceClientCompanionObjectWriter.kt +++ b/codegen/aws-sdk-codegen/src/main/kotlin/aws/sdk/kotlin/codegen/ServiceClientCompanionObjectWriter.kt @@ -73,6 +73,6 @@ internal fun String.toEndpointUrlConfigNames(): EndpointUrlConfigNames = Endpoin // for our client names // e.g. sdkId "Elasticsearch Service" -> client name "ElasticsearchClient", prop "aws.endpointUrlElasticsearch" private object JvmSystemPropertySuffix : StringTransformer { - override fun transform(id: String): String = - id.toPascalCase().removeSuffix("Service") + override fun transform(input: String): String = + input.toPascalCase().removeSuffix("Service") } diff --git a/dokka-aws/build.gradle.kts b/dokka-aws/build.gradle.kts index c97a4bdd0df..6cfe6d21261 100644 --- a/dokka-aws/build.gradle.kts +++ b/dokka-aws/build.gradle.kts @@ -36,7 +36,6 @@ tasks.withType { compilerOptions { jvmTarget.set(JvmTarget.JVM_1_8) freeCompilerArgs.add("-Xjdk-release=1.8") - allWarningsAsErrors.set(false) // FIXME Dokka bundles stdlib into the classpath, causing an unfixable warning } } diff --git a/hll/build.gradle.kts b/hll/build.gradle.kts index 7b16a91885f..e2e8ded84b5 100644 --- a/hll/build.gradle.kts +++ b/hll/build.gradle.kts @@ -70,6 +70,12 @@ subprojects { optinAnnotations.forEach(languageSettings::optIn) } + named("commonMain") { + dependencies { + api(project(":aws-runtime:aws-core")) // for InternalSdkApi annotation + } + } + named("commonTest") { dependencies { implementation(libraries.kotest.assertions.core) diff --git a/hll/dynamodb-mapper/dynamodb-mapper-schema-generator-plugin/build.gradle.kts b/hll/dynamodb-mapper/dynamodb-mapper-schema-generator-plugin/build.gradle.kts index 600a93c0929..df6752c7adb 100644 --- a/hll/dynamodb-mapper/dynamodb-mapper-schema-generator-plugin/build.gradle.kts +++ b/hll/dynamodb-mapper/dynamodb-mapper-schema-generator-plugin/build.gradle.kts @@ -151,6 +151,9 @@ tasks.withType { dependsOn(generateSdkVersionFile) dependsOn(generateKotlinVersionFile) dependsOn(generateSmithyKotlinVersionFile) + compilerOptions { + allWarningsAsErrors = false // FIXME Re-enable warnings as errors SDK-KT-787 + } } tasks.withType { diff --git a/services/build.gradle.kts b/services/build.gradle.kts index af781794fbe..ca9cbe02e6a 100644 --- a/services/build.gradle.kts +++ b/services/build.gradle.kts @@ -129,7 +129,7 @@ subprojects { tasks.withType { compilerOptions { - allWarningsAsErrors.set(false) // FIXME Tons of errors occur in generated code + allWarningsAsErrors.set(false) // FIXME Tons of errors occur in generated code. Can we work around errors from deprecated service fields / APIs? jvmTarget.set(JvmTarget.JVM_1_8) // fixes outgoing variant metadata: https://github.com/smithy-lang/smithy-kotlin/issues/258 freeCompilerArgs.add("-Xjdk-release=1.8") } diff --git a/tests/codegen/build.gradle.kts b/tests/codegen/build.gradle.kts index ecdae5f6ccc..6d7d81bb201 100644 --- a/tests/codegen/build.gradle.kts +++ b/tests/codegen/build.gradle.kts @@ -32,7 +32,6 @@ subprojects { tasks.withType { dependsOn(tasks.generateSmithyProjections) - compilerOptions.allWarningsAsErrors = false } tasks.generateSmithyProjections {