Add new-mpp-lib-with-tests Kotlin DSL build script and test

This commit is contained in:
Sergey Igushkin
2018-11-26 16:13:47 +03:00
parent 202c86aafe
commit a0399d0541
4 changed files with 77 additions and 4 deletions
@@ -301,7 +301,18 @@ class NewMultiplatformIT : BaseGradleIT() {
}
@Test
fun testLibWithTests() = with(Project("new-mpp-lib-with-tests", gradleVersion)) {
fun testLibWithTests() = doTestLibWithTests(Project("new-mpp-lib-with-tests", gradleVersion))
@Test
fun testLibWithTestsKotlinDsl() = with(Project("new-mpp-lib-with-tests", gradleVersion)) {
setupWorkingDir()
gradleBuildScript().delete()
projectDir.resolve("build.gradle.kts.alternative").renameTo(projectDir.resolve("build.gradle.kts"))
gradleBuildScript().modify(::transformBuildScriptWithPluginsDsl)
doTestLibWithTests(this)
}
private fun doTestLibWithTests(project: Project) = with(project) {
build("check") {
assertSuccessful()
assertTasksExecuted(
@@ -83,14 +83,15 @@ internal fun BaseGradleIT.transformProjectWithPluginsDsl(
result.projectDir.walkTopDown()
.filter { it.isFile && (it.name == "build.gradle" || it.name == "build.gradle.kts") }
.forEach { buildGradle ->
buildGradle.modify { text ->
text.replace(PLUGIN_MARKER_VERSION_PLACEHOLDER, KOTLIN_VERSION)
}
buildGradle.modify(::transformBuildScriptWithPluginsDsl)
}
return result
}
internal fun transformBuildScriptWithPluginsDsl(buildScriptContent: String): String =
buildScriptContent.replace(PLUGIN_MARKER_VERSION_PLACEHOLDER, KOTLIN_VERSION)
/** Copies the logic of Gradle [`mavenLocal()`](https://docs.gradle.org/3.4.1/dsl/org.gradle.api.artifacts.dsl.RepositoryHandler.html#org.gradle.api.artifacts.dsl.RepositoryHandler:mavenLocal())
*/
private object MavenLocalUrlProvider {
@@ -0,0 +1,54 @@
plugins {
id("org.jetbrains.kotlin.multiplatform").version("<pluginMarkerVersion>")
}
repositories {
mavenLocal()
jcenter()
maven { setUrl("http://dl.bintray.com/kotlin/kotlinx.html/") }
}
kotlin {
val jvmWithoutJava = jvm("jvmWithoutJava")
val jvmWithJava = targetFromPreset(presets["jvmWithJava"])
val js = js()
val macos64 = macosX64("macos64")
val linux64 = linuxX64("linux64")
val mingw64 = mingwX64("mingw64")
sourceSets {
val commonTest by getting {
dependencies {
implementation(kotlin("test-common"))
implementation(kotlin("test-annotations-common"))
}
}
val main by getting
val jvmWithoutJavaMain = jvmWithoutJava.compilations["main"].defaultSourceSet
configure(listOf(main, jvmWithoutJavaMain)) {
dependencies {
implementation(kotlin("stdlib"))
}
}
val test by getting
val jvmWithoutJavaTest = jvmWithoutJava.compilations["test"].defaultSourceSet
configure(listOf(test, jvmWithoutJavaTest)) {
dependencies {
implementation(kotlin("test-junit"))
}
}
js.compilations["test"].defaultSourceSet {
dependencies {
implementation(kotlin("test-js"))
}
}
val nativeMain by creating
configure(listOf(macos64, linux64, mingw64)) {
compilations["main"].defaultSourceSet.dependsOn(nativeMain)
}
}
}
@@ -1 +1,8 @@
pluginManagement {
repositories {
mavenLocal()
gradlePluginPortal()
}
}
enableFeaturePreview('GRADLE_METADATA')