简体   繁体   English

使用 Maven 管理 Eclipse 插件项目的依赖项

[英]Managing dependencies of a Eclipse plug-in project using Maven

I am trying to use Maven for managing the dependencies of my plug-in project.我正在尝试使用 Maven 来管理我的插件项目的依赖项。 The dependencies are correctly stated in the POM.xml. POM.xml 中正确说明了依赖关系。 Even though, I get the exception:即使,我得到了例外:

java.lang.NoClassDefFoundError java.lang.NoClassDefFoundError

Is it the correct way for solving dependencies for an Eclipse plug-in project?它是解决 Eclipse 插件项目的依赖关系的正确方法吗?

Eclipse plug-ins must use the Require-Bundle or Import-Package statements in the plug-in's MANIFEST.MF to specify their dependencies. Eclipse 插件必须使用插件的 MANIFEST.MF 中的Require-BundleImport-Package语句来指定它们的依赖关系。

Plug-ins can only be dependent on other plug-ins.插件只能依赖于其他插件。

If you want to use a jar which is not a plug-in it must be included in the plug-in and included in the Bundle-Classpath in the MANIFEST.MF.如果要使用不是插件的 jar,则必须将其包含在插件中并包含在 MANIFEST.MF 的Bundle-Classpath中。 You will also have to update the build.properties file to include the jars in the plug-in build.您还必须更新build.properties文件以在插件构建中包含 jars。

Example MANIFEST.MF extract that includes 3 jars in the plug-in:在插件中包含 3 个 jars 的示例 MANIFEST.MF 提取:

Require-Bundle: greg.music.core;bundle-version="1.0.0",
 greg.music.resources;bundle-version="1.0.0",
 org.eclipse.core.runtime,
 javazoom.jlgui.basicplayer,
 org.eclipse.e4.core.services;bundle-version="2.0.100"
Bundle-ClassPath: .,
 lib/jogg-0.0.7.jar,
 lib/jorbis-0.0.15.jar,
 lib/vorbisspi1.0.2.jar
Import-Package: javax.annotation;version="1.0.0",
 javax.inject;version="1.0.0",
 org.eclipse.e4.core.di.annotations

Matching build.properties匹配 build.properties

source.. = src/
output.. = bin/
bin.includes = META-INF/,\
               .,\
               plugin.properties,\
               plugin.xml,\
               lib/jogg-0.0.7.jar,\
               lib/jorbis-0.0.15.jar,\
               lib/vorbisspi1.0.2.jar

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

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