Fix bom dependencies again; Fix #1975

This commit is contained in:
Karlatemp 2022-05-05 22:44:48 +08:00
parent e3b372e643
commit 78d0cdd155
No known key found for this signature in database
GPG Key ID: C6B606FF23D8FED7
2 changed files with 30 additions and 4 deletions

View File

@ -204,6 +204,30 @@ class TestBuildPlugin : AbstractTest() {
}
}
@Test
fun `can build with bom dependencies 2`() {
tempDir.resolve("build.gradle").appendText(
"""
dependencies {
implementation "com.fasterxml.jackson.core:jackson-annotations:2.12.4"
}
""".trimIndent()
)
gradleRunner()
.withArguments("buildPlugin", "dependencies", "--stacktrace", "--info")
.build()
ZipFile(findJar()).use { zipFile ->
val dpPrivate = zipFile.getInputStream(
zipFile.getEntry("META-INF/mirai-console-plugin/dependencies-private.txt")
).use { it.readBytes().decodeToString() }
assertFalse { dpPrivate.contains("com.fasterxml.jackson:jackson-bom") }
assertTrue { dpPrivate.contains("com.fasterxml.jackson.core:jackson-annotations") }
}
}
private fun findJar(): File = tempDir.resolve("build/mirai").listFiles()!!.first { it.name.endsWith(".mirai2.jar") }
private fun checkOutput() {

View File

@ -140,7 +140,12 @@ public open class BuildMiraiPluginV2 : Jar() {
}
fun linkDependencyTo(resolvedDependency: ResolvedDependency, dependencies: MutableCollection<String>) {
dependencies.add(resolvedDependency.module.toString())
// bom files
if (resolvedDependency.allModuleArtifacts.any { it.extension == "jar" }) {
dependencies.add(resolvedDependency.module.toString())
}
resolvedDependency.children.forEach { linkDependencyTo(it, dependencies) }
}
@ -150,9 +155,6 @@ public open class BuildMiraiPluginV2 : Jar() {
if (depId in linkedDependencies) {
markAsResolved(resolvedDependency)
// bom files
if (resolvedDependency.allModuleArtifacts.none { it.extension == "jar" }) return
linkDependencyTo(resolvedDependency, runtime)
if (depId in linkToApi) {
linkDependencyTo(resolvedDependency, api)