【发布时间】:2016-03-31 15:22:29
【问题描述】:
我们有一个使用 Maven 和 Tycho 构建的 Eclipse 插件。现在 但是,我们仍然通过一堆手动提供所有项目依赖项 添加 JAR 文件而不是 Maven。原因如下: (1) 依赖项不能通过标准的 Eclipse 更新站点获得(至少 不在当前版本中),(2)依赖项不能作为包提供。
这些依赖关系中最大的部分是 Selenium 库(API、Remote、 特定于浏览器的库及其传递依赖项,例如 Guava 等)
我已经浪费了几个小时,试图在我们的 Maven 构建过程中提取这些依赖项。
在this SO 问题之后,我尝试了p2-maven-plugin,创建了一个更新
包含我添加到我的 Eclipse 目标平台的依赖项的站点。然而,
在运行时,不能跨不同 JAR 引用的类
加载(我假设,根据我非常有限的 OSGi 知识,因为一些
MANIFEST.MF 文件中缺少必要的信息)。这是一个例子
的问题,当试图创建一个RemoteWebDriver,它使用
DesiredCapabilities 类(两个类在不同的包中):
Exception in thread "Thread-8" java.lang.NoClassDefFoundError: org/openqa/selenium/remote/DesiredCapabilities
at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:243)
at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:126)
at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:153)
…
Caused by: java.lang.ClassNotFoundException: org.openqa.selenium.remote.DesiredCapabilities cannot be found by org.seleniumhq.selenium.remote-driver_2.45.0
at org.eclipse.osgi.internal.loader.BundleLoader.findClassInternal(BundleLoader.java:439)
at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:352)
at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:344)
at org.eclipse.osgi.internal.loader.ModuleClassLoader.loadClass(ModuleClassLoader.java:160)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 7 more
在使用p2-maven-plugin 时,我还有什么需要注意的吗? pom.xml 的相关部分如下所示:
<plugin>
<groupId>org.reficio</groupId>
<artifactId>p2-maven-plugin</artifactId>
<version>1.1.1-SNAPSHOT</version>
<executions>
<execution>
<id>default-cli</id>
<configuration>
<artifacts>
<artifact>
<id>org.seleniumhq.selenium:selenium-remote-driver:2.45.0</id>
</artifact>
</artifacts>
</configuration>
</execution>
</executions>
</plugin>
【问题讨论】:
标签: java eclipse maven dependencies tycho