diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 17167cf3..9c8fc2da 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -10,7 +10,7 @@ jobs: build: strategy: matrix: - os: [macOS-latest] + os: [macOS-latest, windows-latest] runs-on: ${{matrix.os}} steps: - name: Checkout the repo @@ -42,17 +42,27 @@ jobs: key: ${{ runner.os }}-gradle-${{ hashFiles('*.gradle.kts') }} restore-keys: | ${{ runner.os }}-gradle- - - name: Build + - name: Build for MacOS + if: matrix.os == 'macOS-latest' + run: ./gradlew build --no-daemon --stacktrace --build-cache + env: + S3_BUILD_CACHE_AWS_REGION: ${{ secrets.S3_BUILD_CACHE_AWS_REGION }} + S3_BUILD_CACHE_BUCKET_NAME: ${{ secrets.S3_BUILD_CACHE_BUCKET_NAME }} + S3_BUILD_CACHE_ACCESS_KEY_ID: ${{ secrets.S3_BUILD_CACHE_ACCESS_KEY_ID }} + S3_BUILD_CACHE_SECRET_KEY: ${{ secrets.S3_BUILD_CACHE_SECRET_KEY }} + CI: "true" + - name: Build for Windows + if: matrix.os == 'windows-latest' + run: ./gradlew kotlinUpgradeYarnLock build -PenableWasm=false --no-daemon --stacktrace --build-cache env: S3_BUILD_CACHE_AWS_REGION: ${{ secrets.S3_BUILD_CACHE_AWS_REGION }} S3_BUILD_CACHE_BUCKET_NAME: ${{ secrets.S3_BUILD_CACHE_BUCKET_NAME }} S3_BUILD_CACHE_ACCESS_KEY_ID: ${{ secrets.S3_BUILD_CACHE_ACCESS_KEY_ID }} S3_BUILD_CACHE_SECRET_KEY: ${{ secrets.S3_BUILD_CACHE_SECRET_KEY }} CI: "true" - run: ./gradlew -PbuildExtensions=true build --no-daemon --stacktrace --build-cache - name: Local Publish For Samples if: matrix.os == 'macOS-latest' - run: ./gradlew -PbuildExtensions=true publishToMavenLocal --no-daemon --stacktrace --build-cache + run: ./gradlew publishToMavenLocal --no-daemon --stacktrace --build-cache env: ORG_GRADLE_PROJECT_SIGNING_KEY: ${{ secrets.SIGNING_KEY }} ORG_GRADLE_PROJECT_signingInMemoryKey: ${{ secrets.SIGNING_KEY }} diff --git a/convention-plugins/build.gradle.kts b/convention-plugins/build.gradle.kts new file mode 100644 index 00000000..5a4a1d31 --- /dev/null +++ b/convention-plugins/build.gradle.kts @@ -0,0 +1,7 @@ +plugins { + `kotlin-dsl` +} + +dependencies { + implementation(libs.kotlin.gradlePlugin) +} \ No newline at end of file diff --git a/convention-plugins/settings.gradle.kts b/convention-plugins/settings.gradle.kts new file mode 100644 index 00000000..ac9c362c --- /dev/null +++ b/convention-plugins/settings.gradle.kts @@ -0,0 +1,10 @@ +dependencyResolutionManagement { + repositories { + gradlePluginPortal() + } + versionCatalogs { + create("libs") { + from(files("../gradle/libs.versions.toml")) + } + } +} \ No newline at end of file diff --git a/convention-plugins/src/main/kotlin/wasm-setup.gradle.kts b/convention-plugins/src/main/kotlin/wasm-setup.gradle.kts new file mode 100644 index 00000000..13342e51 --- /dev/null +++ b/convention-plugins/src/main/kotlin/wasm-setup.gradle.kts @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2023 Touchlab + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. + */ + +import org.jetbrains.kotlin.gradle.targets.js.dsl.ExperimentalWasmDsl + +plugins { + kotlin("multiplatform") +} + +kotlin { + val wasmEnabled = project.findProperty("enableWasm") == "true" + if (wasmEnabled) { + @OptIn(ExperimentalWasmDsl::class) + wasm { + browser() + nodejs() + d8() + binaries.executable() + } + } + sourceSets { + val jsAndWasmMain by creating + val jsAndWasmTest by creating + if (wasmEnabled) { + val wasmMain by getting { + dependsOn(jsAndWasmMain) + } + + val wasmTest by getting { + dependsOn(jsAndWasmTest) + } + } + } +} \ No newline at end of file diff --git a/gradle.properties b/gradle.properties index 8f537ab6..7a60f215 100644 --- a/gradle.properties +++ b/gradle.properties @@ -24,3 +24,4 @@ POM_DEVELOPER_ORG=Touchlab POM_DEVELOPER_URL=https://touchlab.co/ kotlin.js.ir.output.granularity=whole-program +enableWasm=true \ No newline at end of file diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 31fc9a4a..361ec7b3 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -69,6 +69,9 @@ coroutines-test = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-test", ve android-junitTest = { module = "androidx.test.ext:junit", version.ref = "android-junitTest" } junitTest = { module = "junit:junit", version.ref = "junit" } +# For convention-plugins +kotlin-gradlePlugin = { group = "org.jetbrains.kotlin", name = "kotlin-gradle-plugin", version.ref = "kotlin" } + [plugins] maven-publish = { id = "com.vanniktech.maven.publish", version.ref = "mavenPublish" } kotlin-multiplatform = { id = "org.jetbrains.kotlin.multiplatform", version.ref = "kotlin" } diff --git a/kermit-core/build.gradle.kts b/kermit-core/build.gradle.kts index 909a23c5..1809ce6c 100644 --- a/kermit-core/build.gradle.kts +++ b/kermit-core/build.gradle.kts @@ -12,7 +12,6 @@ */ import org.jetbrains.kotlin.gradle.ExperimentalKotlinGradlePluginApi -import org.jetbrains.kotlin.gradle.targets.js.dsl.ExperimentalWasmDsl import org.jetbrains.kotlin.gradle.targets.js.nodejs.NodeJsRootExtension import org.jetbrains.kotlin.gradle.tasks.KotlinCompile @@ -20,6 +19,7 @@ plugins { id("com.android.library") kotlin("multiplatform") id("com.vanniktech.maven.publish") + id("wasm-setup") } kotlin { @@ -33,13 +33,6 @@ kotlin { browser() nodejs() } - @OptIn(ExperimentalWasmDsl::class) - wasm { - browser() - nodejs() - d8() - binaries.executable() - } macosX64() macosArm64() @@ -117,15 +110,14 @@ kotlin { dependsOn(nativeTest) } - val jsAndWasmMain by creating { + val jsAndWasmMain by getting { dependsOn(commonMain) getByName("jsMain").dependsOn(this) - getByName("wasmMain").dependsOn(this) } - val jsAndWasmTest by creating { + + val jsAndWasmTest by getting { dependsOn(commonTest) getByName("jsTest").dependsOn(this) - getByName("wasmTest").dependsOn(this) } targets.withType().all { diff --git a/kermit-simple/build.gradle.kts b/kermit-simple/build.gradle.kts index a44ffc26..5344aef8 100644 --- a/kermit-simple/build.gradle.kts +++ b/kermit-simple/build.gradle.kts @@ -1,5 +1,4 @@ import org.jetbrains.kotlin.gradle.ExperimentalKotlinGradlePluginApi -import org.jetbrains.kotlin.gradle.targets.js.dsl.ExperimentalWasmDsl import org.jetbrains.kotlin.gradle.targets.js.nodejs.NodeJsRootExtension /* @@ -18,6 +17,7 @@ import org.jetbrains.kotlin.gradle.targets.js.nodejs.NodeJsRootExtension plugins { kotlin("multiplatform") id("com.vanniktech.maven.publish") + id("wasm-setup") } kotlin { @@ -27,13 +27,6 @@ kotlin { browser() nodejs() } - @OptIn(ExperimentalWasmDsl::class) - wasm { - browser() - nodejs() - d8() - binaries.executable() - } macosX64() macosArm64() @@ -78,19 +71,15 @@ kotlin { dependsOn(getByName("commonTest")) } - val jsMain by getting { + val jsAndWasmMain by getting { dependsOn(nonKotlinMain) + getByName("jsMain").dependsOn(this) } - - val jsTest by getting { - dependsOn(nonKotlinTest) - } - val wasmMain by getting { - dependsOn(nonKotlinMain) - } - val wasmTest by getting { + val jsAndWasmTest by getting { dependsOn(nonKotlinTest) + getByName("jsTest").dependsOn(this) } + targets.withType().all { val mainSourceSet = compilations.getByName("main").defaultSourceSet val testSourceSet = compilations.getByName("test").defaultSourceSet diff --git a/kermit-test/build.gradle.kts b/kermit-test/build.gradle.kts index ae30f3d7..44bb6242 100644 --- a/kermit-test/build.gradle.kts +++ b/kermit-test/build.gradle.kts @@ -12,7 +12,6 @@ */ import org.jetbrains.kotlin.gradle.ExperimentalKotlinGradlePluginApi -import org.jetbrains.kotlin.gradle.targets.js.dsl.ExperimentalWasmDsl import org.jetbrains.kotlin.gradle.targets.js.nodejs.NodeJsRootExtension import org.jetbrains.kotlin.gradle.tasks.KotlinCompile @@ -20,6 +19,7 @@ plugins { id("com.android.library") kotlin("multiplatform") id("com.vanniktech.maven.publish") + id("wasm-setup") } kotlin { @@ -33,13 +33,6 @@ kotlin { browser() nodejs() } - @OptIn(ExperimentalWasmDsl::class) - wasm { - browser() - nodejs() - d8() - binaries.executable() - } macosX64() macosArm64() diff --git a/kermit/build.gradle.kts b/kermit/build.gradle.kts index dcb3b746..f03e90d8 100644 --- a/kermit/build.gradle.kts +++ b/kermit/build.gradle.kts @@ -12,7 +12,6 @@ */ import org.jetbrains.kotlin.gradle.ExperimentalKotlinGradlePluginApi -import org.jetbrains.kotlin.gradle.targets.js.dsl.ExperimentalWasmDsl import org.jetbrains.kotlin.gradle.targets.js.nodejs.NodeJsRootExtension import org.jetbrains.kotlin.gradle.tasks.KotlinCompile @@ -20,6 +19,7 @@ plugins { id("com.android.library") kotlin("multiplatform") id("com.vanniktech.maven.publish") + id("wasm-setup") } kotlin { @@ -33,13 +33,6 @@ kotlin { browser() nodejs() } - @OptIn(ExperimentalWasmDsl::class) - wasm { - browser() - nodejs() - d8() - binaries.executable() - } macosX64() macosArm64() @@ -70,6 +63,7 @@ kotlin { api(project(":kermit-core")) } } + val commonTest by getting { dependencies { implementation(kotlin("test")) @@ -90,15 +84,14 @@ kotlin { dependsOn(nonKotlinMain) } - val jsAndWasmMain by creating { + val jsAndWasmMain by getting { dependsOn(nonKotlinMain) getByName("jsMain").dependsOn(this) - getByName("wasmMain").dependsOn(this) } - val jsAndWasmTest by creating { + + val jsAndWasmTest by getting { dependsOn(nonKotlinTest) getByName("jsTest").dependsOn(this) - getByName("wasmTest").dependsOn(this) } val commonJvmMain by creating { diff --git a/settings.gradle.kts b/settings.gradle.kts index 0b1c8005..548720ff 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -32,6 +32,7 @@ project(":kermit-koin").projectDir = File("extensions/kermit-koin") //project(":kermit-ir-plugin-native").projectDir = File("plugin/kermit-ir-plugin-native") pluginManagement { + includeBuild("convention-plugins") repositories { google() gradlePluginPortal()