Intellij IDEA如何管理插件依赖? [英] How does Intellij IDEA manage plugin dependencies?

查看:1016
本文介绍了Intellij IDEA如何管理插件依赖?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在使用Intellij IDEA插件一段时间之后,我注意到具有外部依赖性的插件工作正常,即使这些依赖项未与插件本身捆绑在一起,也不会在任何地方公开声明。

After playing with Intellij IDEA plugins for a while, I have noticed that plugins with external dependencies work fine, even if these dependencies are not bundled with the plugin itself nor are they publicly declared anywhere.

选择随机示例: GenerateToString 插件取决于在其他方面,在log4j上。但是如果你看一下jar文件,你会看到它只包含它自己的类加上一些资源(图像和html文件)和元数据(强制性的plugin.xml和MANIFEST.MF),其中没有任何一个对log4j的引用。而且这个jar文件是你安装插件所需要的唯一东西。

Picking a random example: the GenerateToString plugin depends, among other things, on log4j. But if you take a look inside the jar file, you will see that it contains only its own classes plus some resources (images and html files) and metadata (the obligatory plugin.xml and the MANIFEST.MF), none of which has any reference to log4j. And that jar file is the only thing you need to install the plugin.

这怎么可能? IDEA如何管理这些依赖项,以便它不会在运行时抛出 ClassNotFoundException 或类似的东西?

How is that possible? How does IDEA manage these dependencies, so that it doesn't throw a ClassNotFoundException or something like that in runtime?

推荐答案

IDEA使用自定义类加载器,如果它没有在插件发行版中找到所需的类,则会在位于 IDEA_HOME / lib 目录。

IDEA uses custom classloader, if it doesn't find the required class in the plugin distribution, it's searched in all the jars located in IDEA_HOME/lib directory.

这篇关于Intellij IDEA如何管理插件依赖?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