Skip to content

Commit 5fc1b55

Browse files
authored
kn: configure targets (#53)
1 parent 2eafcdf commit 5fc1b55

File tree

4 files changed

+58
-72
lines changed

4 files changed

+58
-72
lines changed

build-plugins/build-support/build.gradle.kts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ dependencies {
2222
runtimeOnly(project(":ktlint-rules"))
2323
implementation(libs.nexusPublishPlugin)
2424
compileOnly(gradleApi())
25-
implementation("aws.sdk.kotlin:s3:1.1.+")
26-
implementation("aws.sdk.kotlin:cloudwatch:1.1.+")
25+
implementation("aws.sdk.kotlin:s3:+")
26+
implementation("aws.sdk.kotlin:cloudwatch:+")
2727
testImplementation(libs.junit.jupiter)
2828
}
2929

build-plugins/build-support/src/main/kotlin/aws/sdk/kotlin/gradle/dsl/Publish.kt

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,16 @@ private const val SONATYPE_PASSWORD_PROP = "sonatypePassword"
2727
private val ALLOWED_PUBLICATIONS = listOf(
2828
"common",
2929
"jvm",
30-
"metadata",
3130
"kotlinMultiplatform",
31+
"iosX64",
32+
"linuxArm64",
33+
"linuxX64",
34+
"macosArm64",
35+
"macosX64",
36+
37+
"metadata",
3238
"bom",
3339
"versionCatalog",
34-
"android", // aws-crt-kotlin
3540
"codegen",
3641
"codegen-testutils",
3742

build-plugins/kmp-conventions/src/main/kotlin/aws/sdk/kotlin/gradle/kmp/ConfigureTargets.kt

Lines changed: 49 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
*/
55
package aws.sdk.kotlin.gradle.kmp
66

7+
import aws.sdk.kotlin.gradle.util.prop
78
import org.gradle.api.Project
89
import org.gradle.api.tasks.testing.Test
910
import org.gradle.api.tasks.testing.logging.TestExceptionFormat
@@ -45,7 +46,7 @@ val Project.hasWindows: Boolean get() = hasNative || files.any { it.name == "win
4546
* Test if a project follows the convention and needs configured for KMP (used in handful of spots where we have a
4647
* subproject that is just a container for other projects but isn't a KMP project itself).
4748
*/
48-
public val Project.needsKmpConfigured: Boolean get() = hasCommon || hasJvm || hasNative || hasJs
49+
public val Project.needsKmpConfigured: Boolean get() = hasCommon || hasJvm || hasNative || hasJs || hasJvmAndNative || hasDesktop || hasLinux || hasApple || hasWindows
4950

5051
@OptIn(ExperimentalKotlinGradlePluginApi::class)
5152
fun Project.configureKmpTargets() {
@@ -64,7 +65,8 @@ fun Project.configureKmpTargets() {
6465
return@withPlugin
6566
}
6667

67-
// configure the target hierarchy, this does not actually enable the targets, just their relationships
68+
// extend the default KMP target hierarchy
69+
// this does not actually enable the targets, just their relationships
6870
// see https://kotlinlang.org/docs/multiplatform-hierarchy.html#see-the-full-hierarchy-template
6971
kmpExt.applyDefaultHierarchyTemplate {
7072
if (hasJvmAndNative) {
@@ -95,24 +97,32 @@ fun Project.configureKmpTargets() {
9597
}
9698
}
9799

98-
// enable targets
100+
// enable the targets
99101
configureCommon()
100102

101103
if (hasJvm && JVM_ENABLED) {
102104
configureJvm()
103105
}
104106

105107
// FIXME Configure JS
106-
// FIXME Configure Apple
107-
// FIXME Configure Windows
108108

109-
withIf(hasLinux && NATIVE_ENABLED, kmpExt) {
110-
configureLinux()
111-
}
112-
113-
withIf(hasDesktop && NATIVE_ENABLED, kmpExt) {
114-
configureLinux()
115-
// FIXME Configure desktop
109+
if (NATIVE_ENABLED) {
110+
if (hasApple) {
111+
kmpExt.apply { configureApple() }
112+
}
113+
if (hasWindows) {
114+
kmpExt.apply { configureWindows() }
115+
}
116+
if (hasLinux) {
117+
kmpExt.apply { configureLinux() }
118+
}
119+
if (hasDesktop) {
120+
kmpExt.apply {
121+
configureLinux()
122+
configureMacos()
123+
configureWindows()
124+
}
125+
}
116126
}
117127

118128
kmpExt.configureSourceSetsConvention()
@@ -155,14 +165,31 @@ fun Project.configureJvm() {
155165

156166
fun Project.configureLinux() {
157167
kotlin {
158-
linuxX64 {
159-
// FIXME enable tests once the target is fully implemented
160-
tasks.named("linuxX64Test") {
161-
enabled = false
162-
}
163-
}
164-
// FIXME - Okio missing arm64 target support
165-
// linuxArm64()
168+
linuxX64()
169+
linuxArm64() // FIXME - Okio missing arm64 target support
170+
}
171+
}
172+
173+
fun Project.configureApple() {
174+
kotlin {
175+
configureMacos()
176+
iosSimulatorArm64()
177+
iosArm64()
178+
iosX64()
179+
}
180+
}
181+
182+
fun Project.configureMacos() {
183+
kotlin {
184+
macosX64()
185+
macosArm64()
186+
}
187+
}
188+
189+
fun Project.configureWindows() {
190+
kotlin {
191+
// FIXME Set up Docker files and CMake tasks for Windows
192+
// mingwX64()
166193
}
167194
}
168195

@@ -179,8 +206,5 @@ fun KotlinMultiplatformExtension.configureSourceSetsConvention() {
179206
}
180207
}
181208

182-
internal inline fun <T> withIf(condition: Boolean, receiver: T, block: T.() -> Unit) {
183-
if (condition) {
184-
receiver.block()
185-
}
186-
}
209+
val Project.JVM_ENABLED get() = prop("aws.kotlin.jvm")?.let { it == "true" } ?: true
210+
val Project.NATIVE_ENABLED get() = prop("aws.kotlin.native")?.let { it == "true" } ?: true

build-plugins/kmp-conventions/src/main/kotlin/aws/sdk/kotlin/gradle/kmp/IdeUtils.kt

Lines changed: 0 additions & 43 deletions
This file was deleted.

0 commit comments

Comments
 (0)