Add new-mpp-lib-with-tests Kotlin DSL build script and test
This commit is contained in:
+12
-1
@@ -301,7 +301,18 @@ class NewMultiplatformIT : BaseGradleIT() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@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") {
|
build("check") {
|
||||||
assertSuccessful()
|
assertSuccessful()
|
||||||
assertTasksExecuted(
|
assertTasksExecuted(
|
||||||
|
|||||||
+4
-3
@@ -83,14 +83,15 @@ internal fun BaseGradleIT.transformProjectWithPluginsDsl(
|
|||||||
result.projectDir.walkTopDown()
|
result.projectDir.walkTopDown()
|
||||||
.filter { it.isFile && (it.name == "build.gradle" || it.name == "build.gradle.kts") }
|
.filter { it.isFile && (it.name == "build.gradle" || it.name == "build.gradle.kts") }
|
||||||
.forEach { buildGradle ->
|
.forEach { buildGradle ->
|
||||||
buildGradle.modify { text ->
|
buildGradle.modify(::transformBuildScriptWithPluginsDsl)
|
||||||
text.replace(PLUGIN_MARKER_VERSION_PLACEHOLDER, KOTLIN_VERSION)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return result
|
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())
|
/** 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 {
|
private object MavenLocalUrlProvider {
|
||||||
|
|||||||
+54
@@ -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)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
+7
@@ -1 +1,8 @@
|
|||||||
|
pluginManagement {
|
||||||
|
repositories {
|
||||||
|
mavenLocal()
|
||||||
|
gradlePluginPortal()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
enableFeaturePreview('GRADLE_METADATA')
|
enableFeaturePreview('GRADLE_METADATA')
|
||||||
Reference in New Issue
Block a user