Skip to content

Update/enable all multiplatform targets #131

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 2 additions & 34 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ env:
OSSRH_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }}

jobs:
release_linux:
name: Build release on main platform (Linux)
release:
name: Build release
runs-on: ubuntu-22.04
steps:
- name: Checkout
Expand All @@ -37,35 +37,3 @@ jobs:
release_name: Release ${{ github.ref }}
draft: false
prerelease: false
release_macos:
name: Build release on MacOS
runs-on: macos-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up JDK 11
uses: actions/setup-java@v4
with:
distribution: zulu
java-version: 11
- uses: gradle/actions/setup-gradle@v3
with:
gradle-version: wrapper
cache-encryption-key: ${{ secrets.GRADLE_ENCRYPTION_KEY }}
- run: ./gradlew publishToSonatype closeSonatypeStagingRepository
release_windows:
name: Build release on Windows
runs-on: windows-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up JDK 11
uses: actions/setup-java@v4
with:
distribution: zulu
java-version: 11
- uses: gradle/actions/setup-gradle@v3
with:
gradle-version: wrapper
cache-encryption-key: ${{ secrets.GRADLE_ENCRYPTION_KEY }}
- run: ./gradlew publishToSonatype closeSonatypeStagingRepository
16 changes: 1 addition & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,18 +23,4 @@ Please refer to the original guides for more information.

## Supported Platforms

Currently, artifacts for the following platforms are supported:

- JVM
- JS (both browser and Node.js)
- WebAssembly (JS and WASI)
- Native

The supported Native targets are (following the Kotlin/Native [target support guidelines][1]):

| Tier 1 | Tier 2 | Tier 3 |
|:------------------|:------------------|:---------|
| macosX64 | linuxX64 | mingwX64 |
| macosArm64 | linuxArm64 | |

