Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Maven: `Unknown packaging: bundle` error from a dependency packaging as bundle

Tags:

java

maven

I am running mvn org.apache.maven.plugins:maven-dependency-plugin:3.1.1:copy-dependencies in my project, and I'm seeing the following errors:

[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

Looking at Snappy's pom file, it looks like so:

<?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>
    ....

Specifically, the <packaging>bundle</packaging> line seems to be the problem.

I tried adding the maven-bundle-plugin to my own POM file's <build> tag, but that won't fix it (and why should it? I'd think that a dependency's config shouldn't affect my pom?)

How do I enable the maven-bundle-plugin for my dependencies? Do I need to add it to a specific subsection of my pom that refers to apache.maven.plugins:maven-dependency-plugin:3.1.1:copy-dependencies?

Also, for extra info, my Maven version is 3.5.0

like image 861
Pablo Avatar asked Jun 27 '18 19:06

Pablo


2 Answers

I tried adding the maven-bundle-plugin to my own POM file's tag, but that won't fix it (and why should it? I'd think that a dependency's config shouldn't affect my pom?

And you are right : it is not the maven-bundle-plugin as a dependency that you need to add to make the bundle package usable in your build.
What you need is adding the maven-bundle-plugin as a plugin to enhance the default Maven lifecycle such as :

<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>

You can find the information in the apache-felix-maven-bundle-plugin.

like image 72
davidxxx Avatar answered Oct 24 '22 04:10

davidxxx


This is actually an issue with snappy-java 1.1.4. Their pom does not include the bundle plugin. However, version 1.1.7 switches to jar packaging.

You can work around this by using maven-dependency-plugin 2.10.

like image 28
Kenn Knowles Avatar answered Oct 24 '22 02:10

Kenn Knowles