Maven:"未知打包:bundle"错误,来自作为bundle的依赖项打包



我在项目中运行mvn org.apache.maven.plugins:maven-dependency-plugin:3.1.1:copy-dependencies,并看到以下错误:

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-dependency-plugin:3.1.1:copy-dependencies (default-cli) on project beam-sdks-java-core: Some problems were encountered while processing the POMs:
[ERROR] [ERROR] Unknown packaging: bundle @ line 6, column 16: 1 problem was encountered while building the effective model for org.xerial.snappy:snappy-java:1.1.4
[ERROR] [ERROR] Unknown packaging: bundle @ line 6, column 16

看看 Snappy 的 pom 文件,它看起来像这样:

<?xml version='1.0' encoding='UTF-8'?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0">
<modelVersion>4.0.0</modelVersion>
<groupId>org.xerial.snappy</groupId>
<artifactId>snappy-java</artifactId>
<packaging>bundle</packaging>
<description>snappy-java: A fast compression/decompression library</description>
<version>1.1.4</version>
<name>snappy-java</name>
....

具体来说,<packaging>bundle</packaging>线似乎是问题所在。

我尝试将maven-bundle-plugin添加到我自己的 POM 文件的<build>标签中,但这不会修复它(为什么要这样做?我认为依赖项的配置不应该影响我的pom?

如何为依赖项启用maven-bundle-plugin?我是否需要将其添加到我的pom中引用apache.maven.plugins:maven-dependency-plugin:3.1.1:copy-dependencies的特定小节中?

另外,对于额外的信息,我的Maven版本是3.5.0

我尝试将 maven-bundle-plugin 添加到我自己的 POM 文件中 标签,但这不会修复它(为什么要这样做?我认为 依赖项的配置应该不会影响我的 POM?

你是对的:这不是你需要maven-bundle-plugin作为dependency添加以使bundle包在生成中可用。
您需要的是将maven-bundle-plugin作为plugin添加到 增强默认的 Maven 生命周期,例如:

<build>
<plugins>
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<extensions>true</extensions>
<configuration>
<instructions>
<Include-Resource> 
....
</Include-Resource>
</instructions>
</configuration>
</plugin>
</plugins>
<build>

您可以在apache-felix-maven-bundle-plugin中找到相关信息。

这实际上是 snappy-java 1.1.4 的一个问题。他们的pom不包括捆绑插件。但是,版本 1.1.7 切换到 jar 包装。

您可以使用 maven-dependency-plugin 2.10 来解决此问题。

最新更新