-
Notifications
You must be signed in to change notification settings - Fork 51
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft: Introduce basic Kotlin MPP project layout #77
Changes from 5 commits
fff656b
5bd60c6
8da5e07
4fa1c21
1673f81
35f28f7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,33 +16,27 @@ | |
|
||
*/ | ||
|
||
import com.charleskorn.kaml.build.Versions | ||
import com.charleskorn.kaml.build.configureAssemble | ||
import com.charleskorn.kaml.build.configureJacoco | ||
import com.charleskorn.kaml.build.configurePublishing | ||
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" | ||
id("org.jetbrains.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,49 @@ 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<KotlinCompile> { | ||
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")) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should this be applied to There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I really don't know what's |
||
implementation(kotlin("stdlib-jdk8")) | ||
implementation("org.snakeyaml:snakeyaml-engine:${Versions.snakeYaml}") | ||
implementation("org.jetbrains.kotlinx:kotlinx-serialization-core:${Versions.serialization}") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Does this need to be applied again if it's already in There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Another good catch. It does not. |
||
} | ||
} | ||
val jvmTest by getting { | ||
dependencies { | ||
implementation("org.spekframework.spek2:spek-dsl-jvm:${Versions.spek}") | ||
implementation("ch.tutteli.atrium:atrium-fluent-en_GB:${Versions.atrium}") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same thing again - does this need to be here if it's also in There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is quite the opposite. |
||
runtimeOnly("org.spekframework.spek2:spek-runner-junit5:${Versions.spek}") | ||
} | ||
} | ||
} | ||
} | ||
|
||
configureAssemble() | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Does Renovate support updating versions when configured like this? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't know about Renovate (never heard of it) but you apply the |
||
const val atrium = "0.15.0" | ||
const val serialization = "1.0.1" | ||
const val snakeYaml = "2.2.1" | ||
const val spek = "2.0.15" | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know I wasn't using it before, but it might be good to switch to the
kotlin("plugin.serialization")
method here as well, as described in the kotlinx.serialization readme.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch. Of course it should.