[Gradle][MPP] Ensure there are no KLIBs discriminated by duplicated unique_name
^KT-63573
This commit is contained in:
committed by
Space Team
parent
5ffbaa1621
commit
48072c822b
+77
-1
@@ -39,20 +39,71 @@ class KlibResolverInsideCompilerIT : KGPBaseTest() {
|
||||
)
|
||||
}
|
||||
|
||||
@DisplayName("KLIBs with duplicated unique_name not discriminated, library + composite build, LV=1.9 (KT-63573)")
|
||||
@GradleTest
|
||||
fun testKlibsWithDuplicatedUniqueNameNotDiscriminated1(gradleVersion: GradleVersion, @TempDir tempDir: Path) {
|
||||
buildLibraryAndCompositeProjectForKT63573(
|
||||
baseDir = "mpp-klib-resolver-inside-compiler/klibs-with-duplicated-unique_name-library-and-composite-build",
|
||||
languageVersion = EnforcedLanguageVersion.K1,
|
||||
tempDir, gradleVersion
|
||||
)
|
||||
}
|
||||
|
||||
@DisplayName("KLIBs with duplicated unique_name not discriminated, library + composite build, LV=2.0 (KT-63573)")
|
||||
@GradleTest
|
||||
fun testKlibsWithDuplicatedUniqueNameNotDiscriminated2(gradleVersion: GradleVersion, @TempDir tempDir: Path) {
|
||||
buildLibraryAndCompositeProjectForKT63573(
|
||||
baseDir = "mpp-klib-resolver-inside-compiler/klibs-with-duplicated-unique_name-library-and-composite-build",
|
||||
languageVersion = EnforcedLanguageVersion.K2,
|
||||
tempDir, gradleVersion
|
||||
)
|
||||
}
|
||||
|
||||
@DisplayName("KLIBs with duplicated unique_name not discriminated, library x2 + app, LV=1.9 (KT-63573)")
|
||||
@GradleTest
|
||||
fun testKlibsWithDuplicatedUniqueNameNotDiscriminated3(gradleVersion: GradleVersion, @TempDir tempDir: Path) {
|
||||
buildTwoLibrariesAndAppForKT63573(
|
||||
baseDir = "mpp-klib-resolver-inside-compiler/klibs-with-duplicated-unique_name-library-x2-and-app",
|
||||
languageVersion = EnforcedLanguageVersion.K1,
|
||||
tempDir, gradleVersion
|
||||
)
|
||||
}
|
||||
|
||||
@DisplayName("KLIBs with duplicated unique_name not discriminated, library x2 + app, LV=2.0 (KT-63573)")
|
||||
@GradleTest
|
||||
fun testKlibsWithDuplicatedUniqueNameNotDiscriminated4(gradleVersion: GradleVersion, @TempDir tempDir: Path) {
|
||||
buildTwoLibrariesAndAppForKT63573(
|
||||
baseDir = "mpp-klib-resolver-inside-compiler/klibs-with-duplicated-unique_name-library-x2-and-app",
|
||||
languageVersion = EnforcedLanguageVersion.K2,
|
||||
tempDir, gradleVersion
|
||||
)
|
||||
}
|
||||
|
||||
private fun createLocalRepo(tempDir: Path): Path {
|
||||
val localRepo = tempDir.resolve("local-repo").toAbsolutePath()
|
||||
Files.createDirectories(localRepo)
|
||||
return localRepo
|
||||
}
|
||||
|
||||
private enum class EnforcedLanguageVersion { K1, K2 }
|
||||
|
||||
private fun buildProject(
|
||||
baseDir: String,
|
||||
projectName: String,
|
||||
gradleVersion: GradleVersion,
|
||||
localRepoDir: Path,
|
||||
languageVersion: EnforcedLanguageVersion? = null,
|
||||
buildTask: String = "build",
|
||||
) {
|
||||
project("$baseDir/$projectName", gradleVersion, localRepoDir = localRepoDir) {
|
||||
val buildOptions = with(defaultBuildOptions) {
|
||||
when (languageVersion) {
|
||||
EnforcedLanguageVersion.K1 -> copyEnsuringK1()
|
||||
EnforcedLanguageVersion.K2 -> copyEnsuringK2()
|
||||
else -> this
|
||||
}
|
||||
}
|
||||
|
||||
project("$baseDir/$projectName", gradleVersion, buildOptions, localRepoDir = localRepoDir) {
|
||||
build(buildTask)
|
||||
}
|
||||
}
|
||||
@@ -99,4 +150,29 @@ class KlibResolverInsideCompilerIT : KGPBaseTest() {
|
||||
|
||||
buildProject(baseDir, "app", gradleVersion, localRepoDir)
|
||||
}
|
||||
|
||||
private fun buildLibraryAndCompositeProjectForKT63573(
|
||||
baseDir: String,
|
||||
languageVersion: EnforcedLanguageVersion,
|
||||
tempDir: Path,
|
||||
gradleVersion: GradleVersion,
|
||||
) {
|
||||
val localRepoDir = createLocalRepo(tempDir)
|
||||
|
||||
buildAndPublishProject(baseDir, "external-library", gradleVersion, localRepoDir)
|
||||
buildProject(baseDir, "composite-project", gradleVersion, localRepoDir, languageVersion, ":app:build")
|
||||
}
|
||||
|
||||
private fun buildTwoLibrariesAndAppForKT63573(
|
||||
baseDir: String,
|
||||
languageVersion: EnforcedLanguageVersion,
|
||||
tempDir: Path,
|
||||
gradleVersion: GradleVersion,
|
||||
) {
|
||||
val localRepoDir = createLocalRepo(tempDir)
|
||||
|
||||
buildAndPublishProject(baseDir, "external-library1", gradleVersion, localRepoDir)
|
||||
buildAndPublishProject(baseDir, "external-library2", gradleVersion, localRepoDir)
|
||||
buildProject(baseDir, "app", gradleVersion, localRepoDir, languageVersion, "build")
|
||||
}
|
||||
}
|
||||
|
||||
+29
@@ -0,0 +1,29 @@
|
||||
plugins {
|
||||
id("org.jetbrains.kotlin.multiplatform")
|
||||
}
|
||||
|
||||
repositories {
|
||||
mavenLocal()
|
||||
mavenCentral()
|
||||
maven { url = uri("<localRepo>") }
|
||||
}
|
||||
|
||||
kotlin {
|
||||
jvm()
|
||||
js {
|
||||
nodejs()
|
||||
binaries.executable()
|
||||
}
|
||||
linuxX64 {
|
||||
binaries.executable()
|
||||
}
|
||||
|
||||
sourceSets {
|
||||
commonMain {
|
||||
dependencies {
|
||||
api("org.sample.kt62515.foo:libraryWithNonUniqueName:1.0")
|
||||
api(project(":libraryWithNonUniqueName"))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
fun main() {
|
||||
println("Hello from App!")
|
||||
org.sample.kt62515.foo.greet()
|
||||
org.sample.kt62515.bar.greet()
|
||||
}
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
plugins {
|
||||
id("org.jetbrains.kotlin.multiplatform")
|
||||
}
|
||||
|
||||
group = "org.sample.kt62515.bar"
|
||||
version = 1.0
|
||||
|
||||
repositories {
|
||||
mavenLocal()
|
||||
mavenCentral()
|
||||
}
|
||||
|
||||
kotlin {
|
||||
jvm()
|
||||
js {
|
||||
nodejs()
|
||||
}
|
||||
linuxX64()
|
||||
}
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
package org.sample.kt62515.bar
|
||||
|
||||
fun greet() {
|
||||
println("hello from org.sample.kt62515.bar:libraryWithNonUniqueName")
|
||||
}
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
rootProject.name = "composite-project"
|
||||
|
||||
include(":libraryWithNonUniqueName")
|
||||
include(":app")
|
||||
|
||||
+26
@@ -0,0 +1,26 @@
|
||||
plugins {
|
||||
id("org.jetbrains.kotlin.multiplatform")
|
||||
`maven-publish`
|
||||
}
|
||||
|
||||
group = "org.sample.kt62515.foo"
|
||||
version = 1.0
|
||||
|
||||
repositories {
|
||||
mavenLocal()
|
||||
mavenCentral()
|
||||
}
|
||||
|
||||
publishing {
|
||||
repositories {
|
||||
maven { url = uri("<localRepo>") }
|
||||
}
|
||||
}
|
||||
|
||||
kotlin {
|
||||
jvm()
|
||||
js {
|
||||
nodejs()
|
||||
}
|
||||
linuxX64()
|
||||
}
|
||||
+1
@@ -0,0 +1 @@
|
||||
rootProject.name = "libraryWithNonUniqueName"
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
package org.sample.kt62515.foo
|
||||
|
||||
fun greet() {
|
||||
println("hello from org.sample.kt62515.foo:libraryWithNonUniqueName")
|
||||
}
|
||||
+29
@@ -0,0 +1,29 @@
|
||||
plugins {
|
||||
id("org.jetbrains.kotlin.multiplatform")
|
||||
}
|
||||
|
||||
repositories {
|
||||
mavenLocal()
|
||||
mavenCentral()
|
||||
maven { url = uri("<localRepo>") }
|
||||
}
|
||||
|
||||
kotlin {
|
||||
jvm()
|
||||
js {
|
||||
nodejs()
|
||||
binaries.executable()
|
||||
}
|
||||
linuxX64 {
|
||||
binaries.executable()
|
||||
}
|
||||
|
||||
sourceSets {
|
||||
commonMain {
|
||||
dependencies {
|
||||
api("org.sample.kt62515.foo:libraryWithNonUniqueName:1.0")
|
||||
api("org.sample.kt62515.bar:libraryWithNonUniqueName:1.0")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+2
@@ -0,0 +1,2 @@
|
||||
rootProject.name = "app"
|
||||
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
fun main() {
|
||||
println("Hello from App!")
|
||||
org.sample.kt62515.foo.greet()
|
||||
org.sample.kt62515.bar.greet()
|
||||
}
|
||||
+26
@@ -0,0 +1,26 @@
|
||||
plugins {
|
||||
id("org.jetbrains.kotlin.multiplatform")
|
||||
`maven-publish`
|
||||
}
|
||||
|
||||
group = "org.sample.kt62515.foo"
|
||||
version = 1.0
|
||||
|
||||
repositories {
|
||||
mavenLocal()
|
||||
mavenCentral()
|
||||
}
|
||||
|
||||
publishing {
|
||||
repositories {
|
||||
maven { url = uri("<localRepo>") }
|
||||
}
|
||||
}
|
||||
|
||||
kotlin {
|
||||
jvm()
|
||||
js {
|
||||
nodejs()
|
||||
}
|
||||
linuxX64()
|
||||
}
|
||||
+1
@@ -0,0 +1 @@
|
||||
rootProject.name = "libraryWithNonUniqueName"
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
package org.sample.kt62515.foo
|
||||
|
||||
fun greet() {
|
||||
println("hello from org.sample.kt62515.foo:libraryWithNonUniqueName")
|
||||
}
|
||||
+26
@@ -0,0 +1,26 @@
|
||||
plugins {
|
||||
id("org.jetbrains.kotlin.multiplatform")
|
||||
`maven-publish`
|
||||
}
|
||||
|
||||
group = "org.sample.kt62515.bar"
|
||||
version = 1.0
|
||||
|
||||
repositories {
|
||||
mavenLocal()
|
||||
mavenCentral()
|
||||
}
|
||||
|
||||
publishing {
|
||||
repositories {
|
||||
maven { url = uri("<localRepo>") }
|
||||
}
|
||||
}
|
||||
|
||||
kotlin {
|
||||
jvm()
|
||||
js {
|
||||
nodejs()
|
||||
}
|
||||
linuxX64()
|
||||
}
|
||||
+1
@@ -0,0 +1 @@
|
||||
rootProject.name = "libraryWithNonUniqueName"
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
package org.sample.kt62515.bar
|
||||
|
||||
fun greet() {
|
||||
println("hello from org.sample.kt62515.bar:libraryWithNonUniqueName")
|
||||
}
|
||||
Reference in New Issue
Block a user