Maven:从依赖项打包为bundle时出现“未知的打包:bundle”错误

6

我在我的项目中运行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?我需要将其添加到涉及 apache.maven.plugins:maven-dependency-plugin:3.1.1:copy-dependencies 的POM的特定子部分吗?

另外,我使用的 Maven 版本是 3.5.0。


我现在也遇到了这个问题。但是尝试包含com.typesafe:config依赖项。它有一个无效的pom,其中包含packang bundle,并且在pom中没有声明bundle插件。我唯一能建议的就是联系库的作者并要求更正pom。我想知道这些人是如何构建bundle的 :) - anydoby
我已经为此创建了一个问题 https://github.com/xerial/snappy-java/issues/255 - Antony Stubbs
2个回答

4
我尝试将maven-bundle-plugin添加到我的POM文件的标签中,但这样做并不能解决问题(为什么要这样做呢?我认为依赖项的配置不应该影响我的pom)。
而你是正确的:并不是需要将maven-bundle-plugin作为依赖项添加,才能使bundle包在你的构建中可用。你需要将maven-bundle-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 中没有包含插件。 - Kenn Knowles

1
这实际上是关于snappy-java 1.1.4的问题。他们的pom文件中没有包含bundle插件。但是,版本1.1.7切换到了jar打包。
您可以通过使用maven-dependency-plugin 2.10来解决此问题。

这在1.1.7.7版本中似乎仍然是一个问题。 - Antony Stubbs
我已经为此创建了一个问题 https://github.com/xerial/snappy-java/issues/255 - Antony Stubbs

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接