[Gradle, JS] KT-36784 Composite build test
#KT-32466 fixed #KT-36784 fixed #KT-36864 fixed
This commit is contained in:
+11
-8
@@ -215,7 +215,12 @@ abstract class BaseGradleIT {
|
||||
val jsCompilerType: KotlinJsCompilerType? = null
|
||||
)
|
||||
|
||||
data class KaptOptions(val verbose: Boolean, val useWorkers: Boolean, val incrementalKapt: Boolean = false, val includeCompileClasspath: Boolean = true)
|
||||
data class KaptOptions(
|
||||
val verbose: Boolean,
|
||||
val useWorkers: Boolean,
|
||||
val incrementalKapt: Boolean = false,
|
||||
val includeCompileClasspath: Boolean = true
|
||||
)
|
||||
|
||||
open inner class Project(
|
||||
val projectName: String,
|
||||
@@ -630,13 +635,11 @@ Finished executing task ':$taskName'|
|
||||
}
|
||||
|
||||
fun Project.gradleProperties(): File =
|
||||
listOf("gradle.properties").map {
|
||||
File(projectDir, it).also { file ->
|
||||
if (!file.exists()) {
|
||||
file.createNewFile()
|
||||
}
|
||||
File(projectDir, "gradle.properties").also { file ->
|
||||
if (!file.exists()) {
|
||||
file.createNewFile()
|
||||
}
|
||||
}.single()
|
||||
}
|
||||
|
||||
/**
|
||||
* @param assertionFileName path to xml with expected test results, relative to test resources root
|
||||
@@ -709,7 +712,7 @@ Finished executing task ':$taskName'|
|
||||
}
|
||||
|
||||
private fun prettyPrintXml(uglyXml: String): String =
|
||||
XMLOutputter(Format.getPrettyFormat()).outputString(SAXBuilder().build(uglyXml.reader()))
|
||||
XMLOutputter(Format.getPrettyFormat()).outputString(SAXBuilder().build(uglyXml.reader()))
|
||||
|
||||
private fun Project.createGradleTailParameters(options: BuildOptions, params: Array<out String> = arrayOf()): List<String> =
|
||||
params.toMutableList().apply {
|
||||
|
||||
+29
@@ -548,6 +548,35 @@ abstract class AbstractKotlin2JsGradlePluginIT(private val irBackend: Boolean) :
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testJsCompositeBuild() {
|
||||
val rootProjectName = "js-composite-build"
|
||||
val appProject = transformProjectWithPluginsDsl(
|
||||
projectName = "app",
|
||||
directoryPrefix = rootProjectName,
|
||||
wrapperVersion = GradleVersionRequired.AtLeast("5.3")
|
||||
)
|
||||
|
||||
val libProject = transformProjectWithPluginsDsl(
|
||||
projectName = "lib",
|
||||
directoryPrefix = rootProjectName,
|
||||
wrapperVersion = GradleVersionRequired.AtLeast("5.3")
|
||||
)
|
||||
|
||||
if (irBackend) {
|
||||
libProject.gradleProperties().appendText(jsCompilerType(KotlinJsCompilerType.IR))
|
||||
appProject.gradleProperties().appendText(jsCompilerType(KotlinJsCompilerType.IR))
|
||||
}
|
||||
|
||||
libProject.projectDir.copyRecursively(appProject.projectDir.resolve(libProject.projectDir.name))
|
||||
|
||||
with(appProject) {
|
||||
build("build") {
|
||||
assertSuccessful()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testBrowserDistribution() = with(Project("kotlin-js-browser-project", GradleVersionRequired.AtLeast("4.10.2"))) {
|
||||
setupWorkingDir()
|
||||
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
plugins {
|
||||
kotlin("js") version "<pluginMarkerVersion>"
|
||||
}
|
||||
|
||||
repositories {
|
||||
jcenter()
|
||||
mavenLocal()
|
||||
mavenCentral()
|
||||
}
|
||||
|
||||
kotlin.js {
|
||||
binaries.executable()
|
||||
nodejs()
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation(kotlin("stdlib-js"))
|
||||
implementation("com.example:lib2")
|
||||
}
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
pluginManagement {
|
||||
repositories {
|
||||
mavenLocal()
|
||||
gradlePluginPortal()
|
||||
}
|
||||
}
|
||||
|
||||
includeBuild("lib")
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
fun main() {
|
||||
println(Singleton.test())
|
||||
}
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
group = "com.example"
|
||||
|
||||
plugins {
|
||||
kotlin("js") version "<pluginMarkerVersion>"
|
||||
}
|
||||
|
||||
repositories {
|
||||
jcenter()
|
||||
mavenCentral()
|
||||
mavenLocal()
|
||||
}
|
||||
|
||||
kotlin.target.nodejs()
|
||||
|
||||
dependencies {
|
||||
implementation(kotlin("stdlib-js"))
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
rootProject.name = "lib2"
|
||||
|
||||
pluginManagement {
|
||||
repositories {
|
||||
gradlePluginPortal()
|
||||
|
||||
mavenLocal()
|
||||
|
||||
mavenCentral()
|
||||
}
|
||||
}
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
object Singleton {
|
||||
fun test(): String {
|
||||
return "42"
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user