Skip to content

Commit

Permalink
Multi platform build with kotlin 2.0.0 (#106)
Browse files Browse the repository at this point in the history
  • Loading branch information
jillesvangurp authored Jun 2, 2024
1 parent de1e9b2 commit 285db7e
Show file tree
Hide file tree
Showing 5 changed files with 123 additions and 134 deletions.
6 changes: 1 addition & 5 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,7 @@ jobs:
# Library is built for JVM 1.8, but we run gradle itself with a newer one because we can
# and the publishing plugin requires it
java-version: 21
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v3
with:
gradle-version: 8.7
cache: 'gradle'
- name: Get Version
id: get-version
shell: bash
Expand Down Expand Up @@ -66,7 +63,6 @@ jobs:
./gradlew publishToSonatype closeSonatypeStagingRepository --info
fi
- uses: trstringer/manual-approval@v1
name: "Wait for approval to publish version '${{ steps.get-version.outputs.version }}'"
if: ${{ steps.get-version.outputs.is_snapshot == 'false' }}
Expand Down
5 changes: 1 addition & 4 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,6 @@ jobs:
# Library is built for JVM 1.8, but we run gradle itself with a newer one because we can
# and the publishing plugin requires it
java-version: 21
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v3
with:
gradle-version: 8.7
cache: 'gradle'
- name: Assemble & Test project
run: ./gradlew build
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,6 @@ node_modules/

# Secrets
*.secret

# created by kotlin 2.0
.kotlin
80 changes: 36 additions & 44 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import org.jetbrains.kotlin.cli.common.toBooleanLenient
import org.jetbrains.kotlin.config.JvmTarget
import org.jetbrains.kotlin.gradle.ExperimentalKotlinGradlePluginApi
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
import org.jetbrains.kotlin.gradle.targets.js.dsl.ExperimentalWasmDsl

val projectName = "konform"
val projectGroup = "io.konform"
Expand All @@ -12,14 +14,13 @@ val projectScmUrl = "https://github.com/konform-kt/konform.git"
val projectInceptionYear = 2018

val kotlinApiTarget = "1.7"
val jvmTarget = JvmTarget.JVM_1_8
val javaVersion = 8
val jvm = JvmTarget.JVM_1_8

/** The "CI" env var is a quasi-standard way to indicate that we're running on CI. */
val onCI: Boolean = System.getenv("CI")?.toBooleanLenient() ?: false

plugins {
kotlin("multiplatform") version "1.9.24"
kotlin("multiplatform") version "2.0.0"
id("maven-publish")
id("signing")
id("io.github.gradle-nexus.publish-plugin") version "2.0.0"
Expand All @@ -46,62 +47,53 @@ kotlin {
}
}
jvm {
compilations.all {
kotlinOptions.jvmTarget = jvmTarget.toString()
}
withJava()
testRuns["test"].executionTask.configure {
useJUnitPlatform()
}
}
jvmToolchain {
languageVersion = JavaLanguageVersion.of(javaVersion)
@OptIn(ExperimentalKotlinGradlePluginApi::class)
compilerOptions {
// note lang toolchain cannot be used here
// because gradle no longer supports running on java 8
jvmTarget = jvm
}
}
js(IR) {
browser {}
nodejs {}
}
// linuxX64()
// linuxArm64()
// linuxArm32Hfp()
// linuxMips32()
// linuxMipsel32()
// ios()
// iosX64()
// iosArm64()
// iosSimulatorArm64()
// macosX64()
// macosArm64()
// tvos()
// tvosArm64()
// tvosSimulatorArm64()
// tvosX64()
// watchos()
// watchosArm32()
// watchosSimulatorArm64()
// watchosArm64()
// watchosX86()
// watchosX64()
// wasm()
// wasm32()
// mingwX86()
// mingwX64()
linuxX64()
linuxArm64()
iosX64()
iosArm64()
macosX64()
macosArm64()
tvosArm64()
tvosX64()
watchosArm32()
watchosArm64()
watchosX64()
@OptIn(ExperimentalWasmDsl::class)
wasmJs {
browser()
nodejs()
d8()
}
@OptIn(ExperimentalWasmDsl::class)
wasmWasi {
nodejs()
}
mingwX64()
sourceSets {
val commonMain by getting {
commonMain {
dependencies {
compileOnly(kotlin("stdlib"))
api(kotlin("stdlib"))
}
}
val commonTest by getting {
commonTest {
dependencies {
implementation(kotlin("test"))
}
}
val jvmMain by getting {
dependencies {
compileOnly(kotlin("stdlib-jdk8"))
}
}
}
}
configure<org.jlleitschuh.gradle.ktlint.KtlintExtension> {
Expand Down
Loading

0 comments on commit 285db7e

Please sign in to comment.