From 39402c4bfd6a433264be5d2fe5ab2e50948aed72 Mon Sep 17 00:00:00 2001 From: Vitaly Pestryakov <34812712+dsvag@users.noreply.github.com> Date: Fri, 9 Feb 2024 19:04:17 +0200 Subject: [PATCH] use multiplatform plugin instead of jvm --- .../kotlin/elmslie.kotlin-jvm-lib.gradle.kts | 45 ------------------- ...lmslie.kotlin-multiplatform-lib.gradle.kts | 14 +++--- build.gradle.kts | 2 +- elmslie-core/build.gradle.kts | 22 ++++++--- gradle/libs.versions.toml | 2 +- 5 files changed, 25 insertions(+), 60 deletions(-) delete mode 100644 build-logic/src/main/kotlin/elmslie.kotlin-jvm-lib.gradle.kts diff --git a/build-logic/src/main/kotlin/elmslie.kotlin-jvm-lib.gradle.kts b/build-logic/src/main/kotlin/elmslie.kotlin-jvm-lib.gradle.kts deleted file mode 100644 index a6e69bbe..00000000 --- a/build-logic/src/main/kotlin/elmslie.kotlin-jvm-lib.gradle.kts +++ /dev/null @@ -1,45 +0,0 @@ -@file:Suppress("UnstableApiUsage") - -plugins { - id("org.jetbrains.kotlin.jvm") - id("org.jetbrains.dokka") - id("com.android.lint") - id("elmslie.base-lib") - id("elmslie.detekt") - id("elmslie.tests-convention") - `maven-publish` -} - -java { - withJavadocJar() - withSourcesJar() -} - -tasks.named("javadocJar") { from(tasks.named("dokkaJavadoc")) } - -val catalog = extensions.getByType().named("libs") - -dependencies { catalog.findLibrary("dokka-kotlinAsJavaPlugin").ifPresent { dokkaHtmlPlugin(it) } } - -lint { - checkDependencies = true - ignoreTestSources = true - - abortOnError = true - warningsAsErrors = true - - htmlReport = true - xmlReport = false -} - -val libraryGroup: String by project -val libraryVersion: String by project - -afterEvaluate { - publishing.publications.create("maven") { - from(components["java"]) - artifactId = project.name - groupId = libraryGroup - version = libraryVersion - } -} diff --git a/build-logic/src/main/kotlin/elmslie.kotlin-multiplatform-lib.gradle.kts b/build-logic/src/main/kotlin/elmslie.kotlin-multiplatform-lib.gradle.kts index a85a9692..6c6c26d1 100644 --- a/build-logic/src/main/kotlin/elmslie.kotlin-multiplatform-lib.gradle.kts +++ b/build-logic/src/main/kotlin/elmslie.kotlin-multiplatform-lib.gradle.kts @@ -1,22 +1,22 @@ -@file:Suppress("UnstableApiUsage") +import org.jetbrains.kotlin.gradle.dsl.JvmTarget plugins { kotlin("multiplatform") - id("com.android.library") id("elmslie.detekt") } kotlin { applyDefaultHierarchyTemplate() - androidTarget { + jvm { compilations.all { - kotlinOptions { - jvmTarget = JvmTarget.toString() + compilerOptions.configure { + jvmTarget.set(JvmTarget.JVM_11) } } } - iosX64() iosArm64() -} + iosSimulatorArm64() + iosX64() +} \ No newline at end of file diff --git a/build.gradle.kts b/build.gradle.kts index b22d873a..e1358f9a 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,4 +1,4 @@ plugins { alias(libs.plugins.androidApplication) apply false - alias(libs.plugins.kotlinJvm) apply false + alias(libs.plugins.kotlinMultiplatform) apply false } \ No newline at end of file diff --git a/elmslie-core/build.gradle.kts b/elmslie-core/build.gradle.kts index a16e6bdd..36a476e5 100644 --- a/elmslie-core/build.gradle.kts +++ b/elmslie-core/build.gradle.kts @@ -1,9 +1,19 @@ plugins { - id("elmslie.kotlin-jvm-lib") - id("elmslie.tests-convention") + id("elmslie.kotlin-multiplatform-lib") } -dependencies { - implementation(libs.kotlinx.coroutinesCore) - testImplementation(libs.kotlinx.coroutinesTest) -} +kotlin { + sourceSets { + val commonMain by getting { + dependencies { + implementation(libs.kotlinx.coroutinesCore) + } + } + val commonTest by getting { + dependencies { + implementation(libs.kotlinx.coroutinesTest) + implementation(libs.kotlin.test) + } + } + } +} \ No newline at end of file diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index f7570ec3..0c1f9d04 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -24,5 +24,5 @@ kotlinx-coroutinesCore = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-co kotlinx-coroutinesTest = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-test", version.ref = "coroutines" } [plugins] -kotlinJvm = { id = "org.jetbrains.kotlin.jvm", version.ref = "kotlin" } +kotlinMultiplatform = { id = "org.jetbrains.kotlin.multiplatform", version.ref = "kotlin" } androidApplication = { id = "com.android.application", version.ref = "agp" } \ No newline at end of file