1
0
mirror of https://github.com/mamoe/mirai.git synced 2025-03-26 07:20:09 +08:00

Skip if dependencies have no jars; fix

This commit is contained in:
Karlatemp 2022-04-22 23:55:06 +08:00
parent 7f3b67ad9e
commit e6e8f77f41
No known key found for this signature in database
GPG Key ID: C6B606FF23D8FED7
2 changed files with 28 additions and 1 deletions
mirai-console/tools/gradle-plugin/src
integTest/kotlin
main/kotlin

View File

@ -7,7 +7,7 @@
* https://github.com/mamoe/mirai/blob/dev/LICENSE
*/
@file:Suppress("DuplicatedCode")
@file:Suppress("DuplicatedCode", "FunctionName")
package net.mamoe.mirai.console.gradle
@ -181,6 +181,29 @@ class TestBuildPlugin : AbstractTest() {
checkOutput()
}
@Test
fun `can build with bom dependencies`() {
tempDir.resolve("build.gradle").appendText(
"""
dependencies {
implementation platform("com.fasterxml.jackson:jackson-bom: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") }
}
}
private fun findJar(): File = tempDir.resolve("build/libs").listFiles()!!.first { it.name.endsWith(".mirai.jar") }
private fun checkOutput() {

View File

@ -146,6 +146,10 @@ public open class BuildMiraiPluginV2 : Jar() {
logger.info { "resolving : $depId" }
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)