Fix unresolved library with 'java-api' and 'java-runtime' usages
This commit is contained in:
+44
@@ -180,6 +180,50 @@ class VariantAwareDependenciesIT : BaseGradleIT() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun testResolvesOldKotlinArtifactsPublishedWithMetadata() = with(Project("multiplatformProject", gradleVersion)) {
|
||||||
|
setupWorkingDir()
|
||||||
|
projectDir.resolve("settings.gradle").appendText("\nenableFeaturePreview 'GRADLE_METADATA'")
|
||||||
|
gradleBuildScript().appendText(
|
||||||
|
"\n" + """
|
||||||
|
configure([project(':lib'), project(':libJvm'), project(':libJs')]) {
|
||||||
|
group 'com.example.oldmpp'
|
||||||
|
version '1.0'
|
||||||
|
apply plugin: 'maven-publish'
|
||||||
|
publishing {
|
||||||
|
repositories { maven { url "file://${'$'}{rootDir.absolutePath.replace('\\', '/')}/repo" } }
|
||||||
|
publications { kotlin(MavenPublication) { from(components.java) } }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
""".trimIndent()
|
||||||
|
)
|
||||||
|
build("publish") { assertSuccessful() }
|
||||||
|
|
||||||
|
gradleBuildScript().modify {
|
||||||
|
it.replace("'com.example.oldmpp'", "'com.example.consumer'") +
|
||||||
|
"\nsubprojects { repositories { maven { url \"file://${'$'}{rootDir.absolutePath.replace('\\\\', '/')}/repo\" } } }"
|
||||||
|
}
|
||||||
|
|
||||||
|
gradleBuildScript("lib").appendText("\ndependencies { compile 'com.example.oldmpp:lib:1.0' }")
|
||||||
|
testResolveAllConfigurations("lib")
|
||||||
|
|
||||||
|
gradleBuildScript("libJvm").appendText("\ndependencies { compile 'com.example.oldmpp:libJvm:1.0' }")
|
||||||
|
testResolveAllConfigurations("libJvm")
|
||||||
|
|
||||||
|
gradleBuildScript("libJs").appendText("\ndependencies { compile 'com.example.oldmpp:libJs:1.0' }")
|
||||||
|
testResolveAllConfigurations("libJs")
|
||||||
|
|
||||||
|
embedProject(Project("sample-lib", directoryPrefix = "new-mpp-lib-and-app"))
|
||||||
|
gradleBuildScript("sample-lib").appendText("\n" + """
|
||||||
|
dependencies {
|
||||||
|
commonMainApi 'com.example.oldmpp:lib:1.0'
|
||||||
|
jvm6MainApi 'com.example.oldmpp:libJvm:1.0'
|
||||||
|
nodeJsMainApi 'com.example.oldmpp:libJs:1.0'
|
||||||
|
}
|
||||||
|
""".trimIndent())
|
||||||
|
testResolveAllConfigurations("sample-lib")
|
||||||
|
}
|
||||||
|
|
||||||
private fun Project.embedProject(other: Project) {
|
private fun Project.embedProject(other: Project) {
|
||||||
setupWorkingDir()
|
setupWorkingDir()
|
||||||
other.setupWorkingDir()
|
other.setupWorkingDir()
|
||||||
|
|||||||
+5
-1
@@ -55,7 +55,8 @@ object KotlinUsages {
|
|||||||
override fun execute(details: CompatibilityCheckDetails<Usage>) = with(details) {
|
override fun execute(details: CompatibilityCheckDetails<Usage>) = with(details) {
|
||||||
when {
|
when {
|
||||||
consumerValue?.name == KOTLIN_API && producerValue?.name == JAVA_API -> compatible()
|
consumerValue?.name == KOTLIN_API && producerValue?.name == JAVA_API -> compatible()
|
||||||
consumerValue?.name in values && producerValue?.name == JAVA_RUNTIME_JARS -> compatible()
|
consumerValue?.name in values &&
|
||||||
|
producerValue?.name.let { it == JAVA_RUNTIME || it == JAVA_RUNTIME_JARS } -> compatible()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -72,6 +73,9 @@ object KotlinUsages {
|
|||||||
if (JAVA_API in candidateNames && JAVA_RUNTIME_JARS in candidateNames && values.none { it in candidateNames }) {
|
if (JAVA_API in candidateNames && JAVA_RUNTIME_JARS in candidateNames && values.none { it in candidateNames }) {
|
||||||
details.closestMatch(candidateValues.single { it?.name == JAVA_API }!!)
|
details.closestMatch(candidateValues.single { it?.name == JAVA_API }!!)
|
||||||
}
|
}
|
||||||
|
if (JAVA_API in candidateNames && JAVA_RUNTIME in candidateNames && values.none { it in candidateNames }) {
|
||||||
|
details.closestMatch(candidateValues.single { it?.name == JAVA_API }!!)
|
||||||
|
}
|
||||||
if (JAVA_RUNTIME_CLASSES in candidateNames && JAVA_RUNTIME_RESOURCES in candidateNames && KOTLIN_RUNTIME in candidateNames) {
|
if (JAVA_RUNTIME_CLASSES in candidateNames && JAVA_RUNTIME_RESOURCES in candidateNames && KOTLIN_RUNTIME in candidateNames) {
|
||||||
closestMatch(candidateValues.single { it?.name == KOTLIN_RUNTIME }!!)
|
closestMatch(candidateValues.single { it?.name == KOTLIN_RUNTIME }!!)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user