Skip to content
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

multi platform build with kotlin 2.0.0 #106

Merged
merged 12 commits into from
Jun 2, 2024
Merged
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
Comment on lines +55 to +57
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not true?

I'm not opposed to bumping the JVM target version, but it should be 11 (LTS) instead of 10, and preferably for a good reason.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

right, my bad, I was getting some weird error earlier. It seems 1.8 works after all. I meant to update to 11 but was getting an error. I'll push the fix.

}
}
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