在我的 Maven/Tycho 构建中,我有一个 exec-maven-plugin,由于 org.eclipse.emf.common
包中的签名者信息不匹配而导致失败并出现 SecurityException。 exec-maven-plugin 的执行依赖于两个 Artifact (实际上更多,但我认为它们与这个问题无关):
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.4.0</version>
<executions>
...
</executions>
<configuration>
...
<includeProjectDependencies>false</includeProjectDependencies>
<includePluginDependencies>true</includePluginDependencies>
</configuration>
<dependencies>
<dependency>
<groupId>org.eclipse.xtext</groupId>
<artifactId>org.eclipse.xtext.common.types</artifactId>
<version>${xtext.version}</version>
</dependency>
<dependency>
<groupId>my.group</groupId>
<artifactId>my.group.artifact</artifactId>
<version>1.8.6-SNAPSHOT</version>
</dependency>
...
</dependencies>
</plugin>
my.group.artifact
是一个使用 Tycho 构建的 OSGi 项目。因此,它的依赖项在构建过程中被“重新打包”,并安装到 p2.eclipse-plugin
groupId 下的本地 m2 存储库中。
有问题的包org.eclipse.emf.common
是org.eclipse.xtext.common.types
和my.group.artifact的依赖项
但它的解析方式不同,如 Maven 所示(省略了不相关的依赖项):
[DEBUG] org.codehaus.mojo:exec-maven-plugin:jar:1.4.0:
[DEBUG] org.eclipse.xtext:org.eclipse.xtext.common.types:jar:2.12.0:runtime
[DEBUG] org.eclipse.xtext:org.eclipse.xtext:jar:2.12.0:runtime
[DEBUG] org.eclipse.emf:org.eclipse.emf.common:jar:2.15.0:runtime
[DEBUG] my.group:my.group.artifact:jar:1.8.6-SNAPSHOT:runtime
[DEBUG] p2.eclipse-plugin:org.eclipse.emf.common:jar:2.12.0.v20160420-0247:system
然后,在执行上述任务时,两个 jar 都被包含在内,因此 org.eclipse.emf.common 包被添加到类路径中两次:
[DEBUG] Adding plugin dependency artifact: org.eclipse.emf.common to classpath
...
[DEBUG] Adding plugin dependency artifact: org.eclipse.emf.common to classpath
这会导致提到的 SecurityException:
java.lang.SecurityException: class "org.eclipse.emf.common.notify.impl.BasicNotifierImpl$EScannableAdapterList"'s signer information does not match signer information of other classes in the same package
这可能是由于上述重新打包步骤造成的。
我该怎么做才能避免这种冲突?
尾注:这是维护流的构建,上次运行于 7 月,该维护流成功运行。从那时起,只进行了一次小的代码更改,不会影响依赖项。然而,org.eclipse.emf.common 的 2.15.0 版本已于 9 月份发布。在此之前,2.12.x 是最新版本。 xtext 使用 [2.10.0,3) 声明其对 emf 的依赖关系,解析为 2.15.0。我们的 Artifact 的目标平台仅包括 2.12.0。当然,现在要尝试的一件事是将目标平台也移至 2.15.0,但我不愿意这样做,因为正如我所说,这是一个维护流,应该只接收必要的错误修复。
最佳答案
在这种情况下,您可以使用排除并将该包从 Artifact/包中排除,如下所示
<dependency>
<groupId>my.group</groupId>
<artifactId>my.group.artifact</artifactId>
<version>1.8.6-SNAPSHOT</version>
<exclusions>
<exclusion>
<groupId>org.eclipse.emf</groupId>
<artifactId>org.eclipse.emf.common</artifactId>
</exclusion>
</exclusions>
</dependency>
关于java - 由于 Tycho 'repackaging' ,共享 Maven 插件依赖项的解析方式不同,导致 SecurityException,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52820104/