[1]: https://kotlinlang.org/docs/native-target-support.html
All the platforms are supported. (following the Kotlin/Native [target support guidelines](https://kotlinlang.org/docs/native-target-support.html)):
40 changes: 37 additions & 3 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,14 @@ import io.gitlab.arturbosch.detekt.Detekt
import org.jetbrains.kotlin.gradle.ExperimentalKotlinGradlePluginApi
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
import org.jetbrains.kotlin.gradle.dsl.KotlinVersion
import org.jetbrains.kotlin.gradle.targets.js.dsl.ExperimentalWasmDsl
import org.jetbrains.kotlin.gradle.ExperimentalWasmDsl
import org.jetbrains.kotlin.gradle.swiftexport.ExperimentalSwiftExportDsl
import org.jetbrains.kotlin.gradle.targets.js.testing.KotlinJsTest

plugins {
kotlin("multiplatform")
alias(libs.plugins.detekt)
alias(libs.plugins.versions)
id("jacoco-convention")
}

Expand Down Expand Up @@ -68,24 +70,52 @@ kotlin {
nodejs {
testTask(testConfig)
}
binaries.library()
}

@OptIn(ExperimentalWasmDsl::class)
wasmJs {
browser()
nodejs()
//d8()
binaries.library()
}

@OptIn(ExperimentalWasmDsl::class)
wasmWasi {
nodejs()
binaries.library()
}

// native, see https://kotlinlang.org/docs/native-target-support.html
// tier 1
macosX64()
macosArm64()
iosSimulatorArm64()
iosX64()
iosArm64()

// tier 2
linuxX64()
linuxArm64()
watchosSimulatorArm64()
watchosX64()
watchosArm32()
watchosArm64()
tvosSimulatorArm64()
tvosX64()
tvosArm64()

// tier 3
androidNativeArm32()
androidNativeArm64()
androidNativeX86()
androidNativeX64()
mingwX64()
macosX64()
macosArm64()
watchosDeviceArm64()

@OptIn(ExperimentalSwiftExportDsl::class)
swiftExport {}

sourceSets {
commonTest {
Expand All @@ -110,4 +140,8 @@ tasks {
dependsOn(this@withType)
}
}

// skip tests which require XCode components to be installed
named("tvosSimulatorArm64Test") { enabled = false }
named("watchosSimulatorArm64Test") { enabled = false }
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,9 @@ import io.github.gradlenexus.publishplugin.NexusPublishExtension
import org.gradle.api.publish.PublishingExtension
import org.gradle.api.publish.maven.MavenPublication
import org.gradle.api.publish.maven.plugins.MavenPublishPlugin
import org.gradle.api.publish.maven.tasks.AbstractPublishToMaven
import org.gradle.api.publish.maven.tasks.PublishToMavenRepository
import org.gradle.api.tasks.bundling.Jar
import org.gradle.kotlin.dsl.*
import org.gradle.nativeplatform.platform.internal.DefaultNativePlatform
import org.gradle.plugins.signing.Sign
import org.gradle.plugins.signing.SigningExtension
import org.gradle.plugins.signing.SigningPlugin
Expand Down Expand Up @@ -42,34 +40,10 @@ fun Project.configurePublishing() {
if (hasProperty("sonatypeUsername")) {
configureNexusPublishing()
}

// https://kotlinlang.org/docs/mpp-publish-lib.html#avoid-duplicate-publications
// Publication with name `kotlinMultiplatform` is for the default artifact.
// `configureNexusPublishing` adds sonatype publication tasks inside `afterEvaluate`.
rootProject.afterEvaluate {
val publicationsFromMainHost = listOf("jvm", "js", "linuxX64", "kotlinMultiplatform", "metadata")
configure<PublishingExtension> {
publications.matching { it.name in publicationsFromMainHost }.all {
val targetPublication = this@all
tasks.withType<AbstractPublishToMaven>()
.matching { it.publication == targetPublication }
.configureEach {
onlyIf {
// main publishing CI job is executed on Linux host
DefaultNativePlatform.getCurrentOperatingSystem().isLinux.apply {
if (!this) {
logger.lifecycle("Publication ${(it as AbstractPublishToMaven).publication.name} is skipped on current host")
}
}
}
}
}
}
}
}

private fun Project.configurePublications() {
val dokkaJar = tasks.create<Jar>("dokkaJar") {
val dokkaJar = tasks.register<Jar>("dokkaJar") {
group = "documentation"
archiveClassifier.set("javadoc")
from(tasks.findByName("dokkaHtml"))
Expand Down
10 changes: 7 additions & 3 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
kotlin.code.style=official
# https://kotlinlang.org/docs/whatsnew19.html#try-the-k2-compiler-in-your-project
kotlin.experimental.tryK2=false
org.gradle.jvmargs=-Xmx2g -XX:MaxMetaspaceSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
org.gradle.caching=true
# https://kotlinlang.org/docs/whatsnew19.html#preview-of-gradle-configuration-cache
org.gradle.configuration-cache=false
org.gradle.parallel=true
org.gradle.parallel=true
kotlin.apple.xcodeCompatibility.nowarn=true
kotlin.experimental.swift-export.enabled=true
kotlin.native.enableKlibsCrossCompilation=true
org.jetbrains.dokka.experimental.gradle.pluginMode=V2Enabled
org.jetbrains.dokka.experimental.gradle.pluginMode.noWarn=true
version=0.1-SNAPSHOT
8 changes: 5 additions & 3 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
[versions]
kotlin = "1.9.24"
detekt = "1.23.5"
dokka = "1.9.20"
kotlin = "2.1.10"
detekt = "1.23.7"
dokka = "2.0.0"
nexus = "1.3.0"
versionsPlugin = "0.52.0"

[plugins]
detekt = { id = "io.gitlab.arturbosch.detekt", version.ref = "detekt" }
versions = { id = "com.github.ben-manes.versions", version.ref = "versionsPlugin" }

[libraries]
detekt-formatting = { group = "io.gitlab.arturbosch.detekt", name = "detekt-formatting", version.ref = "detekt" }
Expand Down
4 changes: 2 additions & 2 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionSha256Sum=a4b4158601f8636cdeeab09bd76afb640030bb5b144aafe261a5e8af027dc612
distributionUrl=https\://services.gradle.org/distributions/gradle-8.8-bin.zip
distributionSha256Sum=371cb9fbebbe9880d147f59bab36d61eee122854ef8c9ee1ecf12b82368bcf10
distributionUrl=https\://services.gradle.org/distributions/gradle-8.12.1-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
Expand Down
Loading