tycho-surefire-plugin 中普通 jar 的可见性

问题描述

问题

我面临以下情况:

Eclipse 测试插件(tycho 包装类型 eclipse-test-plugin)的来源依赖于“普通”jar(阅读:非 Osgi jar)。我设法让测试在 Eclipse 中编译和运行,但是当从命令行运行 Maven/Tycho 时,tycho-surefire-plugin 无法执行测试,因为 jar 在测试时不可见.这会导致在尝试从 jar 加载类时出现 java.lang.NoClassDefFoundError

查看 mvn -e -X 输出没有发现任何重要的信息。

我的问题是,从命令行运行 Maven/Tycho 时,如何将 jar 包含在 tycho-surefire-plugin 的类路径中?

尝试

这是我迄今为止尝试过的所有内容

  1. 按照 tycho-surefire-plugin documentation 使用 <extraRequirements>。然而,这会失败,因为 jar 的包装类型是 jar,而 <extraRequirements> 需要 eclipse-xxx packaging types 之一。

为了很好的衡量,我也尝试过

<configuration>
  <dependencies>
    <dependency>
      <groupId>. . .</groupId>
      <artifactId>. . .</artifactId>
      <version>. . .</version>
      <scope>system</scope>
      <systemPath>path-to-the-jar</systemPath>
    </dependency>
  </dependencies>
</configuration>

但包装类型仍被视为jar

  1. 按照 tycho-surefire-plugin documentation 使用 <argLine>
<groupId>org.eclipse.tycho</groupId>
<artifactId>tycho-surefire-plugin</artifactId>
<configuration>
  <argLine>-cp path-to-the-jar</argLine>
</configuration>

然而,这似乎没有效果,因为 java.lang.NoClassDefFoundError 仍然存在。

  1. 将 jar 包含在 Eclipse 测试插件中。 jar 存在于 MANIFEST.MF
Bundle-Classpath: the.jar

build.properties

bin.includes = meta-inf/,\
               the.jar

并在 .classpath 中(尽管这对 tycho-surefire-plugin 无关紧要)。

<classpathentry exported="true" kind="lib" path="the.jar"/>

tycho-surefire-plugin 再次报告 java.lang.NoClassDefFoundError

  1. 创建一个专用的 Eclipse 插件来存放 jar。这在很大程度上相当于 3,其中 Eclipse 测试插件仅依赖于这个新的专用 Eclipse 插件java.lang.NoClassDefFoundError 仍然抬起头来。

  2. 过渡到 Tycho 2.x.x,因为它支持 Directory 位置类型。不幸的是,无法在目标定义中包含 jar,因为它的包装类型是 jar

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...