Skip to content

Commit e1864e3

Browse files
authored
chore: add a posix source set for code which must run on Linux and Apple (POSIX-compliant) but not on MinGW/Windows (not POSIX-compliant) (#131)
1 parent c17e9c4 commit e1864e3

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

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

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,12 +42,13 @@ val Project.hasDesktop: Boolean get() = hasNative || files.any { it.name == "des
4242
val Project.hasLinux: Boolean get() = hasNative || hasJvmAndNative || files.any { it.name == "linux" }
4343
val Project.hasApple: Boolean get() = hasNative || hasJvmAndNative || files.any { it.name == "apple" }
4444
val Project.hasWindows: Boolean get() = hasNative || files.any { it.name == "windows" }
45+
val Project.hasPosix: Boolean get() = hasNative || hasJvmAndNative || files.any { it.name == "posix" }
4546

4647
/**
4748
* Test if a project follows the convention and needs configured for KMP (used in handful of spots where we have a
4849
* subproject that is just a container for other projects but isn't a KMP project itself).
4950
*/
50-
val Project.needsKmpConfigured: Boolean get() = hasCommon || hasJvm || hasNative || hasJs || hasJvmAndNative || hasDesktop || hasLinux || hasApple || hasWindows
51+
val Project.needsKmpConfigured: Boolean get() = hasCommon || hasJvm || hasNative || hasJs || hasJvmAndNative || hasDesktop || hasLinux || hasApple || hasWindows || hasPosix
5152

5253
@OptIn(ExperimentalKotlinGradlePluginApi::class)
5354
fun Project.configureKmpTargets() {
@@ -96,6 +97,16 @@ fun Project.configureKmpTargets() {
9697
}
9798
}
9899
}
100+
101+
if (hasPosix) {
102+
common {
103+
group("posix") {
104+
// Linux and Apple but NOT Mingw/Windows
105+
withLinux()
106+
withMacos()
107+
}
108+
}
109+
}
99110
}
100111

101112
// enable the targets

0 commit comments

Comments
 (0)