Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Redesign console plugin loading system #1842

Merged
merged 6 commits into from
Feb 21, 2022
Merged

Conversation

Karlatemp
Copy link
Member

重新设计 console 插件加载系统

新的插件类搜索机制

`- 在 <console 类加载器>(jdk.internal.loader.ClassLoaders$AppClassLoader) 搜索, 如果搜索到就返回
`- 在<全局共享库> (For JvmPlugin only) 中搜索, 如果搜索到就返回
`- 在插件依赖的其他插件的<共享库类加载器>以及其<本体类加载器>中搜索,如果搜索到就返回
`- 在当前插件的<独立私有依赖库>中搜索, 如果搜索到就返回
`- 在当前插件的<本体类加载器>中搜索,如果搜索到就返回
`- 在其他未直接显示依赖的插件的<本体类加载器>中搜索, 如果搜索到就返回
`- throw ClassNotFoundException(className)

新依赖引入

mirai-console
  `- org.apache.maven.resolver:maven-resolver-api
  `- org.apache.maven.resolver:maven-resolver-impl
  `- org.apache.maven.resolver:maven-resolver-connector-basic
  `- org.apache.maven.resolver:maven-resolver-transport-http
  `- org.apache.maven:maven-resolver-provider

console 文件结构变动

console
  `- plugin-libraries - 下载下来的各种依赖存放位置, 结构为本地 Maven 仓库
  `- plugin-shared-libraries - 全局共享库
      `- libraries.txt - 动态依赖, 其 jar 会下载至 plugin-libraries
      |                  格式:  group:artifact:version, eg: net.mamoe:mirai-console:2.9.2
      `- ***.jar - 需要直接加载的 jar, 此文件内的全部 jar 都将被加载

其他细节更新

当运行时为 Java 9+ 时, 报错堆栈将包含报错堆栈来源于哪个插件, Java 8 依然可正常运行

2022-01-20 22:20:44 I/Plugin Depend On Other: java.lang.Throwable: Stack trace
java.lang.Throwable: Stack trace
	at plugin-depend-on-other-0.0.0.jar//net.mamoe.console.integrationtest.ep.dependonother.PluginDependOnOther.onEnable(PluginDependOnOther.kt:38)
	at net.mamoe.mirai.console.internal.plugin.JvmPluginInternal.internalOnEnable$mirai_console(JvmPluginInternal.kt:117)
	at net.mamoe.mirai.console.internal.plugin.BuiltInJvmPluginLoaderImpl.enable(BuiltInJvmPluginLoaderImpl.kt:255)
	at net.mamoe.mirai.console.internal.plugin.BuiltInJvmPluginLoaderImpl.enable(BuiltInJvmPluginLoaderImpl.kt:35)
	at net.mamoe.mirai.console.plugin.jvm.JvmPluginLoader$BuiltIn.enable(JvmPluginLoader.kt)
	at net.mamoe.mirai.console.plugin.jvm.JvmPluginLoader$BuiltIn.enable(JvmPluginLoader.kt:50)
	at net.mamoe.mirai.console.plugin.PluginManager.enablePlugin(PluginManager.kt:171)

close #1809, close #1800, close #1815

@Karlatemp Karlatemp added t:enhancement 类型: 现有功能上的优化 t:feature 类型: 新特性 N 优先级: 一般 s:console 子系统: mirai-console s:gradle 子系统: mirai-console-gradle labels Jan 20, 2022
@Karlatemp Karlatemp added this to the 2.11 milestone Jan 20, 2022
@Him188 Him188 self-requested a review January 20, 2022 14:57
@cssxsh
Copy link
Contributor

cssxsh commented Jan 20, 2022

maven repo 的 来源是否能 指定多个 url 或 mavenlocal 或 gradle-cache ?

@Him188 Him188 added M 优先级: 主要 and removed N 优先级: 一般 labels Jan 21, 2022
@Karlatemp Karlatemp force-pushed the console/plugin-loading-system branch from fc3750e to f7613b0 Compare January 21, 2022 06:30
@Karlatemp Karlatemp force-pushed the console/plugin-loading-system branch from ddea3bd to 3636060 Compare January 31, 2022 03:37
@Karlatemp Karlatemp requested a review from Him188 February 6, 2022 11:23
@Karlatemp Karlatemp force-pushed the console/plugin-loading-system branch from 3636060 to fbb1dd9 Compare February 6, 2022 11:36
@Karlatemp Karlatemp force-pushed the console/plugin-loading-system branch from d02ca84 to 18428ad Compare February 7, 2022 09:07
@Karlatemp Karlatemp requested a review from Him188 February 8, 2022 07:08
@Him188 Him188 modified the milestones: 2.11, 2.11.0-RC Feb 10, 2022
@Him188 Him188 linked an issue Feb 12, 2022 that may be closed by this pull request
@Karlatemp Karlatemp force-pushed the console/plugin-loading-system branch 2 times, most recently from d67762b to 74f1319 Compare February 20, 2022 15:04
@Him188 Him188 added z:ready-to-merge 状态: PR 已经可以合并, 正在等待一些安排 and removed t:enhancement 类型: 现有功能上的优化 labels Feb 21, 2022
@Him188
Copy link
Member

Him188 commented Feb 21, 2022

@Karlatemp rebase merge?

@Karlatemp Karlatemp force-pushed the console/plugin-loading-system branch from 74f1319 to 8e77109 Compare February 21, 2022 13:21
@Karlatemp Karlatemp merged commit 8e77109 into dev Feb 21, 2022
@Karlatemp Karlatemp deleted the console/plugin-loading-system branch February 21, 2022 13:23
@github-pages github-pages bot temporarily deployed to github-pages February 21, 2022 13:23 Inactive
@Him188 Him188 modified the milestones: 2.11.0-RC, 2.11.0-M1 Mar 8, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
M 优先级: 主要 s:console 子系统: mirai-console s:gradle 子系统: mirai-console-gradle t:feature 类型: 新特性 z:ready-to-merge 状态: PR 已经可以合并, 正在等待一些安排
Projects
None yet
3 participants