From 8a80acb19ab01a85df5801709505059a6a45a4c6 Mon Sep 17 00:00:00 2001 From: Guillermo Mazzola Date: Sun, 3 Dec 2023 15:31:59 +0100 Subject: [PATCH] Converted `core` to multiplatform project --- build.gradle.kts | 1 + .../kotlin/maven-central-publish.gradle.kts | 15 ++++++------- core/build.gradle.kts | 21 ++++++------------- .../kotlin/bar/Bar.kt | 0 .../kotlin/bar/impl/BarImpl.kt | 0 .../kotlin/baz/Baz.kt | 0 .../kotlin/foo/Foo.kt | 0 .../kotlin/foo/bar/FooBar.kt | 0 .../kotlin/foo/bar/impl/FooBarImpl.kt | 0 .../kotlin/foo/impl/FooImpl.kt | 0 .../resources/bar/.codeowners | 0 .../resources/bar/impl/BarImpl.codeowners | 0 .../resources/baz/Baz.codeowners | 0 .../resources/foo/.codeowners | 0 .../resources/foo/bar/.codeowners | 0 .../io/github/gmazzo/codeowners/CodeOwners.kt | 0 .../gmazzo/codeowners/CodeOwnersTest.kt | 0 gradle/libs.versions.toml | 1 + plugin/build.gradle.kts | 2 +- settings.gradle.kts | 2 +- 20 files changed, 18 insertions(+), 24 deletions(-) rename core/src/{testFixtures => commonTest}/kotlin/bar/Bar.kt (100%) rename core/src/{testFixtures => commonTest}/kotlin/bar/impl/BarImpl.kt (100%) rename core/src/{testFixtures => commonTest}/kotlin/baz/Baz.kt (100%) rename core/src/{testFixtures => commonTest}/kotlin/foo/Foo.kt (100%) rename core/src/{testFixtures => commonTest}/kotlin/foo/bar/FooBar.kt (100%) rename core/src/{testFixtures => commonTest}/kotlin/foo/bar/impl/FooBarImpl.kt (100%) rename core/src/{testFixtures => commonTest}/kotlin/foo/impl/FooImpl.kt (100%) rename core/src/{testFixtures => commonTest}/resources/bar/.codeowners (100%) rename core/src/{testFixtures => commonTest}/resources/bar/impl/BarImpl.codeowners (100%) rename core/src/{testFixtures => commonTest}/resources/baz/Baz.codeowners (100%) rename core/src/{testFixtures => commonTest}/resources/foo/.codeowners (100%) rename core/src/{testFixtures => commonTest}/resources/foo/bar/.codeowners (100%) rename core/src/{main => jvmMain}/kotlin/io/github/gmazzo/codeowners/CodeOwners.kt (100%) rename core/src/{test => jvmTest}/kotlin/io/github/gmazzo/codeowners/CodeOwnersTest.kt (100%) diff --git a/build.gradle.kts b/build.gradle.kts index 84c4219..8eabf72 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,6 +1,7 @@ plugins { base alias(libs.plugins.kotlin.jvm) apply false + alias(libs.plugins.kotlin.multiplatform) apply false alias(libs.plugins.gradle.nexusPublish) `git-versioning` } diff --git a/buildSrc/src/main/kotlin/maven-central-publish.gradle.kts b/buildSrc/src/main/kotlin/maven-central-publish.gradle.kts index 338e208..43ec951 100644 --- a/buildSrc/src/main/kotlin/maven-central-publish.gradle.kts +++ b/buildSrc/src/main/kotlin/maven-central-publish.gradle.kts @@ -1,5 +1,4 @@ plugins { - java `maven-publish` org.jetbrains.dokka } @@ -19,13 +18,15 @@ if (signingKey != null && signingPassword != null) { logger.warn("Artifact signing disabled due lack of signing properties `signingKey` and `signingPassword`") } -java { - withJavadocJar() - withSourcesJar() -} +plugins.withId("java") { + configure { + withJavadocJar() + withSourcesJar() + } -tasks.named("javadocJar") { - from(tasks.dokkaJavadoc) + tasks.named("javadocJar") { + from(tasks.dokkaJavadoc) + } } publishing.publications.withType().configureEach { diff --git a/core/build.gradle.kts b/core/build.gradle.kts index f580f3b..a3fb157 100644 --- a/core/build.gradle.kts +++ b/core/build.gradle.kts @@ -1,6 +1,5 @@ plugins { - alias(libs.plugins.kotlin.jvm) - `java-test-fixtures` + alias(libs.plugins.kotlin.multiplatform) `maven-central-publish` jacoco } @@ -9,21 +8,13 @@ description = "CodeOwners Library" java.toolchain.languageVersion.set(JavaLanguageVersion.of(8)) -testing.suites.withType { - useKotlinTest(libs.versions.kotlin) - dependencies { - implementation(platform(libs.junit.bom)) - } +kotlin { + jvm() } -publishing.publications { - create("java") { from(components["java"]) } -} - -// disables testFixtures artifact publication -components.named("java") { - withVariantsFromConfiguration(configurations.testFixturesApiElements.get()) { skip() } - withVariantsFromConfiguration(configurations.testFixturesRuntimeElements.get()) { skip() } +dependencies { + commonTestImplementation(libs.kotlin.test) + commonTestImplementation(platform(libs.junit.bom)) } publishing.repositories { diff --git a/core/src/testFixtures/kotlin/bar/Bar.kt b/core/src/commonTest/kotlin/bar/Bar.kt similarity index 100% rename from core/src/testFixtures/kotlin/bar/Bar.kt rename to core/src/commonTest/kotlin/bar/Bar.kt diff --git a/core/src/testFixtures/kotlin/bar/impl/BarImpl.kt b/core/src/commonTest/kotlin/bar/impl/BarImpl.kt similarity index 100% rename from core/src/testFixtures/kotlin/bar/impl/BarImpl.kt rename to core/src/commonTest/kotlin/bar/impl/BarImpl.kt diff --git a/core/src/testFixtures/kotlin/baz/Baz.kt b/core/src/commonTest/kotlin/baz/Baz.kt similarity index 100% rename from core/src/testFixtures/kotlin/baz/Baz.kt rename to core/src/commonTest/kotlin/baz/Baz.kt diff --git a/core/src/testFixtures/kotlin/foo/Foo.kt b/core/src/commonTest/kotlin/foo/Foo.kt similarity index 100% rename from core/src/testFixtures/kotlin/foo/Foo.kt rename to core/src/commonTest/kotlin/foo/Foo.kt diff --git a/core/src/testFixtures/kotlin/foo/bar/FooBar.kt b/core/src/commonTest/kotlin/foo/bar/FooBar.kt similarity index 100% rename from core/src/testFixtures/kotlin/foo/bar/FooBar.kt rename to core/src/commonTest/kotlin/foo/bar/FooBar.kt diff --git a/core/src/testFixtures/kotlin/foo/bar/impl/FooBarImpl.kt b/core/src/commonTest/kotlin/foo/bar/impl/FooBarImpl.kt similarity index 100% rename from core/src/testFixtures/kotlin/foo/bar/impl/FooBarImpl.kt rename to core/src/commonTest/kotlin/foo/bar/impl/FooBarImpl.kt diff --git a/core/src/testFixtures/kotlin/foo/impl/FooImpl.kt b/core/src/commonTest/kotlin/foo/impl/FooImpl.kt similarity index 100% rename from core/src/testFixtures/kotlin/foo/impl/FooImpl.kt rename to core/src/commonTest/kotlin/foo/impl/FooImpl.kt diff --git a/core/src/testFixtures/resources/bar/.codeowners b/core/src/commonTest/resources/bar/.codeowners similarity index 100% rename from core/src/testFixtures/resources/bar/.codeowners rename to core/src/commonTest/resources/bar/.codeowners diff --git a/core/src/testFixtures/resources/bar/impl/BarImpl.codeowners b/core/src/commonTest/resources/bar/impl/BarImpl.codeowners similarity index 100% rename from core/src/testFixtures/resources/bar/impl/BarImpl.codeowners rename to core/src/commonTest/resources/bar/impl/BarImpl.codeowners diff --git a/core/src/testFixtures/resources/baz/Baz.codeowners b/core/src/commonTest/resources/baz/Baz.codeowners similarity index 100% rename from core/src/testFixtures/resources/baz/Baz.codeowners rename to core/src/commonTest/resources/baz/Baz.codeowners diff --git a/core/src/testFixtures/resources/foo/.codeowners b/core/src/commonTest/resources/foo/.codeowners similarity index 100% rename from core/src/testFixtures/resources/foo/.codeowners rename to core/src/commonTest/resources/foo/.codeowners diff --git a/core/src/testFixtures/resources/foo/bar/.codeowners b/core/src/commonTest/resources/foo/bar/.codeowners similarity index 100% rename from core/src/testFixtures/resources/foo/bar/.codeowners rename to core/src/commonTest/resources/foo/bar/.codeowners diff --git a/core/src/main/kotlin/io/github/gmazzo/codeowners/CodeOwners.kt b/core/src/jvmMain/kotlin/io/github/gmazzo/codeowners/CodeOwners.kt similarity index 100% rename from core/src/main/kotlin/io/github/gmazzo/codeowners/CodeOwners.kt rename to core/src/jvmMain/kotlin/io/github/gmazzo/codeowners/CodeOwners.kt diff --git a/core/src/test/kotlin/io/github/gmazzo/codeowners/CodeOwnersTest.kt b/core/src/jvmTest/kotlin/io/github/gmazzo/codeowners/CodeOwnersTest.kt similarity index 100% rename from core/src/test/kotlin/io/github/gmazzo/codeowners/CodeOwnersTest.kt rename to core/src/jvmTest/kotlin/io/github/gmazzo/codeowners/CodeOwnersTest.kt diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 1834611..2f1dbc1 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -10,6 +10,7 @@ kotlin-test = { module = "org.jetbrains.kotlin:kotlin-test", version.ref = "kotl android = "com.android.application:8.1.4" buildConfig = "com.github.gmazzo.buildconfig:4.2.0" kotlin-jvm = { id = "org.jetbrains.kotlin.jvm", version.ref = "kotlin" } +kotlin-multiplatform = { id = "org.jetbrains.kotlin.multiplatform", version.ref = "kotlin" } kotlin-samWithReceiver = { id = "org.jetbrains.kotlin.plugin.sam.with.receiver", version.ref = "kotlin" } dokka = { id = "org.jetbrains.dokka", version = "1.9.10" } gradle-pluginPublish = { id = "com.gradle.plugin-publish", version = "1.2.1" } diff --git a/plugin/build.gradle.kts b/plugin/build.gradle.kts index 67db0ae..f421a81 100644 --- a/plugin/build.gradle.kts +++ b/plugin/build.gradle.kts @@ -64,7 +64,7 @@ gradlePlugin { buildConfig { useKotlinOutput { internalVisibility = true } buildConfigField("String", "CORE_DEPENDENCY", projects.core.dependencyProject - .publishing.publications.named("java").map { + .publishing.publications.named("kotlinMultiplatform").map { "\"${it.groupId}:${it.artifactId}:${it.version}\"" } ) diff --git a/settings.gradle.kts b/settings.gradle.kts index 4e9cf99..57ff9c0 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -1,7 +1,7 @@ enableFeaturePreview("TYPESAFE_PROJECT_ACCESSORS") dependencyResolutionManagement { - repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS) + repositoriesMode = RepositoriesMode.PREFER_PROJECT repositories { mavenCentral() google()