Skip to content

Commit

Permalink
test: fix test multiplatform for ktlin 1.9.20
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolasfara authored and renovate[bot] committed Nov 9, 2023
1 parent e3af6ea commit a625c52
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 48 deletions.
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
@file:Suppress("UnstableApiUsage")

import org.danilopianini.gradle.mavencentral.DocStyle
import org.danilopianini.gradle.mavencentral.JavadocJar
import org.jetbrains.kotlin.gradle.plugin.KotlinTarget
import org.jetbrains.kotlin.util.capitalizeDecapitalize.toLowerCaseAsciiOnly
import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeTarget
import java.util.*

@Suppress("DSL_SCOPE_VIOLATION")
plugins {
kotlin("multiplatform")
id("org.danilopianini.publish-on-central")
Expand Down Expand Up @@ -33,43 +32,7 @@ kotlin {
nodejs()
binaries.library()
}
val hostOs = System.getProperty("os.name").trim().toLowerCaseAsciiOnly()
val hostArch = System.getProperty("os.arch").trim().toLowerCaseAsciiOnly()
val nativeTarget: (String, org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeTarget.() -> Unit) -> KotlinTarget =
when (hostOs to hostArch) {
"linux" to "aarch64" -> ::linuxArm64
"linux" to "amd64" -> ::linuxX64
"linux" to "arm", "linux" to "arm32" -> ::linuxArm32Hfp
"linux" to "mips", "linux" to "mips32" -> ::linuxMips32
"linux" to "mipsel", "linux" to "mips32el" -> ::linuxMipsel32
"mac os x" to "aarch64" -> ::macosArm64
"mac os x" to "amd64", "mac os x" to "x86_64" -> ::macosX64
"windows" to "amd64", "windows server 2022" to "amd64" -> ::mingwX64
"windows" to "x86" -> ::mingwX86
"windows 11" to "amd64", "windows server 2022" to "amd64" -> ::mingwX64
"windows 11" to "x86" -> ::mingwX86
else -> throw GradleException("Host OS '$hostOs' with arch '$hostArch' is not supported in Kotlin/Native.")
}
nativeTarget("native") {
binaries {
sharedLib()
staticLib()
// Remove if it is not executable
"main".let { executable ->
executable {
entryPoint = executable
}
// Enable wasm32
wasm32 {
binaries {
executable {
entryPoint = executable
}
}
}
}
}
}

sourceSets {
val commonMain by getting {
dependencies {
Expand All @@ -86,17 +49,54 @@ kotlin {
implementation(kotlin("test-junit"))
}
}
val nativeMain by getting {
val nativeMain by creating {
dependsOn(commonMain)
}
val nativeTest by getting {
val nativeTest by creating {
dependsOn(commonTest)
}
}

val nativeSetup: KotlinNativeTarget.() -> Unit = {
compilations["main"].defaultSourceSet.dependsOn(kotlin.sourceSets["nativeMain"])
compilations["test"].defaultSourceSet.dependsOn(kotlin.sourceSets["nativeTest"])
binaries {
executable()
sharedLib()
staticLib()
}
}

applyDefaultHierarchyTemplate()
/*
* Linux 64
*/
linuxX64(nativeSetup)
linuxArm64(nativeSetup)
/*
* Win 64
*/
mingwX64(nativeSetup)
/*
* Apple OSs
*/
macosX64(nativeSetup)
macosArm64(nativeSetup)
iosArm64(nativeSetup)
iosX64(nativeSetup)
iosSimulatorArm64(nativeSetup)
watchosArm32(nativeSetup)
watchosX64(nativeSetup)
watchosSimulatorArm64(nativeSetup)
tvosArm64(nativeSetup)
tvosX64(nativeSetup)
tvosSimulatorArm64(nativeSetup)

targets.all {
compilations.all {
kotlinOptions {
allWarningsAsErrors = true
freeCompilerArgs += listOf("-Xexpect-actual-classes")
}
}
}
Expand All @@ -114,7 +114,7 @@ publishOnCentral {
docStyle.set(DocStyle.HTML)
projectLongName.set("Template for Kotlin Multiplatform Project")
projectDescription.set("A template repository for Kotlin Multiplatform projects")
repository("https://maven.pkg.github.com/danysk/${rootProject.name}".toLowerCase()) {
repository("https://maven.pkg.github.com/danysk/${rootProject.name}".lowercase()) {
user.set("DanySK")
password.set(System.getenv("GITHUB_TOKEN"))
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
kotlin.native.ignoreDisabledTargets=true

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ tests:
- 'generateMetadataFileForJvmPublication'
- 'generateMetadataFileForKotlinOSSRHPublication'
- 'generateMetadataFileForKotlinMultiplatformPublication'
- 'generateMetadataFileForNativePublication'
- 'generateMetadataFileForWasm32Publication'
options:
- '--stacktrace'
expectation:
Expand Down

0 comments on commit a625c52

Please sign in to comment.