diff --git a/build.gradle.kts b/build.gradle.kts index 561fe583..164d525d 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -16,6 +16,7 @@ */ +import com.charleskorn.kaml.build.Versions import com.charleskorn.kaml.build.configureAssemble import com.charleskorn.kaml.build.configureJacoco import com.charleskorn.kaml.build.configurePublishing @@ -23,26 +24,19 @@ import com.charleskorn.kaml.build.configureSpotless import com.charleskorn.kaml.build.configureTesting import com.charleskorn.kaml.build.configureVersioning import com.charleskorn.kaml.build.configureWrapper -import org.jetbrains.kotlin.gradle.tasks.KotlinCompile buildscript { repositories { jcenter() } - - dependencies { - classpath(kotlin("serialization", version = "1.4.10")) - } } plugins { - kotlin("jvm") version "1.4.10" - - apply { id("com.github.ben-manes.versions") version "0.36.0" } + kotlin("multiplatform") version "1.4.10" + kotlin("plugin.serialization") version "1.4.10" + id("com.github.ben-manes.versions") version "0.36.0" } -apply(plugin = "kotlinx-serialization") - group = "com.charleskorn.kaml" repositories { @@ -51,28 +45,48 @@ repositories { maven(url = "https://kotlin.bintray.com/kotlinx") } -dependencies { - implementation(platform("org.jetbrains.kotlin:kotlin-bom")) - - implementation(kotlin("stdlib-jdk8")) - implementation(group = "org.snakeyaml", name = "snakeyaml-engine", version = "2.2.1") - implementation(group = "org.jetbrains.kotlinx", name = "kotlinx-serialization-core", version = "1.0.1") - - val spekVersion = "2.0.15" - - testImplementation(group = "org.spekframework.spek2", name = "spek-dsl-jvm", version = spekVersion) - testImplementation(group = "ch.tutteli.atrium", name = "atrium-fluent-en_GB", version = "0.15.0") - - testRuntimeOnly(group = "org.spekframework.spek2", name = "spek-runner-junit5", version = spekVersion) -} - -tasks.withType { - kotlinOptions.jvmTarget = "1.8" - kotlinOptions.freeCompilerArgs = listOf("-Xuse-experimental=kotlin.RequiresOptIn") -} - kotlin { explicitApi() + + jvm { + withJava() + compilations.all { + kotlinOptions { + jvmTarget = "1.8" + } + } + } + + sourceSets { + all { + languageSettings.useExperimentalAnnotation("kotlin.RequiresOptIn") + } + val commonMain by getting { + dependencies { + implementation("org.jetbrains.kotlinx:kotlinx-serialization-core:${Versions.serialization}") + } + } + val commonTest by getting { + dependencies { + implementation("org.spekframework.spek2:spek-dsl-metadata:${Versions.spek}") + implementation("ch.tutteli.atrium:atrium-fluent-en_GB-common:${Versions.atrium}") + } + } + val jvmMain by getting { + dependencies { + implementation(project.dependencies.platform("org.jetbrains.kotlin:kotlin-bom")) + implementation(kotlin("stdlib-jdk8")) + implementation("org.snakeyaml:snakeyaml-engine:${Versions.snakeYaml}") + } + } + val jvmTest by getting { + dependencies { + implementation("org.spekframework.spek2:spek-dsl-jvm:${Versions.spek}") + implementation("ch.tutteli.atrium:atrium-fluent-en_GB:${Versions.atrium}") + runtimeOnly("org.spekframework.spek2:spek-runner-junit5:${Versions.spek}") + } + } + } } configureAssemble() diff --git a/buildSrc/src/main/kotlin/com/charleskorn/kaml/build/Versions.kt b/buildSrc/src/main/kotlin/com/charleskorn/kaml/build/Versions.kt new file mode 100644 index 00000000..75a79c91 --- /dev/null +++ b/buildSrc/src/main/kotlin/com/charleskorn/kaml/build/Versions.kt @@ -0,0 +1,26 @@ +/* + + Copyright 2018-2020 Charles Korn. + + 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. + +*/ + +package com.charleskorn.kaml.build + +object Versions { + const val atrium = "0.15.0" + const val serialization = "1.0.1" + const val snakeYaml = "2.2.1" + const val spek = "2.0.15" +} diff --git a/src/main/kotlin/com/charleskorn/kaml/Location.kt b/src/commonMain/kotlin/com/charleskorn/kaml/Location.kt similarity index 100% rename from src/main/kotlin/com/charleskorn/kaml/Location.kt rename to src/commonMain/kotlin/com/charleskorn/kaml/Location.kt diff --git a/src/main/kotlin/com/charleskorn/kaml/YamlException.kt b/src/commonMain/kotlin/com/charleskorn/kaml/YamlException.kt similarity index 100% rename from src/main/kotlin/com/charleskorn/kaml/YamlException.kt rename to src/commonMain/kotlin/com/charleskorn/kaml/YamlException.kt diff --git a/src/main/kotlin/com/charleskorn/kaml/YamlNode.kt b/src/commonMain/kotlin/com/charleskorn/kaml/YamlNode.kt similarity index 100% rename from src/main/kotlin/com/charleskorn/kaml/YamlNode.kt rename to src/commonMain/kotlin/com/charleskorn/kaml/YamlNode.kt diff --git a/src/main/kotlin/com/charleskorn/kaml/YamlPath.kt b/src/commonMain/kotlin/com/charleskorn/kaml/YamlPath.kt similarity index 100% rename from src/main/kotlin/com/charleskorn/kaml/YamlPath.kt rename to src/commonMain/kotlin/com/charleskorn/kaml/YamlPath.kt diff --git a/src/test/kotlin/com/charleskorn/kaml/Assertions.kt b/src/commonTest/kotlin/com/charleskorn/kaml/Assertions.kt similarity index 99% rename from src/test/kotlin/com/charleskorn/kaml/Assertions.kt rename to src/commonTest/kotlin/com/charleskorn/kaml/Assertions.kt index bd4eace6..2eecbced 100644 --- a/src/test/kotlin/com/charleskorn/kaml/Assertions.kt +++ b/src/commonTest/kotlin/com/charleskorn/kaml/Assertions.kt @@ -20,6 +20,7 @@ package com.charleskorn.kaml import ch.tutteli.atrium.api.fluent.en_GB.feature import ch.tutteli.atrium.creating.Expect +import kotlin.jvm.JvmName fun Expect.path(assertionCreator: Expect.() -> Unit) { feature(YamlException::path).addAssertionsCreatedBy(assertionCreator) diff --git a/src/test/kotlin/com/charleskorn/kaml/YamlExceptionTest.kt b/src/commonTest/kotlin/com/charleskorn/kaml/YamlExceptionTest.kt similarity index 100% rename from src/test/kotlin/com/charleskorn/kaml/YamlExceptionTest.kt rename to src/commonTest/kotlin/com/charleskorn/kaml/YamlExceptionTest.kt diff --git a/src/test/kotlin/com/charleskorn/kaml/YamlListTest.kt b/src/commonTest/kotlin/com/charleskorn/kaml/YamlListTest.kt similarity index 100% rename from src/test/kotlin/com/charleskorn/kaml/YamlListTest.kt rename to src/commonTest/kotlin/com/charleskorn/kaml/YamlListTest.kt diff --git a/src/test/kotlin/com/charleskorn/kaml/YamlMapTest.kt b/src/commonTest/kotlin/com/charleskorn/kaml/YamlMapTest.kt similarity index 100% rename from src/test/kotlin/com/charleskorn/kaml/YamlMapTest.kt rename to src/commonTest/kotlin/com/charleskorn/kaml/YamlMapTest.kt diff --git a/src/test/kotlin/com/charleskorn/kaml/YamlNullTest.kt b/src/commonTest/kotlin/com/charleskorn/kaml/YamlNullTest.kt similarity index 100% rename from src/test/kotlin/com/charleskorn/kaml/YamlNullTest.kt rename to src/commonTest/kotlin/com/charleskorn/kaml/YamlNullTest.kt diff --git a/src/test/kotlin/com/charleskorn/kaml/YamlPathTest.kt b/src/commonTest/kotlin/com/charleskorn/kaml/YamlPathTest.kt similarity index 100% rename from src/test/kotlin/com/charleskorn/kaml/YamlPathTest.kt rename to src/commonTest/kotlin/com/charleskorn/kaml/YamlPathTest.kt diff --git a/src/test/kotlin/com/charleskorn/kaml/YamlScalarTest.kt b/src/commonTest/kotlin/com/charleskorn/kaml/YamlScalarTest.kt similarity index 100% rename from src/test/kotlin/com/charleskorn/kaml/YamlScalarTest.kt rename to src/commonTest/kotlin/com/charleskorn/kaml/YamlScalarTest.kt diff --git a/src/test/kotlin/com/charleskorn/kaml/YamlTaggedNodeTest.kt b/src/commonTest/kotlin/com/charleskorn/kaml/YamlTaggedNodeTest.kt similarity index 100% rename from src/test/kotlin/com/charleskorn/kaml/YamlTaggedNodeTest.kt rename to src/commonTest/kotlin/com/charleskorn/kaml/YamlTaggedNodeTest.kt diff --git a/src/test/kotlin/com/charleskorn/kaml/testobjects/PolymorphicTestObjects.kt b/src/commonTest/kotlin/com/charleskorn/kaml/testobjects/PolymorphicTestObjects.kt similarity index 100% rename from src/test/kotlin/com/charleskorn/kaml/testobjects/PolymorphicTestObjects.kt rename to src/commonTest/kotlin/com/charleskorn/kaml/testobjects/PolymorphicTestObjects.kt diff --git a/src/test/kotlin/com/charleskorn/kaml/testobjects/TestObjects.kt b/src/commonTest/kotlin/com/charleskorn/kaml/testobjects/TestObjects.kt similarity index 100% rename from src/test/kotlin/com/charleskorn/kaml/testobjects/TestObjects.kt rename to src/commonTest/kotlin/com/charleskorn/kaml/testobjects/TestObjects.kt diff --git a/src/main/kotlin/com/charleskorn/kaml/Yaml.kt b/src/jvmMain/kotlin/com/charleskorn/kaml/Yaml.kt similarity index 100% rename from src/main/kotlin/com/charleskorn/kaml/Yaml.kt rename to src/jvmMain/kotlin/com/charleskorn/kaml/Yaml.kt diff --git a/src/main/kotlin/com/charleskorn/kaml/YamlConfiguration.kt b/src/jvmMain/kotlin/com/charleskorn/kaml/YamlConfiguration.kt similarity index 100% rename from src/main/kotlin/com/charleskorn/kaml/YamlConfiguration.kt rename to src/jvmMain/kotlin/com/charleskorn/kaml/YamlConfiguration.kt diff --git a/src/main/kotlin/com/charleskorn/kaml/YamlInput.kt b/src/jvmMain/kotlin/com/charleskorn/kaml/YamlInput.kt similarity index 100% rename from src/main/kotlin/com/charleskorn/kaml/YamlInput.kt rename to src/jvmMain/kotlin/com/charleskorn/kaml/YamlInput.kt diff --git a/src/main/kotlin/com/charleskorn/kaml/YamlNodeReader.kt b/src/jvmMain/kotlin/com/charleskorn/kaml/YamlNodeReader.kt similarity index 100% rename from src/main/kotlin/com/charleskorn/kaml/YamlNodeReader.kt rename to src/jvmMain/kotlin/com/charleskorn/kaml/YamlNodeReader.kt diff --git a/src/main/kotlin/com/charleskorn/kaml/YamlOutput.kt b/src/jvmMain/kotlin/com/charleskorn/kaml/YamlOutput.kt similarity index 100% rename from src/main/kotlin/com/charleskorn/kaml/YamlOutput.kt rename to src/jvmMain/kotlin/com/charleskorn/kaml/YamlOutput.kt diff --git a/src/main/kotlin/com/charleskorn/kaml/YamlParser.kt b/src/jvmMain/kotlin/com/charleskorn/kaml/YamlParser.kt similarity index 100% rename from src/main/kotlin/com/charleskorn/kaml/YamlParser.kt rename to src/jvmMain/kotlin/com/charleskorn/kaml/YamlParser.kt diff --git a/src/test/kotlin/com/charleskorn/kaml/YamlNodeReaderTest.kt b/src/jvmTest/kotlin/com/charleskorn/kaml/YamlNodeReaderTest.kt similarity index 100% rename from src/test/kotlin/com/charleskorn/kaml/YamlNodeReaderTest.kt rename to src/jvmTest/kotlin/com/charleskorn/kaml/YamlNodeReaderTest.kt diff --git a/src/test/kotlin/com/charleskorn/kaml/YamlReadingTest.kt b/src/jvmTest/kotlin/com/charleskorn/kaml/YamlReadingTest.kt similarity index 100% rename from src/test/kotlin/com/charleskorn/kaml/YamlReadingTest.kt rename to src/jvmTest/kotlin/com/charleskorn/kaml/YamlReadingTest.kt diff --git a/src/test/kotlin/com/charleskorn/kaml/YamlWritingTest.kt b/src/jvmTest/kotlin/com/charleskorn/kaml/YamlWritingTest.kt similarity index 100% rename from src/test/kotlin/com/charleskorn/kaml/YamlWritingTest.kt rename to src/jvmTest/kotlin/com/charleskorn/kaml/YamlWritingTest.kt