diff --git a/.yarnrc b/.yarnrc new file mode 100644 index 00000000..f757a6ac --- /dev/null +++ b/.yarnrc @@ -0,0 +1 @@ +--ignore-engines true \ 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 index 13342e51..477ff387 100644 --- a/convention-plugins/src/main/kotlin/wasm-setup.gradle.kts +++ b/convention-plugins/src/main/kotlin/wasm-setup.gradle.kts @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023 Touchlab + * Copyright (c) 2024 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 * @@ -9,6 +9,8 @@ */ import org.jetbrains.kotlin.gradle.targets.js.dsl.ExperimentalWasmDsl +import org.jetbrains.kotlin.gradle.targets.js.nodejs.NodeJsRootExtension +import org.jetbrains.kotlin.gradle.targets.js.webpack.KotlinWebpackConfig plugins { kotlin("multiplatform") @@ -18,24 +20,38 @@ kotlin { val wasmEnabled = project.findProperty("enableWasm") == "true" if (wasmEnabled) { @OptIn(ExperimentalWasmDsl::class) - wasm { - browser() + wasmJs { + browser { + commonWebpackConfig { + devServer = (devServer ?: KotlinWebpackConfig.DevServer()).apply { + static = (static ?: mutableListOf()).apply { + add(project.rootDir.path) + } + } + } + } 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) + @Suppress("OPT_IN_USAGE") + applyDefaultHierarchyTemplate { + common { + group("jsAndWasmJs") { + withJs() + if (wasmEnabled) { + withWasm() + } } } } +} + +if (project.findProperty("enableWasm") == "true") { + rootProject.the().apply { + nodeVersion = "21.0.0-v8-canary202309143a48826a08" + nodeDownloadBaseUrl = "https://nodejs.org/download/v8-canary" + } } \ No newline at end of file diff --git a/extensions/kermit-bugsnag/build.gradle.kts b/extensions/kermit-bugsnag/build.gradle.kts index 1b288186..0d2b9182 100644 --- a/extensions/kermit-bugsnag/build.gradle.kts +++ b/extensions/kermit-bugsnag/build.gradle.kts @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Touchlab + * Copyright (c) 2024 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 * @@ -11,7 +11,6 @@ * the License. */ -import org.jetbrains.kotlin.gradle.ExperimentalKotlinGradlePluginApi import org.jetbrains.kotlin.gradle.tasks.KotlinCompile plugins { @@ -20,19 +19,28 @@ plugins { id("com.vanniktech.maven.publish") } -apply(from = "../../gradle/configure-crash-logger.gradle") kotlin { - @OptIn(ExperimentalKotlinGradlePluginApi::class) - targetHierarchy.default() androidTarget { publishAllLibraryVariants() } + macosX64() + macosArm64() + iosX64() + iosArm64() + iosSimulatorArm64() + tvosArm64() + tvosSimulatorArm64() + tvosX64() + watchosArm32() + watchosArm64() + watchosSimulatorArm64() + watchosDeviceArm64() + watchosX64() sourceSets { - commonMain { - dependencies { - api(libs.crashkios.bugsnag) - } + commonMain.dependencies { + api(libs.crashkios.bugsnag) + implementation(project(":kermit-core")) } } } diff --git a/extensions/kermit-crashlytics/build.gradle.kts b/extensions/kermit-crashlytics/build.gradle.kts index adc2adc5..4b9d64a9 100644 --- a/extensions/kermit-crashlytics/build.gradle.kts +++ b/extensions/kermit-crashlytics/build.gradle.kts @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Touchlab + * Copyright (c) 2024 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 * @@ -11,7 +11,6 @@ * the License. */ -import org.jetbrains.kotlin.gradle.ExperimentalKotlinGradlePluginApi import org.jetbrains.kotlin.gradle.tasks.KotlinCompile plugins { @@ -20,20 +19,28 @@ plugins { id("com.vanniktech.maven.publish") } -apply(from = "../../gradle/configure-crash-logger.gradle") - kotlin { - @OptIn(ExperimentalKotlinGradlePluginApi::class) - targetHierarchy.default() androidTarget { publishAllLibraryVariants() } + macosX64() + macosArm64() + iosX64() + iosArm64() + iosSimulatorArm64() + tvosArm64() + tvosSimulatorArm64() + tvosX64() + watchosArm32() + watchosArm64() + watchosSimulatorArm64() + watchosDeviceArm64() + watchosX64() sourceSets { - commonMain { - dependencies { - api(libs.crashkios.crashlytics) - } + commonMain.dependencies { + api(libs.crashkios.crashlytics) + implementation(project(":kermit-core")) } } } diff --git a/extensions/kermit-koin/build.gradle.kts b/extensions/kermit-koin/build.gradle.kts index 120cc67d..c848b01d 100644 --- a/extensions/kermit-koin/build.gradle.kts +++ b/extensions/kermit-koin/build.gradle.kts @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Touchlab + * Copyright (c) 2024 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 * @@ -11,7 +11,6 @@ * the License. */ -import org.jetbrains.kotlin.gradle.ExperimentalKotlinGradlePluginApi import org.jetbrains.kotlin.gradle.tasks.KotlinCompile plugins { @@ -21,8 +20,6 @@ plugins { } kotlin { - @OptIn(ExperimentalKotlinGradlePluginApi::class) - targetHierarchy.default() androidTarget { publishAllLibraryVariants() } @@ -55,11 +52,9 @@ kotlin { // androidNativeX64() sourceSets { - commonMain { - dependencies { - implementation(project(":kermit")) - implementation(libs.koin) - } + commonMain.dependencies { + implementation(project(":kermit")) + implementation(libs.koin) } } } diff --git a/gradle.properties b/gradle.properties index 7a60f215..1cb69e66 100644 --- a/gradle.properties +++ b/gradle.properties @@ -5,7 +5,7 @@ org.gradle.jvmargs=-Xmx4g SONATYPE_HOST=DEFAULT RELEASE_SIGNING_ENABLED=true GROUP=co.touchlab -VERSION_NAME=2.0.2 +VERSION_NAME=2.0.3 POM_NAME=Kermit POM_DESCRIPTION=Kermit The Log diff --git a/gradle/configure-crash-logger.gradle b/gradle/configure-crash-logger.gradle deleted file mode 100644 index 59eba06c..00000000 --- a/gradle/configure-crash-logger.gradle +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Copyright (c) 2021 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. - */ - -// Write generated Kotlin to disk. This tends to mess up the compiler, but quite useful to see the -// output during dev -def printCInteropKotlin = false - -kotlin { - def commonMain = sourceSets.commonMain - def commonTest = sourceSets.commonTest - - def darwinMain = sourceSets.create("darwinMain") - darwinMain.dependsOn(commonMain) - - [ - macosX64(), - macosArm64(), - iosX64(), - iosArm64(), - iosSimulatorArm64(), - tvosArm64(), - tvosSimulatorArm64(), - tvosX64(), - watchosArm32(), - watchosArm64(), - watchosSimulatorArm64(), - watchosDeviceArm64(), - watchosX64() - ].forEach { target -> -// target.compilations.main.cinterops.create(project.name) { -// includeDirs("$projectDir/src/include") -// compilerOpts("-DNS_FORMAT_ARGUMENT(A)=", "-D_Nullable_result=_Nullable") -// if (printCInteropKotlin) { -// extraOpts = listOf("-mode", "sourcecode") -// } -// } - - target.compilations.main.defaultSourceSet.dependsOn(darwinMain) - target.compilations.test.defaultSourceSet.dependsOn(commonTest) - } - - commonMain.dependencies { - implementation project(":kermit-core") - } -} diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 361ec7b3..6771ca50 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -4,20 +4,20 @@ minSdk = "21" compileSdk = "34" # Dependencies -kotlin = "1.9.10" +kotlin = "1.9.22" binaryCompatability = "0.13.2" androidx-core = "1.12.0" androidx-appcompat = "1.6.1" androidx-constraintLayout = "2.1.4" -androidx-navigationFragment = "2.7.2" -androidx-navigationUI = "2.7.2" +androidx-navigationFragment = "2.7.6" +androidx-navigationUI = "2.7.6" androidx-coordinatorLayout = "1.2.0" -android-gradle-plugin = "8.1.1" +android-gradle-plugin = "8.2.2" android-test-runner = "1.5.2" -google-services = "4.3.15" +google-services = "4.4.0" stately = "2.0.4" testhelp = "0.6.11" @@ -26,13 +26,13 @@ crashkios = "0.8.5" bugsnag = "5.31.1" bugsnag-gradle-plugin = "8.0.1" -koin-core = "3.5.0" -koin-android = "3.5.0" -koin-test = "3.5.0" +koin-core = "3.5.3" +koin-android = "3.5.3" +koin-test = "3.5.3" coroutines = "1.7.3" roboelectric = "4.10.3" buildConfig = "4.1.2" -mavenPublish = "0.25.3" +mavenPublish = "0.27.0" android-junitTest = "1.1.5" junit = "4.13.2" diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index ccebba77..033e24c4 100644 Binary files a/gradle/wrapper/gradle-wrapper.jar and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index a3638774..3fa8f862 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,7 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.2-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.4-bin.zip networkTimeout=10000 +validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/gradlew b/gradlew index 79a61d42..fcb6fca1 100755 --- a/gradlew +++ b/gradlew @@ -85,9 +85,6 @@ done APP_BASE_NAME=${0##*/} APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit -# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' - # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD=maximum @@ -133,10 +130,13 @@ location of your Java installation." fi else JAVACMD=java - which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + if ! command -v java >/dev/null 2>&1 + then + die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. Please set the JAVA_HOME variable in your environment to match the location of your Java installation." + fi fi # Increase the maximum file descriptors if we can. @@ -197,6 +197,10 @@ if "$cygwin" || "$msys" ; then done fi + +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' + # Collect all arguments for the java command; # * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of # shell script including quotes and variable substitutions, so put them in diff --git a/kermit-core/build.gradle.kts b/kermit-core/build.gradle.kts index 1809ce6c..454ab27a 100644 --- a/kermit-core/build.gradle.kts +++ b/kermit-core/build.gradle.kts @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Touchlab + * Copyright (c) 2024 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 * @@ -11,8 +11,6 @@ * the License. */ -import org.jetbrains.kotlin.gradle.ExperimentalKotlinGradlePluginApi -import org.jetbrains.kotlin.gradle.targets.js.nodejs.NodeJsRootExtension import org.jetbrains.kotlin.gradle.tasks.KotlinCompile plugins { @@ -23,8 +21,6 @@ plugins { } kotlin { - @OptIn(ExperimentalKotlinGradlePluginApi::class) - targetHierarchy.default() androidTarget { publishAllLibraryVariants() } @@ -57,99 +53,31 @@ kotlin { androidNativeX86() androidNativeX64() - sourceSets { - val commonMain by getting - val commonTest by getting { - dependencies { - implementation(kotlin("test")) - implementation(libs.stately.collections) - implementation(libs.testhelp) - implementation(project(":kermit-test")) - } - } - - val commonJvmMain by creating { - dependsOn(commonMain) - } - val commonJvmTest by creating { - dependsOn(commonTest) - dependsOn(commonJvmMain) - dependencies { - implementation(kotlin("test-junit")) - } - } - - val jvmMain by getting { - dependsOn(commonJvmMain) - } - val jvmTest by getting { - dependsOn(commonJvmTest) - dependsOn(jvmMain) - } - - val androidMain by getting { - dependsOn(commonJvmMain) - } - val androidUnitTest by getting { - dependsOn(androidMain) - // dependsOn(commonJvmTest) - dependencies { - implementation(libs.androidx.runner) - implementation(libs.roboelectric) + @Suppress("OPT_IN_USAGE") + applyDefaultHierarchyTemplate { + common { + group("commonJvm") { + withAndroidTarget() + withJvm() } } + } - val nativeMain by getting - val nativeTest by getting - - val darwinMain by creating { - dependsOn(nativeMain) - } - - val darwinTest by creating { - dependsOn(nativeTest) - } - - val jsAndWasmMain by getting { - dependsOn(commonMain) - getByName("jsMain").dependsOn(this) + sourceSets { + commonTest.dependencies { + implementation(kotlin("test")) + implementation(libs.stately.collections) + implementation(libs.testhelp) + implementation(project(":kermit-test")) } - val jsAndWasmTest by getting { - dependsOn(commonTest) - getByName("jsTest").dependsOn(this) + getByName("commonJvmTest").dependencies { + implementation(kotlin("test-junit")) } - targets.withType().all { - val mainSourceSet = compilations.getByName("main").defaultSourceSet - val testSourceSet = compilations.getByName("test").defaultSourceSet - - mainSourceSet.dependsOn( - when { - konanTarget.family.isAppleFamily -> darwinMain - konanTarget.family == org.jetbrains.kotlin.konan.target.Family.LINUX -> { - val linuxMain by getting - linuxMain - } - konanTarget.family == org.jetbrains.kotlin.konan.target.Family.MINGW -> { - val mingwMain by getting - mingwMain - } - konanTarget.family == org.jetbrains.kotlin.konan.target.Family.ANDROID -> { - val androidNativeMain by getting - androidNativeMain - } - else -> nativeMain - } - ) - - testSourceSet.dependsOn( - if (konanTarget.family.isAppleFamily) { - darwinTest - } else { - commonTest - } - ) + getByName("androidUnitTest").dependencies { + implementation(libs.androidx.runner) + implementation(libs.roboelectric) } } } @@ -169,7 +97,3 @@ android { tasks.withType { kotlinOptions.jvmTarget = "1.8" } - -rootProject.the().apply { - nodeVersion = "20.4.0" -} \ No newline at end of file diff --git a/kermit-core/src/androidUnitTest/kotlin/co/touchlab/kermit/LogcatLoggerTest.kt b/kermit-core/src/androidUnitTest/kotlin/co/touchlab/kermit/LogcatLoggerTest.kt index ff3e53af..27f37b50 100644 --- a/kermit-core/src/androidUnitTest/kotlin/co/touchlab/kermit/LogcatLoggerTest.kt +++ b/kermit-core/src/androidUnitTest/kotlin/co/touchlab/kermit/LogcatLoggerTest.kt @@ -20,6 +20,7 @@ import kotlin.test.Test import kotlin.test.assertEquals import kotlin.test.assertNotNull +@OptIn(ExperimentalKermitApi::class) @RunWith(RobolectricTestRunner::class) class LogcatLoggerTest { diff --git a/kermit-core/src/darwinMain/kotlin/co/touchlab/kermit/NSLogWriter.kt b/kermit-core/src/appleMain/kotlin/co/touchlab/kermit/NSLogWriter.kt similarity index 100% rename from kermit-core/src/darwinMain/kotlin/co/touchlab/kermit/NSLogWriter.kt rename to kermit-core/src/appleMain/kotlin/co/touchlab/kermit/NSLogWriter.kt diff --git a/kermit-core/src/darwinMain/kotlin/co/touchlab/kermit/OSLogWriter.kt b/kermit-core/src/appleMain/kotlin/co/touchlab/kermit/OSLogWriter.kt similarity index 100% rename from kermit-core/src/darwinMain/kotlin/co/touchlab/kermit/OSLogWriter.kt rename to kermit-core/src/appleMain/kotlin/co/touchlab/kermit/OSLogWriter.kt diff --git a/kermit-core/src/darwinMain/kotlin/co/touchlab/kermit/XcodeSeverityWriter.kt b/kermit-core/src/appleMain/kotlin/co/touchlab/kermit/XcodeSeverityWriter.kt similarity index 100% rename from kermit-core/src/darwinMain/kotlin/co/touchlab/kermit/XcodeSeverityWriter.kt rename to kermit-core/src/appleMain/kotlin/co/touchlab/kermit/XcodeSeverityWriter.kt diff --git a/kermit-core/src/darwinMain/kotlin/co/touchlab/kermit/platformLogWriter.kt b/kermit-core/src/appleMain/kotlin/co/touchlab/kermit/platformLogWriter.kt similarity index 100% rename from kermit-core/src/darwinMain/kotlin/co/touchlab/kermit/platformLogWriter.kt rename to kermit-core/src/appleMain/kotlin/co/touchlab/kermit/platformLogWriter.kt diff --git a/kermit-core/src/darwinTest/kotlin/co/touchlab/kermit/OSLogWriterTest.kt b/kermit-core/src/appleTest/kotlin/co/touchlab/kermit/OSLogWriterTest.kt similarity index 100% rename from kermit-core/src/darwinTest/kotlin/co/touchlab/kermit/OSLogWriterTest.kt rename to kermit-core/src/appleTest/kotlin/co/touchlab/kermit/OSLogWriterTest.kt diff --git a/kermit-core/src/jsAndWasmMain/kotlin/co/touchlab/kermit/ConsoleWriter.kt b/kermit-core/src/jsAndWasmJsMain/kotlin/co/touchlab/kermit/ConsoleWriter.kt similarity index 100% rename from kermit-core/src/jsAndWasmMain/kotlin/co/touchlab/kermit/ConsoleWriter.kt rename to kermit-core/src/jsAndWasmJsMain/kotlin/co/touchlab/kermit/ConsoleWriter.kt diff --git a/kermit-core/src/jsAndWasmMain/kotlin/co/touchlab/kermit/JsMutableLoggerConfig.kt b/kermit-core/src/jsAndWasmJsMain/kotlin/co/touchlab/kermit/JsMutableLoggerConfig.kt similarity index 100% rename from kermit-core/src/jsAndWasmMain/kotlin/co/touchlab/kermit/JsMutableLoggerConfig.kt rename to kermit-core/src/jsAndWasmJsMain/kotlin/co/touchlab/kermit/JsMutableLoggerConfig.kt diff --git a/kermit-core/src/jsAndWasmMain/kotlin/co/touchlab/kermit/KermitConfig.kt b/kermit-core/src/jsAndWasmJsMain/kotlin/co/touchlab/kermit/KermitConfig.kt similarity index 100% rename from kermit-core/src/jsAndWasmMain/kotlin/co/touchlab/kermit/KermitConfig.kt rename to kermit-core/src/jsAndWasmJsMain/kotlin/co/touchlab/kermit/KermitConfig.kt diff --git a/kermit-core/src/jsAndWasmMain/kotlin/co/touchlab/kermit/platformLogWriter.kt b/kermit-core/src/jsAndWasmJsMain/kotlin/co/touchlab/kermit/platformLogWriter.kt similarity index 100% rename from kermit-core/src/jsAndWasmMain/kotlin/co/touchlab/kermit/platformLogWriter.kt rename to kermit-core/src/jsAndWasmJsMain/kotlin/co/touchlab/kermit/platformLogWriter.kt diff --git a/kermit-core/src/jsAndWasmTest/kotlin/co/touchlab/kermit/ConsoleWriterTest.kt b/kermit-core/src/jsAndWasmJsTest/kotlin/co/touchlab/kermit/ConsoleWriterTest.kt similarity index 100% rename from kermit-core/src/jsAndWasmTest/kotlin/co/touchlab/kermit/ConsoleWriterTest.kt rename to kermit-core/src/jsAndWasmJsTest/kotlin/co/touchlab/kermit/ConsoleWriterTest.kt diff --git a/kermit-core/src/wasmMain/kotlin/co/touchlab/kermit/Wasm.ConsoleActual.kt b/kermit-core/src/wasmJsMain/kotlin/co/touchlab/kermit/Wasm.ConsoleActual.kt similarity index 100% rename from kermit-core/src/wasmMain/kotlin/co/touchlab/kermit/Wasm.ConsoleActual.kt rename to kermit-core/src/wasmJsMain/kotlin/co/touchlab/kermit/Wasm.ConsoleActual.kt diff --git a/kermit-simple/build.gradle.kts b/kermit-simple/build.gradle.kts index 5344aef8..cebe99f7 100644 --- a/kermit-simple/build.gradle.kts +++ b/kermit-simple/build.gradle.kts @@ -1,8 +1,5 @@ -import org.jetbrains.kotlin.gradle.ExperimentalKotlinGradlePluginApi -import org.jetbrains.kotlin.gradle.targets.js.nodejs.NodeJsRootExtension - /* - * Copyright (c) 2021 Touchlab + * Copyright (c) 2024 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 * @@ -21,8 +18,6 @@ plugins { } kotlin { - @OptIn(ExperimentalKotlinGradlePluginApi::class) - targetHierarchy.default() js { browser() nodejs() @@ -52,33 +47,23 @@ kotlin { androidNativeX64() sourceSets { - commonMain { - dependencies { - api(project(":kermit")) - } + commonMain.dependencies { + api(project(":kermit")) } - commonTest { - dependencies { - implementation(kotlin("test")) - implementation(project(":kermit-test")) - } + commonTest.dependencies { + implementation(kotlin("test")) + implementation(project(":kermit-test")) } val nonKotlinMain by creating { - dependsOn(getByName("commonMain")) + dependsOn(commonMain.get()) } val nonKotlinTest by creating { - dependsOn(getByName("commonTest")) + dependsOn(commonTest.get()) } - val jsAndWasmMain by getting { - dependsOn(nonKotlinMain) - getByName("jsMain").dependsOn(this) - } - val jsAndWasmTest by getting { - dependsOn(nonKotlinTest) - getByName("jsTest").dependsOn(this) - } + getByName("jsAndWasmJsMain").dependsOn(nonKotlinMain) + getByName("jsAndWasmJsTest").dependsOn(nonKotlinTest) targets.withType().all { val mainSourceSet = compilations.getByName("main").defaultSourceSet @@ -88,8 +73,4 @@ kotlin { testSourceSet.dependsOn(nonKotlinTest) } } -} - -rootProject.the().apply { - nodeVersion = "20.4.0" -} +} \ No newline at end of file diff --git a/kermit-test/build.gradle.kts b/kermit-test/build.gradle.kts index 44bb6242..60f39b03 100644 --- a/kermit-test/build.gradle.kts +++ b/kermit-test/build.gradle.kts @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Touchlab + * Copyright (c) 2024 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 * @@ -11,8 +11,6 @@ * the License. */ -import org.jetbrains.kotlin.gradle.ExperimentalKotlinGradlePluginApi -import org.jetbrains.kotlin.gradle.targets.js.nodejs.NodeJsRootExtension import org.jetbrains.kotlin.gradle.tasks.KotlinCompile plugins { @@ -23,8 +21,6 @@ plugins { } kotlin { - @OptIn(ExperimentalKotlinGradlePluginApi::class) - targetHierarchy.default() androidTarget { publishAllLibraryVariants() } @@ -58,12 +54,10 @@ kotlin { androidNativeX64() sourceSets { - commonMain { - dependencies { - implementation(kotlin("test")) - api(project(":kermit-core")) - implementation(libs.stately.collections) - } + commonMain.dependencies { + implementation(kotlin("test")) + api(project(":kermit-core")) + implementation(libs.stately.collections) } } } @@ -82,8 +76,4 @@ android { tasks.withType { kotlinOptions.jvmTarget = "1.8" -} - -rootProject.the().apply { - nodeVersion = "20.4.0" } \ No newline at end of file diff --git a/kermit/build.gradle.kts b/kermit/build.gradle.kts index f03e90d8..183e62ca 100644 --- a/kermit/build.gradle.kts +++ b/kermit/build.gradle.kts @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Touchlab + * Copyright (c) 2024 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 * @@ -11,8 +11,6 @@ * the License. */ -import org.jetbrains.kotlin.gradle.ExperimentalKotlinGradlePluginApi -import org.jetbrains.kotlin.gradle.targets.js.nodejs.NodeJsRootExtension import org.jetbrains.kotlin.gradle.tasks.KotlinCompile plugins { @@ -23,8 +21,6 @@ plugins { } kotlin { - @OptIn(ExperimentalKotlinGradlePluginApi::class) - targetHierarchy.default() androidTarget { publishAllLibraryVariants() } @@ -57,64 +53,29 @@ kotlin { androidNativeX86() androidNativeX64() - sourceSets { - val commonMain by getting { - dependencies { - api(project(":kermit-core")) - } - } - - val commonTest by getting { - dependencies { - implementation(kotlin("test")) - implementation(libs.testhelp) - implementation(project(":kermit-test")) - } - } - - val nonKotlinMain by creating { - dependsOn(commonMain) - } - - val nonKotlinTest by creating { - dependsOn(commonTest) - } - - val nativeMain by getting { - dependsOn(nonKotlinMain) - } - - val jsAndWasmMain by getting { - dependsOn(nonKotlinMain) - getByName("jsMain").dependsOn(this) - } - - val jsAndWasmTest by getting { - dependsOn(nonKotlinTest) - getByName("jsTest").dependsOn(this) - } - - val commonJvmMain by creating { - dependsOn(commonMain) - dependencies { - implementation(kotlin("test-junit")) + @Suppress("OPT_IN_USAGE") + applyDefaultHierarchyTemplate { + common { + group("commonJvm") { + withAndroidTarget() + withJvm() } } + } - val jvmMain by getting { - dependsOn(commonJvmMain) + sourceSets { + commonMain.dependencies { + api(project(":kermit-core")) } - val androidMain by getting { - dependsOn(commonJvmMain) + commonTest.dependencies { + implementation(kotlin("test")) + implementation(libs.testhelp) + implementation(project(":kermit-test")) } - targets.withType().all { - val mainSourceSet = compilations.getByName("main").defaultSourceSet - val testSourceSet = compilations.getByName("test").defaultSourceSet - - mainSourceSet.dependsOn(nativeMain) - testSourceSet.dependsOn(nonKotlinTest) + getByName("commonJvmMain").dependencies { + implementation(kotlin("test-junit")) } } } @@ -134,7 +95,3 @@ android { tasks.withType { kotlinOptions.jvmTarget = "1.8" } - -rootProject.the().apply { - nodeVersion = "20.4.0" -} diff --git a/kermit/src/commonTest/kotlin/co/touchlab/kermit/LoggerTest.kt b/kermit/src/commonTest/kotlin/co/touchlab/kermit/LoggerTest.kt index d3219fbe..2ea1f40f 100644 --- a/kermit/src/commonTest/kotlin/co/touchlab/kermit/LoggerTest.kt +++ b/kermit/src/commonTest/kotlin/co/touchlab/kermit/LoggerTest.kt @@ -276,6 +276,7 @@ class LoggerTest { } @Ignore + @Test fun testMutableLoggerConfig_MultiThreading_Severity() { val testLogWriter = TestLogWriter(loggable = Severity.Verbose) val config = mutableLoggerConfigInit(listOf(testLogWriter)) diff --git a/kermit/src/jsAndWasmMain/kotlin/co/touchlab/kermit/Defaults.kt b/kermit/src/jsAndWasmJsMain/kotlin/co/touchlab/kermit/Defaults.kt similarity index 100% rename from kermit/src/jsAndWasmMain/kotlin/co/touchlab/kermit/Defaults.kt rename to kermit/src/jsAndWasmJsMain/kotlin/co/touchlab/kermit/Defaults.kt diff --git a/samples/sample-production/KermitSampleIOS/Podfile.lock b/samples/sample-production/KermitSampleIOS/Podfile.lock index 574eee2c..60bca2bf 100644 --- a/samples/sample-production/KermitSampleIOS/Podfile.lock +++ b/samples/sample-production/KermitSampleIOS/Podfile.lock @@ -16,8 +16,8 @@ EXTERNAL SOURCES: SPEC CHECKSUMS: Bugsnag: b10579241f2b7ae6f7c6b04f587c33b38ec5dca7 - shared: 317794cafa8cc02021e4c781c7235ace20c9dfdc + shared: f3fb1ace83e0f517b7df687b0c17512ff2391ade PODFILE CHECKSUM: 3c766f7670f4e65f346904ffce262b5028e84071 -COCOAPODS: 1.12.1 +COCOAPODS: 1.14.3 diff --git a/samples/sample-production/build.gradle.kts b/samples/sample-production/build.gradle.kts index 315170ef..23dac572 100644 --- a/samples/sample-production/build.gradle.kts +++ b/samples/sample-production/build.gradle.kts @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020 Touchlab + * Copyright (c) 2024 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 * diff --git a/samples/sample-production/gradle/wrapper/gradle-wrapper.jar b/samples/sample-production/gradle/wrapper/gradle-wrapper.jar index 41d9927a..033e24c4 100644 Binary files a/samples/sample-production/gradle/wrapper/gradle-wrapper.jar and b/samples/sample-production/gradle/wrapper/gradle-wrapper.jar differ diff --git a/samples/sample-production/gradle/wrapper/gradle-wrapper.properties b/samples/sample-production/gradle/wrapper/gradle-wrapper.properties index 15de9024..3fa8f862 100644 --- a/samples/sample-production/gradle/wrapper/gradle-wrapper.properties +++ b/samples/sample-production/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,7 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.2-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.4-bin.zip +networkTimeout=10000 +validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/samples/sample-production/gradlew b/samples/sample-production/gradlew index 1b6c7873..fcb6fca1 100755 --- a/samples/sample-production/gradlew +++ b/samples/sample-production/gradlew @@ -55,7 +55,7 @@ # Darwin, MinGW, and NonStop. # # (3) This script is generated from the Groovy template -# https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt # within the Gradle project. # # You can find Gradle at https://github.com/gradle/gradle/. @@ -80,13 +80,10 @@ do esac done -APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit - -APP_NAME="Gradle" +# This is normally unused +# shellcheck disable=SC2034 APP_BASE_NAME=${0##*/} - -# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' +APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD=maximum @@ -133,22 +130,29 @@ location of your Java installation." fi else JAVACMD=java - which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + if ! command -v java >/dev/null 2>&1 + then + die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. Please set the JAVA_HOME variable in your environment to match the location of your Java installation." + fi fi # Increase the maximum file descriptors if we can. if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then case $MAX_FD in #( max*) + # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked. + # shellcheck disable=SC3045 MAX_FD=$( ulimit -H -n ) || warn "Could not query maximum file descriptor limit" esac case $MAX_FD in #( '' | soft) :;; #( *) + # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked. + # shellcheck disable=SC3045 ulimit -n "$MAX_FD" || warn "Could not set maximum file descriptor limit to $MAX_FD" esac @@ -193,6 +197,10 @@ if "$cygwin" || "$msys" ; then done fi + +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' + # Collect all arguments for the java command; # * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of # shell script including quotes and variable substitutions, so put them in @@ -205,6 +213,12 @@ set -- \ org.gradle.wrapper.GradleWrapperMain \ "$@" +# Stop when "xargs" is not available. +if ! command -v xargs >/dev/null 2>&1 +then + die "xargs is not available" +fi + # Use "xargs" to parse quoted args. # # With -n1 it outputs one arg per line, with the quotes and backslashes removed. diff --git a/samples/sample-production/gradlew.bat b/samples/sample-production/gradlew.bat index ac1b06f9..6689b85b 100644 --- a/samples/sample-production/gradlew.bat +++ b/samples/sample-production/gradlew.bat @@ -14,7 +14,7 @@ @rem limitations under the License. @rem -@if "%DEBUG%" == "" @echo off +@if "%DEBUG%"=="" @echo off @rem ########################################################################## @rem @rem Gradle startup script for Windows @@ -25,7 +25,8 @@ if "%OS%"=="Windows_NT" setlocal set DIRNAME=%~dp0 -if "%DIRNAME%" == "" set DIRNAME=. +if "%DIRNAME%"=="" set DIRNAME=. +@rem This is normally unused set APP_BASE_NAME=%~n0 set APP_HOME=%DIRNAME% @@ -40,7 +41,7 @@ if defined JAVA_HOME goto findJavaFromJavaHome set JAVA_EXE=java.exe %JAVA_EXE% -version >NUL 2>&1 -if "%ERRORLEVEL%" == "0" goto execute +if %ERRORLEVEL% equ 0 goto execute echo. echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. @@ -75,13 +76,15 @@ set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar :end @rem End local scope for the variables with windows NT shell -if "%ERRORLEVEL%"=="0" goto mainEnd +if %ERRORLEVEL% equ 0 goto mainEnd :fail rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of rem the _cmd.exe /c_ return code! -if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 -exit /b 1 +set EXIT_CODE=%ERRORLEVEL% +if %EXIT_CODE% equ 0 set EXIT_CODE=1 +if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% +exit /b %EXIT_CODE% :mainEnd if "%OS%"=="Windows_NT" endlocal diff --git a/samples/sample-production/shared/build.gradle.kts b/samples/sample-production/shared/build.gradle.kts index ed8bc267..e4a40ad8 100644 --- a/samples/sample-production/shared/build.gradle.kts +++ b/samples/sample-production/shared/build.gradle.kts @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020 Touchlab + * Copyright (c) 2024 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 * @@ -8,7 +8,6 @@ * 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.ExperimentalKotlinGradlePluginApi import org.jetbrains.kotlin.gradle.tasks.KotlinCompile plugins { @@ -38,32 +37,25 @@ val KERMIT_VERSION: String by project version = "0.0.1" kotlin { - @OptIn(ExperimentalKotlinGradlePluginApi::class) - targetHierarchy.default() androidTarget() - ios() + iosX64() + iosArm64() iosSimulatorArm64() sourceSets { - val commonMain by getting { - dependencies { - api("co.touchlab:kermit:${KERMIT_VERSION}") - implementation("co.touchlab:kermit-bugsnag:${KERMIT_VERSION}") - } + commonMain.dependencies { + api("co.touchlab:kermit:${KERMIT_VERSION}") + implementation("co.touchlab:kermit-bugsnag:${KERMIT_VERSION}") } - val commonTest by getting { - dependencies { - implementation(kotlin("test")) - implementation("co.touchlab:kermit-test:${KERMIT_VERSION}") - } + commonTest.dependencies { + implementation(kotlin("test")) + implementation("co.touchlab:kermit-test:${KERMIT_VERSION}") } - val iosMain by getting { - dependencies { - // Only if you want to talk to Kermit from Swift - api("co.touchlab:kermit-simple:${KERMIT_VERSION}") - } + iosMain.dependencies { + // Only if you want to talk to Kermit from Swift + api("co.touchlab:kermit-simple:${KERMIT_VERSION}") } } diff --git a/samples/sample-production/shared/shared.podspec b/samples/sample-production/shared/shared.podspec index cd3c4d7f..fa4c533f 100644 --- a/samples/sample-production/shared/shared.podspec +++ b/samples/sample-production/shared/shared.podspec @@ -11,6 +11,17 @@ Pod::Spec.new do |spec| + if !Dir.exist?('build/cocoapods/framework/shared.framework') || Dir.empty?('build/cocoapods/framework/shared.framework') + raise " + + Kotlin framework 'shared' doesn't exist yet, so a proper Xcode project can't be generated. + 'pod install' should be executed after running ':generateDummyFramework' Gradle task: + + ./gradlew :shared:generateDummyFramework + + Alternatively, proper pod installation is performed during Gradle sync in the IDE (if Podfile location is set)" + end + spec.pod_target_xcconfig = { 'KOTLIN_PROJECT_PATH' => ':shared', 'PRODUCT_MODULE_NAME' => 'shared', diff --git a/samples/sample/app-browser/build.gradle.kts b/samples/sample/app-browser/build.gradle.kts index cd3eb8fd..09c18115 100644 --- a/samples/sample/app-browser/build.gradle.kts +++ b/samples/sample/app-browser/build.gradle.kts @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020 Touchlab + * Copyright (c) 2024 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 * @@ -20,12 +20,10 @@ kotlin { binaries.executable() } sourceSets { - val jsMain by getting { - dependencies { - implementation(project(":shared")) - implementation("org.jetbrains.kotlinx:kotlinx-html-js:0.9.1") - implementation("co.touchlab:kermit-simple:${KERMIT_VERSION}") - } + jsMain.dependencies { + implementation(project(":shared")) + implementation("org.jetbrains.kotlinx:kotlinx-html-js:0.9.1") + implementation("co.touchlab:kermit-simple:${KERMIT_VERSION}") } } } diff --git a/samples/sample/app-browser/src/jsMain/kotlin/Browser.kt b/samples/sample/app-browser/src/jsMain/kotlin/Browser.kt index dd3bd827..19b0d559 100644 --- a/samples/sample/app-browser/src/jsMain/kotlin/Browser.kt +++ b/samples/sample/app-browser/src/jsMain/kotlin/Browser.kt @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020 Touchlab + * Copyright (c) 2024 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 * diff --git a/samples/sample/app/build.gradle.kts b/samples/sample/app/build.gradle.kts index cd0cd234..7a139e81 100644 --- a/samples/sample/app/build.gradle.kts +++ b/samples/sample/app/build.gradle.kts @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020 Touchlab + * Copyright (c) 2024 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 * @@ -29,8 +29,8 @@ android { versionCode = 1 versionName = "0.0.1" } - packagingOptions { - exclude("META-INF/*.kotlin_module") + packaging { + resources.excludes.add("META-INF/*.kotlin_module") } buildTypes { getByName("release") { diff --git a/samples/sample/build.gradle.kts b/samples/sample/build.gradle.kts index 2833f340..0c378781 100644 --- a/samples/sample/build.gradle.kts +++ b/samples/sample/build.gradle.kts @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020 Touchlab + * Copyright (c) 2024 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 * diff --git a/samples/sample/gradle/wrapper/gradle-wrapper.jar b/samples/sample/gradle/wrapper/gradle-wrapper.jar index 41d9927a..033e24c4 100644 Binary files a/samples/sample/gradle/wrapper/gradle-wrapper.jar and b/samples/sample/gradle/wrapper/gradle-wrapper.jar differ diff --git a/samples/sample/gradle/wrapper/gradle-wrapper.properties b/samples/sample/gradle/wrapper/gradle-wrapper.properties index 15de9024..3fa8f862 100644 --- a/samples/sample/gradle/wrapper/gradle-wrapper.properties +++ b/samples/sample/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,7 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.2-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.4-bin.zip +networkTimeout=10000 +validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/samples/sample/gradlew b/samples/sample/gradlew index 1b6c7873..fcb6fca1 100755 --- a/samples/sample/gradlew +++ b/samples/sample/gradlew @@ -55,7 +55,7 @@ # Darwin, MinGW, and NonStop. # # (3) This script is generated from the Groovy template -# https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt # within the Gradle project. # # You can find Gradle at https://github.com/gradle/gradle/. @@ -80,13 +80,10 @@ do esac done -APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit - -APP_NAME="Gradle" +# This is normally unused +# shellcheck disable=SC2034 APP_BASE_NAME=${0##*/} - -# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' +APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD=maximum @@ -133,22 +130,29 @@ location of your Java installation." fi else JAVACMD=java - which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + if ! command -v java >/dev/null 2>&1 + then + die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. Please set the JAVA_HOME variable in your environment to match the location of your Java installation." + fi fi # Increase the maximum file descriptors if we can. if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then case $MAX_FD in #( max*) + # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked. + # shellcheck disable=SC3045 MAX_FD=$( ulimit -H -n ) || warn "Could not query maximum file descriptor limit" esac case $MAX_FD in #( '' | soft) :;; #( *) + # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked. + # shellcheck disable=SC3045 ulimit -n "$MAX_FD" || warn "Could not set maximum file descriptor limit to $MAX_FD" esac @@ -193,6 +197,10 @@ if "$cygwin" || "$msys" ; then done fi + +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' + # Collect all arguments for the java command; # * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of # shell script including quotes and variable substitutions, so put them in @@ -205,6 +213,12 @@ set -- \ org.gradle.wrapper.GradleWrapperMain \ "$@" +# Stop when "xargs" is not available. +if ! command -v xargs >/dev/null 2>&1 +then + die "xargs is not available" +fi + # Use "xargs" to parse quoted args. # # With -n1 it outputs one arg per line, with the quotes and backslashes removed. diff --git a/samples/sample/gradlew.bat b/samples/sample/gradlew.bat index ac1b06f9..6689b85b 100644 --- a/samples/sample/gradlew.bat +++ b/samples/sample/gradlew.bat @@ -14,7 +14,7 @@ @rem limitations under the License. @rem -@if "%DEBUG%" == "" @echo off +@if "%DEBUG%"=="" @echo off @rem ########################################################################## @rem @rem Gradle startup script for Windows @@ -25,7 +25,8 @@ if "%OS%"=="Windows_NT" setlocal set DIRNAME=%~dp0 -if "%DIRNAME%" == "" set DIRNAME=. +if "%DIRNAME%"=="" set DIRNAME=. +@rem This is normally unused set APP_BASE_NAME=%~n0 set APP_HOME=%DIRNAME% @@ -40,7 +41,7 @@ if defined JAVA_HOME goto findJavaFromJavaHome set JAVA_EXE=java.exe %JAVA_EXE% -version >NUL 2>&1 -if "%ERRORLEVEL%" == "0" goto execute +if %ERRORLEVEL% equ 0 goto execute echo. echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. @@ -75,13 +76,15 @@ set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar :end @rem End local scope for the variables with windows NT shell -if "%ERRORLEVEL%"=="0" goto mainEnd +if %ERRORLEVEL% equ 0 goto mainEnd :fail rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of rem the _cmd.exe /c_ return code! -if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 -exit /b 1 +set EXIT_CODE=%ERRORLEVEL% +if %EXIT_CODE% equ 0 set EXIT_CODE=1 +if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% +exit /b %EXIT_CODE% :mainEnd if "%OS%"=="Windows_NT" endlocal diff --git a/samples/sample/shared/build.gradle.kts b/samples/sample/shared/build.gradle.kts index 29fb0733..b45abd6f 100644 --- a/samples/sample/shared/build.gradle.kts +++ b/samples/sample/shared/build.gradle.kts @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020 Touchlab + * Copyright (c) 2024 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 * @@ -8,7 +8,6 @@ * 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.ExperimentalKotlinGradlePluginApi import org.jetbrains.kotlin.gradle.targets.js.dsl.ExperimentalWasmDsl import org.jetbrains.kotlin.gradle.tasks.KotlinCompile @@ -39,38 +38,31 @@ val KERMIT_VERSION: String by project version = "0.0.1" kotlin { - @OptIn(ExperimentalKotlinGradlePluginApi::class) - targetHierarchy.default() androidTarget() - ios() + iosX64() + iosArm64() iosSimulatorArm64() js { browser() } @OptIn(ExperimentalWasmDsl::class) - wasm { + wasmJs { browser() } sourceSets { - val commonMain by getting { - dependencies { - implementation("co.touchlab:kermit:${KERMIT_VERSION}") - } + commonMain.dependencies { + implementation("co.touchlab:kermit:${KERMIT_VERSION}") } - val commonTest by getting { - dependencies { - implementation(kotlin("test")) + commonTest.dependencies { + implementation(kotlin("test")) - implementation("co.touchlab:kermit-test:${KERMIT_VERSION}") - } + implementation("co.touchlab:kermit-test:${KERMIT_VERSION}") } - val iosMain by getting { - dependencies { - // Only if you want to talk to Kermit from Swift - api("co.touchlab:kermit-simple:${KERMIT_VERSION}") - } + iosMain.dependencies { + // Only if you want to talk to Kermit from Swift + api("co.touchlab:kermit-simple:${KERMIT_VERSION}") } } cocoapods { diff --git a/samples/sample/shared/shared.podspec b/samples/sample/shared/shared.podspec index cd3c4d7f..fa4c533f 100644 --- a/samples/sample/shared/shared.podspec +++ b/samples/sample/shared/shared.podspec @@ -11,6 +11,17 @@ Pod::Spec.new do |spec| + if !Dir.exist?('build/cocoapods/framework/shared.framework') || Dir.empty?('build/cocoapods/framework/shared.framework') + raise " + + Kotlin framework 'shared' doesn't exist yet, so a proper Xcode project can't be generated. + 'pod install' should be executed after running ':generateDummyFramework' Gradle task: + + ./gradlew :shared:generateDummyFramework + + Alternatively, proper pod installation is performed during Gradle sync in the IDE (if Podfile location is set)" + end + spec.pod_target_xcconfig = { 'KOTLIN_PROJECT_PATH' => ':shared', 'PRODUCT_MODULE_NAME' => 'shared', diff --git a/samples/sample/wasm-browser/build.gradle.kts b/samples/sample/wasm-browser/build.gradle.kts index d9a8f7e5..1e3230f3 100644 --- a/samples/sample/wasm-browser/build.gradle.kts +++ b/samples/sample/wasm-browser/build.gradle.kts @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023 Touchlab + * Copyright (c) 2024 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 * @@ -15,17 +15,13 @@ val KERMIT_VERSION: String by project kotlin { @Suppress("OPT_IN_USAGE") - wasm { + wasmJs { browser() binaries.executable() } - sourceSets { - val wasmMain by getting { - dependencies { - implementation(project(":shared")) - implementation("co.touchlab:kermit-simple:${KERMIT_VERSION}") - } - } + sourceSets["wasmJsMain"].dependencies { + implementation(project(":shared")) + implementation("co.touchlab:kermit-simple:${KERMIT_VERSION}") } } diff --git a/settings.gradle.kts b/settings.gradle.kts index 548720ff..c3e5a345 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -38,4 +38,4 @@ pluginManagement { gradlePluginPortal() mavenCentral() } -} +} \ No newline at end of file