diff --git a/aws-runtime/aws-config/build.gradle.kts b/aws-runtime/aws-config/build.gradle.kts index f63ff328e44..e03be72f500 100644 --- a/aws-runtime/aws-config/build.gradle.kts +++ b/aws-runtime/aws-config/build.gradle.kts @@ -41,9 +41,6 @@ kotlin { // additional dependencies required by generated sso provider(s) implementation(libs.smithy.kotlin.aws.json.protocols) - // atomics - implementation(libs.kotlinx.atomicfu) - // coroutines implementation(libs.kotlinx.coroutines.core) } @@ -70,7 +67,7 @@ kotlin { } fun awsModelFile(name: String): String = - rootProject.file("codegen/sdk/aws-models/$name").relativeTo(project.buildDir).toString() + rootProject.file("codegen/sdk/aws-models/$name").relativeTo(project.layout.buildDirectory.get().asFile).toString() codegen { val basePackage = "aws.sdk.kotlin.runtime.auth.credentials.internal" @@ -200,13 +197,17 @@ val codegenTask = tasks.named("generateSmithyProjections") tasks.withType { dependsOn(codegenTask) - // generated sts/sso credential providers have quite a few warnings - kotlinOptions.allWarningsAsErrors = false + compilerOptions { + // generated sts/sso credential providers have quite a few warnings + allWarningsAsErrors.set(false) + } } tasks.withType { dependsOn(codegenTask) - kotlinOptions.allWarningsAsErrors = false + compilerOptions { + allWarningsAsErrors.set(false) + } } tasks.withType { @@ -243,6 +244,7 @@ listOf("apiElements", "runtimeElements").forEach { // suppress internal generated clients tasks.named("dokkaHtmlPartial") { + dependsOn(codegenTask) dokkaSourceSets.configureEach { perPackageOption { matchingRegex.set(""".*\.internal.*""") diff --git a/aws-runtime/build.gradle.kts b/aws-runtime/build.gradle.kts index 3a1195ec12a..0365c85dee7 100644 --- a/aws-runtime/build.gradle.kts +++ b/aws-runtime/build.gradle.kts @@ -4,10 +4,10 @@ */ import aws.sdk.kotlin.gradle.dsl.configurePublishing import aws.sdk.kotlin.gradle.kmp.* +import org.jetbrains.kotlin.gradle.dsl.JvmTarget 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 { alias(libs.plugins.dokka) alias(libs.plugins.kotlinx.binary.compatibility.validator) @@ -64,8 +64,14 @@ subprojects { } tasks.withType { - kotlinOptions { - jvmTarget = "1.8" + compilerOptions { + jvmTarget.set(JvmTarget.JVM_1_8) + freeCompilerArgs.add("-Xexpect-actual-classes") + } + } + tasks.withType { + compilerOptions { + freeCompilerArgs.add("-Xexpect-actual-classes") } } } diff --git a/build.gradle.kts b/build.gradle.kts index 66d285405d8..b86cd23d06e 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -14,15 +14,18 @@ buildscript { classpath(libs.kotlinx.atomicfu.plugin) classpath("aws.sdk.kotlin:build-plugins") { version { - require("0.2.9") + require("0.3.0") } } } } plugins { - @Suppress("DSL_SCOPE_VIOLATION") // TODO: Remove once https://youtrack.jetbrains.com/issue/KTIJ-19369 is fixed alias(libs.plugins.dokka) + // ensure the correct version of KGP ends up on our buildscript classpath + // since build-plugins also has version in its dependency closure + alias(libs.plugins.kotlin.multiplatform) apply false + alias(libs.plugins.kotlin.jvm) apply false } // configures (KMP) subprojects with our own KMP conventions and some default dependencies diff --git a/codegen/aws-sdk-codegen/build.gradle.kts b/codegen/aws-sdk-codegen/build.gradle.kts index 016d42acdcf..ce08be55758 100644 --- a/codegen/aws-sdk-codegen/build.gradle.kts +++ b/codegen/aws-sdk-codegen/build.gradle.kts @@ -1,9 +1,16 @@ +/* + * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 + */ +import org.jetbrains.kotlin.gradle.dsl.JvmTarget +import org.jetbrains.kotlin.gradle.tasks.KotlinCompile + /* * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. * SPDX-License-Identifier: Apache-2.0 */ plugins { - kotlin("jvm") + alias(libs.plugins.kotlin.jvm) jacoco } @@ -38,7 +45,7 @@ dependencies { val generateSdkRuntimeVersion by tasks.registering { // generate the version of the runtime to use as a resource. // this keeps us from having to manually change version numbers in multiple places - val resourcesDir = "$buildDir/resources/main/aws/sdk/kotlin/codegen" + val resourcesDir = layout.buildDirectory.dir("resources/main/aws/sdk/kotlin/codegen").get() val versionFile = file("$resourcesDir/sdk-version.txt") val gradlePropertiesFile = rootProject.file("gradle.properties") inputs.file(gradlePropertiesFile) @@ -49,20 +56,16 @@ val generateSdkRuntimeVersion by tasks.registering { } } -val jvmTargetVersion = JavaVersion.VERSION_17.toString() - -tasks.compileKotlin { - kotlinOptions.jvmTarget = jvmTargetVersion +tasks.withType { + compilerOptions { + jvmTarget.set(JvmTarget.JVM_1_8) + } dependsOn(generateSdkRuntimeVersion) } -tasks.compileTestKotlin { - kotlinOptions.jvmTarget = jvmTargetVersion -} - tasks.withType { - sourceCompatibility = jvmTargetVersion - targetCompatibility = jvmTargetVersion + sourceCompatibility = JavaVersion.VERSION_1_8.toString() + targetCompatibility = JavaVersion.VERSION_1_8.toString() } // Reusable license copySpec @@ -94,9 +97,9 @@ tasks.test { // Configure jacoco (code coverage) to generate an HTML report tasks.jacocoTestReport { reports { - xml.isEnabled = false - csv.isEnabled = false - html.destination = file("$buildDir/reports/jacoco") + xml.required.set(false) + csv.required.set(false) + html.outputLocation.set(layout.buildDirectory.dir("reports/jacoco")) } } diff --git a/codegen/aws-sdk-codegen/src/main/kotlin/aws/sdk/kotlin/codegen/GradleGenerator.kt b/codegen/aws-sdk-codegen/src/main/kotlin/aws/sdk/kotlin/codegen/GradleGenerator.kt index 3a478c7d17f..0cae160ab7b 100644 --- a/codegen/aws-sdk-codegen/src/main/kotlin/aws/sdk/kotlin/codegen/GradleGenerator.kt +++ b/codegen/aws-sdk-codegen/src/main/kotlin/aws/sdk/kotlin/codegen/GradleGenerator.kt @@ -45,8 +45,6 @@ class GradleGenerator : KotlinIntegration { writer.write("project.ext.set(#S, #S)", "aws.sdk.id", ctx.settings.sdkId) writer.write("") - writer.write("val kotlinVersion: String by project") - val allDependencies = delegator.dependencies.mapNotNull { it.properties["dependency"] as? KotlinDependency }.distinct() writer diff --git a/codegen/smithy-aws-kotlin-codegen/build.gradle.kts b/codegen/smithy-aws-kotlin-codegen/build.gradle.kts index a4b32102efa..f864936ae37 100644 --- a/codegen/smithy-aws-kotlin-codegen/build.gradle.kts +++ b/codegen/smithy-aws-kotlin-codegen/build.gradle.kts @@ -1,9 +1,16 @@ +/* + * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 + */ +import org.jetbrains.kotlin.gradle.dsl.JvmTarget +import org.jetbrains.kotlin.gradle.tasks.KotlinCompile + /* * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. * SPDX-License-Identifier: Apache-2.0 */ plugins { - kotlin("jvm") + alias(libs.plugins.kotlin.jvm) jacoco } @@ -34,19 +41,15 @@ dependencies { testImplementation(libs.kotlinx.serialization.json) } -val jvmTargetVersion = JavaVersion.VERSION_17.toString() - -tasks.compileKotlin { - kotlinOptions.jvmTarget = jvmTargetVersion -} - -tasks.compileTestKotlin { - kotlinOptions.jvmTarget = jvmTargetVersion +tasks.withType { + compilerOptions { + jvmTarget.set(JvmTarget.JVM_1_8) + } } tasks.withType { - sourceCompatibility = jvmTargetVersion - targetCompatibility = jvmTargetVersion + sourceCompatibility = JavaVersion.VERSION_1_8.toString() + targetCompatibility = JavaVersion.VERSION_1_8.toString() } // Reusable license copySpec @@ -78,9 +81,9 @@ tasks.test { // Configure jacoco (code coverage) to generate an HTML report tasks.jacocoTestReport { reports { - xml.isEnabled = false - csv.isEnabled = false - html.destination = file("$buildDir/reports/jacoco") + xml.required.set(false) + csv.required.set(false) + html.outputLocation.set(layout.buildDirectory.dir("reports/jacoco")) } } diff --git a/dokka-aws/build.gradle.kts b/dokka-aws/build.gradle.kts index f469a769443..e93f6aeb756 100644 --- a/dokka-aws/build.gradle.kts +++ b/dokka-aws/build.gradle.kts @@ -1,9 +1,16 @@ +/* + * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 + */ +import org.jetbrains.kotlin.gradle.dsl.JvmTarget +import org.jetbrains.kotlin.gradle.tasks.KotlinCompile + /* * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. * SPDX-License-Identifier: Apache-2.0 */ plugins { - kotlin("jvm") + alias(libs.plugins.kotlin.jvm) } description = "Custom Dokka plugin for AWS Kotlin SDK API docs" @@ -13,9 +20,14 @@ dependencies { compileOnly(libs.dokka.core) } -tasks.withType { - kotlinOptions { - jvmTarget = "1.8" - allWarningsAsErrors = false // FIXME Dokka bundles stdlib into the classpath, causing an unfixable warning +tasks.withType { + compilerOptions { + jvmTarget.set(JvmTarget.JVM_1_8) + allWarningsAsErrors.set(false) // FIXME Dokka bundles stdlib into the classpath, causing an unfixable warning } } + +tasks.withType { + sourceCompatibility = JavaVersion.VERSION_1_8.toString() + targetCompatibility = JavaVersion.VERSION_1_8.toString() +} diff --git a/gradle.properties b/gradle.properties index ee25ba8ffe6..645bc23f6bd 100644 --- a/gradle.properties +++ b/gradle.properties @@ -8,11 +8,10 @@ org.gradle.jvmargs=-Xmx6g -XX:MaxMetaspaceSize=2G # sdk sdkVersion=1.0.18-SNAPSHOT -# kotlin -kotlinVersion=1.9.20 - # dokka config (values specified at build-time as needed) smithyKotlinDocBaseUrl=https://sdk.amazonaws.com/kotlin/api/smithy-kotlin/api/$smithyKotlinRuntimeVersion/ # atomicfu -kotlinx.atomicfu.enableJvmIrTransformation=true \ No newline at end of file +kotlinx.atomicfu.enableJvmIrTransformation=true +# FIXME - https://github.com/Kotlin/kotlinx-atomicfu/issues/274 +kotlinx.atomicfu.enableNativeIrTransformation=false diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 62be89ec553..a930e952a15 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -1,10 +1,10 @@ [versions] -kotlin-version = "1.9.20" +kotlin-version = "1.9.21" dokka-version = "1.9.10" # libs coroutines-version = "1.7.3" -atomicfu-version = "0.22.0" +atomicfu-version = "0.23.1" # smithy-kotlin codegen and runtime are versioned separately smithy-kotlin-runtime-version = "1.0.4" diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index 7454180f2ae..afba109285a 100644 Binary files a/gradle/wrapper/gradle-wrapper.jar and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 068cdb2dc26..3499ded5c11 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-7.6.3-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-bin.zip +networkTimeout=10000 zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/gradlew b/gradlew index 1b6c787337f..65dcd68d65c 100755 --- a/gradlew +++ b/gradlew @@ -55,7 +55,7 @@ # Darwin, MinGW, and NonStop. # # (3) This script is generated from the Groovy template -# https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt # within the Gradle project. # # You can find Gradle at https://github.com/gradle/gradle/. @@ -80,10 +80,10 @@ do esac done -APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit - -APP_NAME="Gradle" +# This is normally unused +# shellcheck disable=SC2034 APP_BASE_NAME=${0##*/} +APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' @@ -143,12 +143,16 @@ fi if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then case $MAX_FD in #( max*) + # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked. + # shellcheck disable=SC3045 MAX_FD=$( ulimit -H -n ) || warn "Could not query maximum file descriptor limit" esac case $MAX_FD in #( '' | soft) :;; #( *) + # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked. + # shellcheck disable=SC3045 ulimit -n "$MAX_FD" || warn "Could not set maximum file descriptor limit to $MAX_FD" esac @@ -205,6 +209,12 @@ set -- \ org.gradle.wrapper.GradleWrapperMain \ "$@" +# Stop when "xargs" is not available. +if ! command -v xargs >/dev/null 2>&1 +then + die "xargs is not available" +fi + # Use "xargs" to parse quoted args. # # With -n1 it outputs one arg per line, with the quotes and backslashes removed. diff --git a/gradlew.bat b/gradlew.bat index ac1b06f9382..6689b85beec 100644 --- a/gradlew.bat +++ b/gradlew.bat @@ -14,7 +14,7 @@ @rem limitations under the License. @rem -@if "%DEBUG%" == "" @echo off +@if "%DEBUG%"=="" @echo off @rem ########################################################################## @rem @rem Gradle startup script for Windows @@ -25,7 +25,8 @@ if "%OS%"=="Windows_NT" setlocal set DIRNAME=%~dp0 -if "%DIRNAME%" == "" set DIRNAME=. +if "%DIRNAME%"=="" set DIRNAME=. +@rem This is normally unused set APP_BASE_NAME=%~n0 set APP_HOME=%DIRNAME% @@ -40,7 +41,7 @@ if defined JAVA_HOME goto findJavaFromJavaHome set JAVA_EXE=java.exe %JAVA_EXE% -version >NUL 2>&1 -if "%ERRORLEVEL%" == "0" goto execute +if %ERRORLEVEL% equ 0 goto execute echo. echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. @@ -75,13 +76,15 @@ set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar :end @rem End local scope for the variables with windows NT shell -if "%ERRORLEVEL%"=="0" goto mainEnd +if %ERRORLEVEL% equ 0 goto mainEnd :fail rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of rem the _cmd.exe /c_ return code! -if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 -exit /b 1 +set EXIT_CODE=%ERRORLEVEL% +if %EXIT_CODE% equ 0 set EXIT_CODE=1 +if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% +exit /b %EXIT_CODE% :mainEnd if "%OS%"=="Windows_NT" endlocal diff --git a/services/build.gradle.kts b/services/build.gradle.kts index c69d367bac7..e5912af66ea 100644 --- a/services/build.gradle.kts +++ b/services/build.gradle.kts @@ -5,11 +5,11 @@ import aws.sdk.kotlin.gradle.dsl.configurePublishing import aws.sdk.kotlin.gradle.kmp.* import aws.sdk.kotlin.gradle.util.typedProp +import org.jetbrains.kotlin.gradle.dsl.JvmTarget import java.time.LocalDateTime plugins { `maven-publish` - @Suppress("DSL_SCOPE_VIOLATION") // TODO: Remove once https://youtrack.jetbrains.com/issue/KTIJ-19369 is fixed alias(libs.plugins.dokka) } @@ -117,9 +117,9 @@ subprojects { } tasks.withType { - kotlinOptions { - allWarningsAsErrors = false // FIXME Tons of errors occur in generated code - jvmTarget = "1.8" // fixes outgoing variant metadata: https://github.com/awslabs/smithy-kotlin/issues/258 + compilerOptions { + allWarningsAsErrors.set(false) // FIXME Tons of errors occur in generated code + jvmTarget.set(JvmTarget.JVM_1_8) // fixes outgoing variant metadata: https://github.com/awslabs/smithy-kotlin/issues/258 } } diff --git a/settings.gradle.kts b/settings.gradle.kts index 56e0ff1fd14..84aa67eb10b 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -9,13 +9,6 @@ pluginManagement { mavenCentral() gradlePluginPortal() } - - // configure default plugin versions - plugins { - val kotlinVersion: String by settings - id("org.jetbrains.kotlin.jvm") version kotlinVersion - id("org.jetbrains.kotlin.multiplatform") version kotlinVersion - } } dependencyResolutionManagement { diff --git a/tests/benchmarks/service-benchmarks/build.gradle.kts b/tests/benchmarks/service-benchmarks/build.gradle.kts index 98d956d2541..0366b195e90 100644 --- a/tests/benchmarks/service-benchmarks/build.gradle.kts +++ b/tests/benchmarks/service-benchmarks/build.gradle.kts @@ -5,7 +5,7 @@ import aws.sdk.kotlin.gradle.dsl.skipPublishing plugins { - kotlin("multiplatform") + alias(libs.plugins.kotlin.multiplatform) application } diff --git a/tests/codegen/event-stream/build.gradle.kts b/tests/codegen/event-stream/build.gradle.kts index 82ac7b29a8e..e7c5c1bcfb5 100644 --- a/tests/codegen/event-stream/build.gradle.kts +++ b/tests/codegen/event-stream/build.gradle.kts @@ -6,7 +6,7 @@ import aws.sdk.kotlin.gradle.codegen.dsl.smithyKotlinPlugin import software.amazon.smithy.gradle.tasks.SmithyBuild plugins { - kotlin("jvm") + alias(libs.plugins.kotlin.jvm) id("aws.sdk.kotlin.codegen") } @@ -22,7 +22,7 @@ data class EventStreamTest( val modelTemplate: File, ) { val model: File - get() = buildDir.resolve("$projectionName/model.smithy") + get() = layout.buildDirectory.file("$projectionName/model.smithy").get().asFile } val tests = listOf( diff --git a/tests/e2e-test-util/build.gradle.kts b/tests/e2e-test-util/build.gradle.kts index d8f8d2cd7f3..4e476ce6af6 100644 --- a/tests/e2e-test-util/build.gradle.kts +++ b/tests/e2e-test-util/build.gradle.kts @@ -3,7 +3,7 @@ * SPDX-License-Identifier: Apache-2.0 */ plugins { - kotlin("jvm") + alias(libs.plugins.kotlin.jvm) } description = "Test utilities for integration and e2e tests"