From 5fc1b5595ba5b49fd8e0a27eca17f047a3bfcdca Mon Sep 17 00:00:00 2001 From: Matas Date: Tue, 29 Oct 2024 13:29:02 -0400 Subject: [PATCH 01/14] kn: configure targets (#53) --- build-plugins/build-support/build.gradle.kts | 4 +- .../aws/sdk/kotlin/gradle/dsl/Publish.kt | 9 ++- .../sdk/kotlin/gradle/kmp/ConfigureTargets.kt | 74 ++++++++++++------- .../aws/sdk/kotlin/gradle/kmp/IdeUtils.kt | 43 ----------- 4 files changed, 58 insertions(+), 72 deletions(-) delete mode 100644 build-plugins/kmp-conventions/src/main/kotlin/aws/sdk/kotlin/gradle/kmp/IdeUtils.kt diff --git a/build-plugins/build-support/build.gradle.kts b/build-plugins/build-support/build.gradle.kts index e76fcbf..77216ef 100644 --- a/build-plugins/build-support/build.gradle.kts +++ b/build-plugins/build-support/build.gradle.kts @@ -22,8 +22,8 @@ dependencies { runtimeOnly(project(":ktlint-rules")) implementation(libs.nexusPublishPlugin) compileOnly(gradleApi()) - implementation("aws.sdk.kotlin:s3:1.1.+") - implementation("aws.sdk.kotlin:cloudwatch:1.1.+") + implementation("aws.sdk.kotlin:s3:+") + implementation("aws.sdk.kotlin:cloudwatch:+") testImplementation(libs.junit.jupiter) } diff --git a/build-plugins/build-support/src/main/kotlin/aws/sdk/kotlin/gradle/dsl/Publish.kt b/build-plugins/build-support/src/main/kotlin/aws/sdk/kotlin/gradle/dsl/Publish.kt index 3fe168b..5ae106c 100644 --- a/build-plugins/build-support/src/main/kotlin/aws/sdk/kotlin/gradle/dsl/Publish.kt +++ b/build-plugins/build-support/src/main/kotlin/aws/sdk/kotlin/gradle/dsl/Publish.kt @@ -27,11 +27,16 @@ private const val SONATYPE_PASSWORD_PROP = "sonatypePassword" private val ALLOWED_PUBLICATIONS = listOf( "common", "jvm", - "metadata", "kotlinMultiplatform", + "iosX64", + "linuxArm64", + "linuxX64", + "macosArm64", + "macosX64", + + "metadata", "bom", "versionCatalog", - "android", // aws-crt-kotlin "codegen", "codegen-testutils", diff --git a/build-plugins/kmp-conventions/src/main/kotlin/aws/sdk/kotlin/gradle/kmp/ConfigureTargets.kt b/build-plugins/kmp-conventions/src/main/kotlin/aws/sdk/kotlin/gradle/kmp/ConfigureTargets.kt index e450c4c..6440dce 100644 --- a/build-plugins/kmp-conventions/src/main/kotlin/aws/sdk/kotlin/gradle/kmp/ConfigureTargets.kt +++ b/build-plugins/kmp-conventions/src/main/kotlin/aws/sdk/kotlin/gradle/kmp/ConfigureTargets.kt @@ -4,6 +4,7 @@ */ package aws.sdk.kotlin.gradle.kmp +import aws.sdk.kotlin.gradle.util.prop import org.gradle.api.Project import org.gradle.api.tasks.testing.Test import org.gradle.api.tasks.testing.logging.TestExceptionFormat @@ -45,7 +46,7 @@ val Project.hasWindows: Boolean get() = hasNative || files.any { it.name == "win * Test if a project follows the convention and needs configured for KMP (used in handful of spots where we have a * subproject that is just a container for other projects but isn't a KMP project itself). */ -public val Project.needsKmpConfigured: Boolean get() = hasCommon || hasJvm || hasNative || hasJs +public val Project.needsKmpConfigured: Boolean get() = hasCommon || hasJvm || hasNative || hasJs || hasJvmAndNative || hasDesktop || hasLinux || hasApple || hasWindows @OptIn(ExperimentalKotlinGradlePluginApi::class) fun Project.configureKmpTargets() { @@ -64,7 +65,8 @@ fun Project.configureKmpTargets() { return@withPlugin } - // configure the target hierarchy, this does not actually enable the targets, just their relationships + // extend the default KMP target hierarchy + // this does not actually enable the targets, just their relationships // see https://kotlinlang.org/docs/multiplatform-hierarchy.html#see-the-full-hierarchy-template kmpExt.applyDefaultHierarchyTemplate { if (hasJvmAndNative) { @@ -95,7 +97,7 @@ fun Project.configureKmpTargets() { } } - // enable targets + // enable the targets configureCommon() if (hasJvm && JVM_ENABLED) { @@ -103,16 +105,24 @@ fun Project.configureKmpTargets() { } // FIXME Configure JS - // FIXME Configure Apple - // FIXME Configure Windows - withIf(hasLinux && NATIVE_ENABLED, kmpExt) { - configureLinux() - } - - withIf(hasDesktop && NATIVE_ENABLED, kmpExt) { - configureLinux() - // FIXME Configure desktop + if (NATIVE_ENABLED) { + if (hasApple) { + kmpExt.apply { configureApple() } + } + if (hasWindows) { + kmpExt.apply { configureWindows() } + } + if (hasLinux) { + kmpExt.apply { configureLinux() } + } + if (hasDesktop) { + kmpExt.apply { + configureLinux() + configureMacos() + configureWindows() + } + } } kmpExt.configureSourceSetsConvention() @@ -155,14 +165,31 @@ fun Project.configureJvm() { fun Project.configureLinux() { kotlin { - linuxX64 { - // FIXME enable tests once the target is fully implemented - tasks.named("linuxX64Test") { - enabled = false - } - } - // FIXME - Okio missing arm64 target support - // linuxArm64() + linuxX64() + linuxArm64() // FIXME - Okio missing arm64 target support + } +} + +fun Project.configureApple() { + kotlin { + configureMacos() + iosSimulatorArm64() + iosArm64() + iosX64() + } +} + +fun Project.configureMacos() { + kotlin { + macosX64() + macosArm64() + } +} + +fun Project.configureWindows() { + kotlin { + // FIXME Set up Docker files and CMake tasks for Windows +// mingwX64() } } @@ -179,8 +206,5 @@ fun KotlinMultiplatformExtension.configureSourceSetsConvention() { } } -internal inline fun withIf(condition: Boolean, receiver: T, block: T.() -> Unit) { - if (condition) { - receiver.block() - } -} +val Project.JVM_ENABLED get() = prop("aws.kotlin.jvm")?.let { it == "true" } ?: true +val Project.NATIVE_ENABLED get() = prop("aws.kotlin.native")?.let { it == "true" } ?: true diff --git a/build-plugins/kmp-conventions/src/main/kotlin/aws/sdk/kotlin/gradle/kmp/IdeUtils.kt b/build-plugins/kmp-conventions/src/main/kotlin/aws/sdk/kotlin/gradle/kmp/IdeUtils.kt deleted file mode 100644 index 8ab7cf8..0000000 --- a/build-plugins/kmp-conventions/src/main/kotlin/aws/sdk/kotlin/gradle/kmp/IdeUtils.kt +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. - * SPDX-License-Identifier: Apache-2.0 - */ -package aws.sdk.kotlin.gradle.kmp - -import aws.sdk.kotlin.gradle.util.prop -import org.gradle.api.Project -import org.jetbrains.kotlin.gradle.dsl.KotlinMultiplatformExtension -import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeTarget -import org.jetbrains.kotlin.konan.target.HostManager -import org.jetbrains.kotlin.konan.target.KonanTarget -import java.util.* - -/** - * Whether Intellij is active or not - */ -val IDEA_ACTIVE = System.getProperty("idea.active") == "true" - -val OS_NAME = System.getProperty("os.name").lowercase() - -val HOST_NAME = when { - OS_NAME.startsWith("linux") -> "linux" - OS_NAME.startsWith("windows") -> "windows" - OS_NAME.startsWith("mac") -> "macos" - else -> error("Unknown os name `$OS_NAME`") -} - -val Project.JVM_ENABLED get() = prop("aws.kotlin.jvm")?.let { it == "true" } ?: true -val Project.NATIVE_ENABLED get() = prop("aws.kotlin.native")?.let { it == "true" } ?: true - -/** - * Scope down the native target enabled when working in intellij - */ -val KotlinMultiplatformExtension.ideaTarget: KotlinNativeTarget - get() = when (HostManager.host) { - is KonanTarget.LINUX_X64 -> linuxX64() - is KonanTarget.LINUX_ARM64 -> linuxArm64() - is KonanTarget.MACOS_X64 -> macosX64() - is KonanTarget.MACOS_ARM64 -> macosArm64() - is KonanTarget.MINGW_X64 -> mingwX64() - else -> error("Unsupported target ${HostManager.host}") - } From 2293711d5e77f673366180a0c43ed8a8ee8ceb71 Mon Sep 17 00:00:00 2001 From: Matas Date: Thu, 7 Nov 2024 14:43:02 -0500 Subject: [PATCH 02/14] misc: enable using `kn-main` in CI (#55) --- .github/actions/checkout-head/action.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/actions/checkout-head/action.yml b/.github/actions/checkout-head/action.yml index f3632d4..d4e3fe5 100644 --- a/.github/actions/checkout-head/action.yml +++ b/.github/actions/checkout-head/action.yml @@ -44,7 +44,9 @@ runs: echo "ref=$ref" >> "$GITHUB_OUTPUT" else baseref="main" - if [ -n "$GITHUB_BASE_REF" ]; then + if git ls-remote --exit-code --heads "https://github.com/$REPOSITORY.git" "kn-main"; then + baseref="kn-main" + elif [ -n "$GITHUB_BASE_REF" ]; then echo "attempting GH base ref: $GITHUB_BASE_REF" if git ls-remote --exit-code --heads "https://github.com/$REPOSITORY.git" "$GITHUB_BASE_REF"; then baseref="$GITHUB_BASE_REF" From 2ba27e540a324f6465ed37eaeb64f829dcbcdf26 Mon Sep 17 00:00:00 2001 From: Matas Date: Mon, 18 Nov 2024 11:35:36 -0500 Subject: [PATCH 03/14] kn: enable checking out submodules recursively (#56) --- .github/actions/checkout-head/action.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/actions/checkout-head/action.yml b/.github/actions/checkout-head/action.yml index d4e3fe5..2713706 100644 --- a/.github/actions/checkout-head/action.yml +++ b/.github/actions/checkout-head/action.yml @@ -62,4 +62,5 @@ runs: path: ${{ inputs.path }} repository: ${{ inputs.repository }} ref: ${{ steps.repo.outputs.ref }} - token: ${{ inputs.token }} \ No newline at end of file + token: ${{ inputs.token }} + submodules: 'recursive' \ No newline at end of file From 0cb72d8b72063c40517c08a123c1c882c01e2d36 Mon Sep 17 00:00:00 2001 From: Matas Date: Mon, 18 Nov 2024 16:13:18 -0500 Subject: [PATCH 04/14] kn: add `submodules` to inputs (#57) --- .github/actions/checkout-head/action.yml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.github/actions/checkout-head/action.yml b/.github/actions/checkout-head/action.yml index 2713706..1b97857 100644 --- a/.github/actions/checkout-head/action.yml +++ b/.github/actions/checkout-head/action.yml @@ -23,6 +23,10 @@ inputs: commands. The post-job step removes the PAT. default: ${{ github.token }} required: false + submodules: + description: 'Whether to checkout submodules: `true` to checkout submodules or `recursive` to recursively checkout submodules'. + default: 'false' + required: 'false' runs: using: composite @@ -63,4 +67,4 @@ runs: repository: ${{ inputs.repository }} ref: ${{ steps.repo.outputs.ref }} token: ${{ inputs.token }} - submodules: 'recursive' \ No newline at end of file + submodules: ${{ inputs.submodules }} From 492ec38289bc71a488ce811aa706e5fc55677594 Mon Sep 17 00:00:00 2001 From: Matas Lauzadis Date: Mon, 18 Nov 2024 16:26:48 -0500 Subject: [PATCH 05/14] Fix step description --- .github/actions/checkout-head/action.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/actions/checkout-head/action.yml b/.github/actions/checkout-head/action.yml index 1b97857..74a3d6b 100644 --- a/.github/actions/checkout-head/action.yml +++ b/.github/actions/checkout-head/action.yml @@ -24,7 +24,8 @@ inputs: default: ${{ github.token }} required: false submodules: - description: 'Whether to checkout submodules: `true` to checkout submodules or `recursive` to recursively checkout submodules'. + description: > + Whether to checkout submodules. `true` to checkout submodules or `recursive` to recursively checkout submodules default: 'false' required: 'false' From 26013a8ac4b4517f786728c428cc02b7a738ec50 Mon Sep 17 00:00:00 2001 From: Matas Lauzadis Date: Fri, 13 Dec 2024 12:10:56 -0500 Subject: [PATCH 06/14] Add `disableCrossCompileTargets` util function --- .../sdk/kotlin/gradle/kmp/ConfigureTargets.kt | 63 +++++++++++++++++++ 1 file changed, 63 insertions(+) diff --git a/build-plugins/kmp-conventions/src/main/kotlin/aws/sdk/kotlin/gradle/kmp/ConfigureTargets.kt b/build-plugins/kmp-conventions/src/main/kotlin/aws/sdk/kotlin/gradle/kmp/ConfigureTargets.kt index 6440dce..97cc037 100644 --- a/build-plugins/kmp-conventions/src/main/kotlin/aws/sdk/kotlin/gradle/kmp/ConfigureTargets.kt +++ b/build-plugins/kmp-conventions/src/main/kotlin/aws/sdk/kotlin/gradle/kmp/ConfigureTargets.kt @@ -6,11 +6,16 @@ package aws.sdk.kotlin.gradle.kmp import aws.sdk.kotlin.gradle.util.prop import org.gradle.api.Project +import org.gradle.api.publish.maven.tasks.AbstractPublishToMaven +import org.gradle.api.publish.tasks.GenerateModuleMetadata import org.gradle.api.tasks.testing.Test import org.gradle.api.tasks.testing.logging.TestExceptionFormat import org.gradle.kotlin.dsl.* import org.jetbrains.kotlin.gradle.ExperimentalKotlinGradlePluginApi import org.jetbrains.kotlin.gradle.dsl.KotlinMultiplatformExtension +import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeTarget +import org.jetbrains.kotlin.konan.target.Family +import org.jetbrains.kotlin.konan.target.HostManager import java.io.File internal fun Project.tryGetClass(className: String): Class? { @@ -208,3 +213,61 @@ fun KotlinMultiplatformExtension.configureSourceSetsConvention() { val Project.JVM_ENABLED get() = prop("aws.kotlin.jvm")?.let { it == "true" } ?: true val Project.NATIVE_ENABLED get() = prop("aws.kotlin.native")?.let { it == "true" } ?: true + +/** + * Kotlin/Native Linux and Windows targets are generally enabled on all hosts since + * the Kotlin toolchain and backend compilers support cross compilation. We + * are using cinterop and have to compile CRT for those platforms which sometimes + * requires using docker which isn't always available in CI or setup in users environment. + * + * See [KT-30498](https://youtrack.jetbrains.com/issue/KT-30498) + */ +fun Project.disableCrossCompileTargets() { + plugins.withId("org.jetbrains.kotlin.multiplatform") { + configure { + targets.withType { + val knTarget = this + when { + HostManager.hostIsMac && (knTarget.isLinux || knTarget.isWindows) -> disable(knTarget) + HostManager.hostIsLinux && knTarget.isApple -> disable(knTarget) + HostManager.hostIsMingw && (knTarget.isLinux || knTarget.isApple) -> disable(knTarget) + } + } + } + } +} + +private val KotlinNativeTarget.isLinux: Boolean + get() = konanTarget.family == Family.LINUX + +private val KotlinNativeTarget.isApple: Boolean + get() = konanTarget.family.isAppleFamily + +private val KotlinNativeTarget.isWindows: Boolean + get() = konanTarget.family == Family.MINGW + + +internal fun Project.disable(knTarget: KotlinNativeTarget) { + logger.warn("disabling Kotlin/Native target: ${knTarget.name}") + knTarget.apply { + compilations.all { + cinterops.all { + tasks.named(interopProcessingTaskName).configure { enabled = false } + } + compileTaskProvider.configure { enabled = false } + } + + binaries.all { + linkTaskProvider.configure { enabled = false } + } + + mavenPublication { + tasks.withType().configureEach { + onlyIf { publication != this@mavenPublication } + } + tasks.withType().configureEach { + onlyIf { publication != this@mavenPublication } + } + } + } +} From f712e53b33609a2da4d110bf594dcfafaadb90e1 Mon Sep 17 00:00:00 2001 From: Matas Date: Fri, 31 Jan 2025 13:07:40 -0500 Subject: [PATCH 07/14] kn: commonize iOS simulator configuration (#63) --- .../gradle/kmp/ConfigureIosSimulator.kt | 60 +++++++++++++++++++ .../sdk/kotlin/gradle/kmp/ConfigureTargets.kt | 1 - 2 files changed, 60 insertions(+), 1 deletion(-) create mode 100644 build-plugins/kmp-conventions/src/main/kotlin/aws/sdk/kotlin/gradle/kmp/ConfigureIosSimulator.kt diff --git a/build-plugins/kmp-conventions/src/main/kotlin/aws/sdk/kotlin/gradle/kmp/ConfigureIosSimulator.kt b/build-plugins/kmp-conventions/src/main/kotlin/aws/sdk/kotlin/gradle/kmp/ConfigureIosSimulator.kt new file mode 100644 index 0000000..f7be606 --- /dev/null +++ b/build-plugins/kmp-conventions/src/main/kotlin/aws/sdk/kotlin/gradle/kmp/ConfigureIosSimulator.kt @@ -0,0 +1,60 @@ +/* + * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 + */ +package aws.sdk.kotlin.gradle.kmp + +import org.gradle.api.Project +import org.gradle.api.tasks.Exec +import org.gradle.kotlin.dsl.withType +import org.jetbrains.kotlin.gradle.targets.native.tasks.KotlinNativeSimulatorTest +import org.jetbrains.kotlin.konan.target.HostManager + +/** + * Disables standalone mode in simulator tests since it causes issues with TLS. + * This means we need to manage the simulator state ourselves (booting, shutting down). + * https://youtrack.jetbrains.com/issue/KT-38317 + */ +public fun Project.configureIosSimulatorTasks() { + val simulatorDeviceName = project.findProperty("iosSimulatorDevice") as? String ?: "iPhone 15" + + val xcrun = "/usr/bin/xcrun" + + tasks.register("bootIosSimulatorDevice", Exec::class.java) { + isIgnoreExitValue = true + commandLine(xcrun, "simctl", "boot", simulatorDeviceName) + + doLast { + val result = executionResult.get() + val code = result.exitValue + if (code != 148 && code != 149) { // ignore "simulator already running" errors + result.assertNormalExitValue() + } + } + } + + tasks.register("shutdownIosSimulatorDevice", Exec::class.java) { + isIgnoreExitValue = true + mustRunAfter(tasks.withType()) + commandLine(xcrun, "simctl", "shutdown", simulatorDeviceName) + + doLast { + val result = executionResult.get() + if (result.exitValue != 405) { // ignore "simulator already shutdown" errors + result.assertNormalExitValue() + } + } + } + + tasks.withType().configureEach { + if (!HostManager.hostIsMac) { + return@configureEach + } + + dependsOn("bootIosSimulatorDevice") + finalizedBy("shutdownIosSimulatorDevice") + + standalone.set(false) + device.set(simulatorDeviceName) + } +} diff --git a/build-plugins/kmp-conventions/src/main/kotlin/aws/sdk/kotlin/gradle/kmp/ConfigureTargets.kt b/build-plugins/kmp-conventions/src/main/kotlin/aws/sdk/kotlin/gradle/kmp/ConfigureTargets.kt index 97cc037..2ed42ed 100644 --- a/build-plugins/kmp-conventions/src/main/kotlin/aws/sdk/kotlin/gradle/kmp/ConfigureTargets.kt +++ b/build-plugins/kmp-conventions/src/main/kotlin/aws/sdk/kotlin/gradle/kmp/ConfigureTargets.kt @@ -246,7 +246,6 @@ private val KotlinNativeTarget.isApple: Boolean private val KotlinNativeTarget.isWindows: Boolean get() = konanTarget.family == Family.MINGW - internal fun Project.disable(knTarget: KotlinNativeTarget) { logger.warn("disabling Kotlin/Native target: ${knTarget.name}") knTarget.apply { From ab34ff6f8b3285057d3c491b856244dee652e75e Mon Sep 17 00:00:00 2001 From: Matas Lauzadis Date: Mon, 3 Feb 2025 11:08:57 -0500 Subject: [PATCH 08/14] Check error code 405 in boot tasks --- .../kotlin/aws/sdk/kotlin/gradle/kmp/ConfigureIosSimulator.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build-plugins/kmp-conventions/src/main/kotlin/aws/sdk/kotlin/gradle/kmp/ConfigureIosSimulator.kt b/build-plugins/kmp-conventions/src/main/kotlin/aws/sdk/kotlin/gradle/kmp/ConfigureIosSimulator.kt index f7be606..e72fa1b 100644 --- a/build-plugins/kmp-conventions/src/main/kotlin/aws/sdk/kotlin/gradle/kmp/ConfigureIosSimulator.kt +++ b/build-plugins/kmp-conventions/src/main/kotlin/aws/sdk/kotlin/gradle/kmp/ConfigureIosSimulator.kt @@ -27,7 +27,7 @@ public fun Project.configureIosSimulatorTasks() { doLast { val result = executionResult.get() val code = result.exitValue - if (code != 148 && code != 149) { // ignore "simulator already running" errors + if (code != 148 && code != 149 && code != 405) { // ignore "simulator already running" errors result.assertNormalExitValue() } } From 7a07412b16bda0ee3037532a2b18cef9617232cf Mon Sep 17 00:00:00 2001 From: Matas Date: Mon, 3 Feb 2025 20:45:52 -0500 Subject: [PATCH 09/14] kn: Create iOS simulator boot and shutdown tasks in root project (#64) --- .../gradle/kmp/ConfigureIosSimulator.kt | 29 +++++++++---------- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/build-plugins/kmp-conventions/src/main/kotlin/aws/sdk/kotlin/gradle/kmp/ConfigureIosSimulator.kt b/build-plugins/kmp-conventions/src/main/kotlin/aws/sdk/kotlin/gradle/kmp/ConfigureIosSimulator.kt index e72fa1b..d8f444a 100644 --- a/build-plugins/kmp-conventions/src/main/kotlin/aws/sdk/kotlin/gradle/kmp/ConfigureIosSimulator.kt +++ b/build-plugins/kmp-conventions/src/main/kotlin/aws/sdk/kotlin/gradle/kmp/ConfigureIosSimulator.kt @@ -16,45 +16,44 @@ import org.jetbrains.kotlin.konan.target.HostManager * https://youtrack.jetbrains.com/issue/KT-38317 */ public fun Project.configureIosSimulatorTasks() { - val simulatorDeviceName = project.findProperty("iosSimulatorDevice") as? String ?: "iPhone 15" + if (!HostManager.hostIsMac) return + val simulatorDeviceName = project.findProperty("iosSimulatorDevice") as? String ?: "iPhone 15" val xcrun = "/usr/bin/xcrun" - tasks.register("bootIosSimulatorDevice", Exec::class.java) { + val bootTask = rootProject.tasks.maybeCreate("bootIosSimulatorDevice", Exec::class.java).apply { isIgnoreExitValue = true commandLine(xcrun, "simctl", "boot", simulatorDeviceName) doLast { val result = executionResult.get() val code = result.exitValue - if (code != 148 && code != 149 && code != 405) { // ignore "simulator already running" errors + if (code != 148 && code != 149) { // ignore "simulator already running" errors result.assertNormalExitValue() } } } - tasks.register("shutdownIosSimulatorDevice", Exec::class.java) { + val shutdownTask = rootProject.tasks.maybeCreate("shutdownIosSimulatorDevice", Exec::class.java).apply { isIgnoreExitValue = true - mustRunAfter(tasks.withType()) commandLine(xcrun, "simctl", "shutdown", simulatorDeviceName) doLast { val result = executionResult.get() - if (result.exitValue != 405) { // ignore "simulator already shutdown" errors + val code = result.exitValue + if (code != 148 && code != 149) { // ignore "simulator already shutdown" errors result.assertNormalExitValue() } } } - tasks.withType().configureEach { - if (!HostManager.hostIsMac) { - return@configureEach + allprojects { + val simulatorTasks = tasks.withType() + simulatorTasks.configureEach { + dependsOn(bootTask) + standalone.set(false) + device.set(simulatorDeviceName) } - - dependsOn("bootIosSimulatorDevice") - finalizedBy("shutdownIosSimulatorDevice") - - standalone.set(false) - device.set(simulatorDeviceName) + shutdownTask.mustRunAfter(simulatorTasks) } } From 40954d037fad0208dcdb62493b0782ccfe884bd8 Mon Sep 17 00:00:00 2001 From: Matas Lauzadis Date: Tue, 18 Mar 2025 16:11:58 -0400 Subject: [PATCH 10/14] Remove K/N targets from `ALLOWED_PUBLICATIONS` --- .../src/main/kotlin/aws/sdk/kotlin/gradle/dsl/Publish.kt | 5 ----- 1 file changed, 5 deletions(-) diff --git a/build-plugins/build-support/src/main/kotlin/aws/sdk/kotlin/gradle/dsl/Publish.kt b/build-plugins/build-support/src/main/kotlin/aws/sdk/kotlin/gradle/dsl/Publish.kt index 8a6aa52..cbc2344 100644 --- a/build-plugins/build-support/src/main/kotlin/aws/sdk/kotlin/gradle/dsl/Publish.kt +++ b/build-plugins/build-support/src/main/kotlin/aws/sdk/kotlin/gradle/dsl/Publish.kt @@ -28,11 +28,6 @@ private val ALLOWED_PUBLICATIONS = listOf( "common", "jvm", "kotlinMultiplatform", - "iosX64", - "linuxArm64", - "linuxX64", - "macosArm64", - "macosX64", "metadata", "bom", From 07c11e47ebf10cc43cfcc81c558b0df63948825a Mon Sep 17 00:00:00 2001 From: Matas Lauzadis Date: Tue, 18 Mar 2025 16:12:28 -0400 Subject: [PATCH 11/14] Revert back to 1.1.+ --- build-plugins/build-support/build.gradle.kts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/build-plugins/build-support/build.gradle.kts b/build-plugins/build-support/build.gradle.kts index 77216ef..e76fcbf 100644 --- a/build-plugins/build-support/build.gradle.kts +++ b/build-plugins/build-support/build.gradle.kts @@ -22,8 +22,8 @@ dependencies { runtimeOnly(project(":ktlint-rules")) implementation(libs.nexusPublishPlugin) compileOnly(gradleApi()) - implementation("aws.sdk.kotlin:s3:+") - implementation("aws.sdk.kotlin:cloudwatch:+") + implementation("aws.sdk.kotlin:s3:1.1.+") + implementation("aws.sdk.kotlin:cloudwatch:1.1.+") testImplementation(libs.junit.jupiter) } From a0e3e174997f3a40c29ec6ccc0ae154df3f61857 Mon Sep 17 00:00:00 2001 From: Matas Date: Tue, 18 Mar 2025 16:19:44 -0400 Subject: [PATCH 12/14] misc: prepare to merge `kn-main` back into `main` (#78) * Remove K/N targets from `ALLOWED_PUBLICATIONS` * Revert back to 1.1.+ --- build-plugins/build-support/build.gradle.kts | 4 ++-- .../src/main/kotlin/aws/sdk/kotlin/gradle/dsl/Publish.kt | 5 ----- 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/build-plugins/build-support/build.gradle.kts b/build-plugins/build-support/build.gradle.kts index 77216ef..e76fcbf 100644 --- a/build-plugins/build-support/build.gradle.kts +++ b/build-plugins/build-support/build.gradle.kts @@ -22,8 +22,8 @@ dependencies { runtimeOnly(project(":ktlint-rules")) implementation(libs.nexusPublishPlugin) compileOnly(gradleApi()) - implementation("aws.sdk.kotlin:s3:+") - implementation("aws.sdk.kotlin:cloudwatch:+") + implementation("aws.sdk.kotlin:s3:1.1.+") + implementation("aws.sdk.kotlin:cloudwatch:1.1.+") testImplementation(libs.junit.jupiter) } diff --git a/build-plugins/build-support/src/main/kotlin/aws/sdk/kotlin/gradle/dsl/Publish.kt b/build-plugins/build-support/src/main/kotlin/aws/sdk/kotlin/gradle/dsl/Publish.kt index 8a6aa52..cbc2344 100644 --- a/build-plugins/build-support/src/main/kotlin/aws/sdk/kotlin/gradle/dsl/Publish.kt +++ b/build-plugins/build-support/src/main/kotlin/aws/sdk/kotlin/gradle/dsl/Publish.kt @@ -28,11 +28,6 @@ private val ALLOWED_PUBLICATIONS = listOf( "common", "jvm", "kotlinMultiplatform", - "iosX64", - "linuxArm64", - "linuxX64", - "macosArm64", - "macosX64", "metadata", "bom", From 9df2b1ac832b67c9cadce7f86636ee733fa3aa7c Mon Sep 17 00:00:00 2001 From: Matas Lauzadis Date: Tue, 18 Mar 2025 16:32:28 -0400 Subject: [PATCH 13/14] Only use kn-main if the ref has a `kn-` prefix --- .github/actions/checkout-head/action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/actions/checkout-head/action.yml b/.github/actions/checkout-head/action.yml index 74a3d6b..1eec81a 100644 --- a/.github/actions/checkout-head/action.yml +++ b/.github/actions/checkout-head/action.yml @@ -49,7 +49,7 @@ runs: echo "ref=$ref" >> "$GITHUB_OUTPUT" else baseref="main" - if git ls-remote --exit-code --heads "https://github.com/$REPOSITORY.git" "kn-main"; then + if [[ "$ref" == kn-* ]] && git ls-remote --exit-code --heads "https://github.com/$REPOSITORY.git" "kn-main"; then baseref="kn-main" elif [ -n "$GITHUB_BASE_REF" ]; then echo "attempting GH base ref: $GITHUB_BASE_REF" From 11393d3fb66f74851300079450b5819bed9327f5 Mon Sep 17 00:00:00 2001 From: Matas Lauzadis Date: Tue, 18 Mar 2025 16:37:37 -0400 Subject: [PATCH 14/14] Revert Publish.kt changes --- .../src/main/kotlin/aws/sdk/kotlin/gradle/dsl/Publish.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/build-plugins/build-support/src/main/kotlin/aws/sdk/kotlin/gradle/dsl/Publish.kt b/build-plugins/build-support/src/main/kotlin/aws/sdk/kotlin/gradle/dsl/Publish.kt index cbc2344..9259272 100644 --- a/build-plugins/build-support/src/main/kotlin/aws/sdk/kotlin/gradle/dsl/Publish.kt +++ b/build-plugins/build-support/src/main/kotlin/aws/sdk/kotlin/gradle/dsl/Publish.kt @@ -27,11 +27,11 @@ private const val SONATYPE_PASSWORD_PROP = "sonatypePassword" private val ALLOWED_PUBLICATIONS = listOf( "common", "jvm", - "kotlinMultiplatform", - "metadata", + "kotlinMultiplatform", "bom", "versionCatalog", + "android", // aws-crt-kotlin "codegen", "codegen-testutils",