22 * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
33 * SPDX-License-Identifier: Apache-2.0
44 */
5+ import aws.sdk.kotlin.gradle.kmp.*
56
67description = " AWS client runtime support for generated service clients"
78
89plugins {
9- kotlin(" multiplatform" )
1010 id(" org.jetbrains.dokka" )
1111 id(" org.jetbrains.kotlinx.binary-compatibility-validator" ) version " 0.12.1"
1212 jacoco
1313}
1414
15- val platforms = listOf (" common" , " jvm" )
16-
17- // Allow subprojects to use internal API's
18- // See: https://kotlinlang.org/docs/reference/opt-in-requirements.html#opting-in-to-using-api
19- val optinAnnotations = listOf (
20- " kotlin.RequiresOptIn" ,
21- )
22-
23- fun projectNeedsPlatform (project : Project , platform : String ): Boolean {
24- val files = project.projectDir.listFiles()
25- val hasPosix = files.any { it.name == " posix" }
26- val hasDarwin = files.any { it.name == " darwin" }
27-
28- if (hasPosix && platform == " darwin" ) return false
29- if (hasDarwin && platform == " posix" ) return false
30- if (! hasPosix && ! hasDarwin && platform == " darwin" ) return false
31- // add implicit JVM target if it has a common module
32- return files.any { it.name == platform || (it.name == " common" && platform == " jvm" ) }
33- }
34-
35- kotlin {
36- jvm() // Create a JVM target with the default name 'jvm'
37- }
38-
3915val sdkVersion: String by project
4016
17+ val coroutinesVersion: String by project
18+ val kotestVersion: String by project
19+ val slf4jVersion: String by project
20+
4121subprojects {
22+ if (! needsKmpConfigured) return @subprojects
23+
4224 group = " aws.sdk.kotlin"
4325 version = sdkVersion
4426
@@ -47,39 +29,41 @@ subprojects {
4729 plugin(" org.jetbrains.dokka" )
4830 }
4931
50- logger.info(" configuring: $project " )
51-
52- // this works by iterating over each platform name and inspecting the projects files. If the project contains
53- // a directory with the corresponding platform name we apply the common configuration settings for that platform
54- // (which includes adding the multiplatform target(s)). This makes adding platform support easy and implicit in each
55- // subproject.
56- platforms.forEach { platform ->
57- if (projectNeedsPlatform(project, platform)) {
58- configure(listOf (project)) {
59- logger.info(" ${project.name} needs platform: $platform " )
60- apply (from = rootProject.file(" gradle/$platform .gradle" ))
61- }
62- }
63- }
32+ apply (from = rootProject.file(" gradle/publish.gradle" ))
6433
6534 kotlin {
6635 explicitApi()
6736
6837 sourceSets {
69- all {
70- val srcDir = if (name.endsWith(" Main" )) " src" else " test"
71- val resourcesPrefix = if (name.endsWith(" Test" )) " test-" else " "
72- // the name is always the platform followed by a suffix of either "Main" or "Test" (e.g. jvmMain, commonTest, etc)
73- val platform = name.substring(0 , name.length - 4 )
74- kotlin.srcDir(" $platform /$srcDir " )
75- resources.srcDir(" $platform /${resourcesPrefix} resources" )
76- languageSettings.progressiveMode = true
77- optinAnnotations.forEach { languageSettings.optIn(it) }
38+ // dependencies available for all subprojects
39+ named(" commonMain" ) {
40+ dependencies {
41+ // FIXME - refactor to only projects that need this
42+ implementation(" org.jetbrains.kotlinx:kotlinx-coroutines-core:$coroutinesVersion " )
43+ }
44+ }
45+
46+ named(" commonTest" ) {
47+ dependencies {
48+ implementation(" io.kotest:kotest-assertions-core:$kotestVersion " )
49+ }
50+ }
51+
52+ named(" jvmTest" ) {
53+ dependencies {
54+ implementation(" org.jetbrains.kotlinx:kotlinx-coroutines-debug:$coroutinesVersion " )
55+ implementation(" io.kotest:kotest-assertions-core-jvm:$kotestVersion " )
56+ implementation(" org.slf4j:slf4j-simple:$slf4jVersion " )
57+ }
7858 }
7959 }
8060 }
8161
82- apply (from = rootProject.file(" gradle/publish.gradle" ))
62+ kotlin.sourceSets.all {
63+ // Allow subprojects to use internal APIs
64+ // See https://kotlinlang.org/docs/reference/opt-in-requirements.html#opting-in-to-using-api
65+ listOf (" kotlin.RequiresOptIn" ).forEach { languageSettings.optIn(it) }
66+ }
8367
8468 dependencies {
8569 dokkaPlugin(project(" :dokka-aws" ))
0 commit comments