mirror of
https://github.com/mamoe/mirai.git
synced 2025-01-31 19:40:24 +08:00
Fix bom dependencies again; Fix #1975
This commit is contained in:
parent
e3b372e643
commit
78d0cdd155
@ -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() {
|
||||
|
@ -140,7 +140,12 @@ public open class BuildMiraiPluginV2 : Jar() {
|
||||
}
|
||||
|
||||
fun linkDependencyTo(resolvedDependency: ResolvedDependency, dependencies: MutableCollection<String>) {
|
||||
|
||||
// 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)
|
||||
|
Loading…
Reference in New Issue
Block a user