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}") - }