mirror of
https://github.com/mamoe/mirai.git
synced 2025-03-03 15:10:14 +08:00
Fix private dependencies resolving; fix #2108
This commit is contained in:
parent
f69fdb7ac1
commit
1110a6f3fa
@ -0,0 +1 @@
|
||||
net.mamoe.consoleit.issue2108:private-module:1.0.0
|
@ -0,0 +1,13 @@
|
||||
/*
|
||||
* Copyright 2019-2022 Mamoe Technologies and contributors.
|
||||
*
|
||||
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
|
||||
* Use of this source code is governed by the GNU AGPLv3 license that can be found through the following link.
|
||||
*
|
||||
* https://github.com/mamoe/mirai/blob/dev/LICENSE
|
||||
*/
|
||||
package issue2108
|
||||
|
||||
public object PrivateModule {
|
||||
public fun stack(): Throwable = Throwable("Stack trace")
|
||||
}
|
@ -24,6 +24,7 @@ kotlin {
|
||||
dependencies {
|
||||
api(project(":mirai-console.integration-test"))
|
||||
api(parent!!.project("module-modb"))
|
||||
api(parent!!.project("module-private-issue2108"))
|
||||
}
|
||||
|
||||
tasks.getByName("jar", Jar::class) {
|
||||
|
@ -11,6 +11,7 @@ package pdepdep2054sec
|
||||
|
||||
import issue2054.modulea.ModuleA
|
||||
import issue2054.moduleb.ModuleB
|
||||
import issue2108.PrivateModule
|
||||
import net.mamoe.mirai.console.plugin.jvm.JvmPluginDescription
|
||||
import net.mamoe.mirai.console.plugin.jvm.KotlinPlugin
|
||||
import net.mamoe.mirai.utils.info
|
||||
@ -26,10 +27,21 @@ public object PDepDependOnDepSec : KotlinPlugin(
|
||||
jvmPluginClasspath.pluginIndependentLibrariesClassLoader,
|
||||
listOf("net.mamoe.consoleit.issue2054:modb:1.0.0")
|
||||
)
|
||||
jvmPluginClasspath.downloadAndAddToPath(
|
||||
jvmPluginClasspath.pluginIndependentLibrariesClassLoader,
|
||||
listOf("net.mamoe.consoleit.issue2108:private-module:1.0.0")
|
||||
)
|
||||
|
||||
assertSame(ModuleA, ModuleB.getModuleA)
|
||||
logger.info { "issue 2054" }
|
||||
|
||||
ModuleB.act { ModuleA.act { logger.info(Throwable("Stack trace")) } }
|
||||
|
||||
logger.info("issue 2108", PrivateModule.stack())
|
||||
assertSame(
|
||||
jvmPluginClasspath.pluginIndependentLibrariesClassLoader,
|
||||
PrivateModule.javaClass.classLoader,
|
||||
"Failed to load private module from " + jvmPluginClasspath.pluginIndependentLibrariesClassLoader
|
||||
)
|
||||
}
|
||||
}
|
||||
|
@ -20,5 +20,9 @@ public object PDepDependOnDep : KotlinPlugin(
|
||||
jvmPluginClasspath.pluginSharedLibrariesClassLoader,
|
||||
listOf("net.mamoe.consoleit.issue2054:moda:1.0.0")
|
||||
)
|
||||
jvmPluginClasspath.downloadAndAddToPath(
|
||||
jvmPluginClasspath.pluginIndependentLibrariesClassLoader,
|
||||
listOf("net.mamoe.consoleit.issue2108:private-module:1.0.0")
|
||||
)
|
||||
}
|
||||
}
|
||||
|
@ -247,7 +247,6 @@ internal class JvmPluginClassLoaderN : URLClassLoader {
|
||||
dependency: String
|
||||
): Boolean {
|
||||
if (dependency in sharedClLoadedDependencies) return true
|
||||
if (dependency in privateClLoadedDependencies) return true
|
||||
return dependencies.any { it.containsSharedDependency(dependency) }
|
||||
}
|
||||
|
||||
@ -288,8 +287,11 @@ internal class JvmPluginClassLoaderN : URLClassLoader {
|
||||
if (dependencies.isEmpty()) return
|
||||
val results = ctx.downloader.resolveDependencies(
|
||||
dependencies, ctx.sharedLibrariesFilter,
|
||||
DependencyFilter { node, _ ->
|
||||
return@DependencyFilter !containsSharedDependency(node.artifact.depId())
|
||||
DependencyFilter filter@{ node, _ ->
|
||||
val depid = node.artifact.depId()
|
||||
if (containsSharedDependency(depid)) return@filter false
|
||||
if (depid in privateClLoadedDependencies) return@filter false
|
||||
return@filter true
|
||||
})
|
||||
val files = results.artifactResults.mapNotNull { result ->
|
||||
result.artifact?.let { it to it.file }
|
||||
|
Loading…
Reference in New Issue
Block a user