简体   繁体   English

使用独立于eclipse的eclipse插件

[英]Using eclipse plugin independent from eclipse

我可以在我的java代码中以编程方式使用Eclipse插件(以便它独立于eclipse)吗?

Yes you can if: 是的,你可以:

  • The plugin you want to use doesn't have any external dependencies => it's just a library plugin 您要使用的插件没有任何外部依赖项=>它只是一个库插件

  • The plugin you want to use and ALL it's dependencies are in your classpath 您要使用的插件及其所有依赖项都在您的类路径中

No in all other cases. 在所有其他情况下都没有。 Because many plugins use at least the core concepts of OSGI/Equinox (have an activator) it will be quite hard to use them in a standalone java app. 因为许多插件至少使用OSGI / Equinox的核心概念(有一个激活器),所以在独立的Java应用程序中使用它们将非常困难。

For example, SWT can be used outside eclipse. 例如,SWT可以在eclipse之外使用。

You should take a look in your eclipse directory. 你应该看看你的eclipse目录。 In the plugins folder you'll find a lot of .jar files. 在plugins文件夹中,你会发现很多.jar文件。 Sure, you could use these as dependencies in your project. 当然,您可以将它们用作项目中的依赖项。

是的,当然,您需要关注部署插件的jar文件并正确投影。

Well designed plugins are split into UI and "core" parts. 精心设计的插件分为UI和“核心”部分。 You would probably want to grab just the core component. 你可能想要只抓住核心组件。 And you may well need to provide an OSGi framework to properly load and activate the plugin too - depending on how complex it is. 您可能还需要提供一个OSGi框架来正确加载和激活插件 - 具体取决于它的复杂程度。

As others have also mentioned, don't forget the dependencies. 正如其他人也提到过的,不要忘记依赖关系。

Eclipse plugins are OSGi bundles. Eclipse插件是OSGi包。

OSGi bundles are JAR files that have extra info in META-INF that declares exports and imports. OSGi包是在META-INF中具有额外信息的JAR文件,用于声明导出和导入。 They sometimes make calls to OSGi APIs. 他们有时会调用OSGi API。

Many Eclipse plugins depend on other Eclipse-specific plugins. 许多Eclipse插件依赖于其他特定于Eclipse的插件。

If you use OSGi in your environment, you can easily reuse those plugins that have no Eclipse dependencies. 如果在您的环境中使用OSGi,则可以轻松地重用那些没有Eclipse依赖项的插件。 If your application is not OSGi, you can only easily reuse those that avoid the direct use of OSGi APIs. 如果您的应用程序不是OSGi,则只能轻松地重用那些避免直接使用OSGi API的应用程序。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM