Rammohan
Rammohan

Reputation: 619

I am facing a Maven error: "Unknown packaging: bundle". Any suggestions how to resolve it?

Anyone knows how to fix this error.

I am trying to analyse my code using maven plugin for finding bugs. I am getting some error with packaging type bundle.

The maven command I am executing is mvn clean compile site

I tried adding the maven-bundle-plugin in reporting section, but it did not solve the problem.

[WARNING] Unable to create Maven project for com.fasterxml.jackson.module:jackson-module-scala_2.10:jar:2.10.0 from repository.
org.apache.maven.project.ProjectBuildingException: Some problems were encountered while processing the POMs:
[ERROR] Unknown packaging: bundle @ line 6, column 16

My pom.xml looks something like this.

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.2.1.RELEASE</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>

    <properties>
        <java.version>1.8</java.version>
        <maven-jar-plugin.version>3.1.1</maven-jar-plugin.version>
    </properties>

    <repositories>
        <repository>
            <id>redshift</id>
            <url>http://redshift-maven-repository.s3-website-us-east-1.amazonaws.com/release</url>
        </repository>
    </repositories>

    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-actuator</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
            <exclusions>
                <exclusion>
                    <groupId>org.junit.vintage</groupId>
                    <artifactId>junit-vintage-engine</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
           <groupId>com.amazon.redshift</groupId>
           <artifactId>redshift-jdbc42</artifactId>
           <version>1.2.10.1009</version>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-jdbc</artifactId>
        </dependency>
        <dependency>
            <groupId>org.json</groupId>
            <artifactId>json</artifactId>
            <version>20190722</version>
        </dependency>
        <dependency>
            <groupId>com.bazaarvoice.maven.plugins</groupId>
            <artifactId>s3-upload-maven-plugin</artifactId>
            <version>1.4</version>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
            <plugin>
                <groupId>org.apache.felix</groupId>
                <artifactId>maven-bundle-plugin</artifactId>
                <version>4.2.1</version>
                <extensions>true</extensions>
            </plugin>
        </plugins>
    </build>

    <reporting>
        <plugins>
           <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-pmd-plugin</artifactId>
                <version>3.11.0</version>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-project-info-reports-plugin</artifactId>
                <version>3.0.0</version>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-jxr-plugin</artifactId>
                <version>3.0.0</version>
            </plugin>
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>findbugs-maven-plugin</artifactId>
                <version>2.5.2</version>
                <configuration>
                    <!--
                        Enables analysis which takes more memory but finds more bugs.
                        If you run out of memory, changes the value of the effort element
                        to 'low'.
                    -->
                    <effort>Max</effort>
                    <!-- Reports all bugs (other values are medium and max) -->
                    <threshold>Low</threshold>
                    <!-- Produces XML report -->
                    <xmlOutput>true</xmlOutput>
                </configuration>
            </plugin>
        </plugins>
    </reporting>
</project>

Upvotes: 3

Views: 1949

Answers (1)

slindenau
slindenau

Reputation: 1267

You are facing this issue because the maven-project-info-reports-plugin doesn't support bundle as the packaging of any pom.xml (which is used to create a jar that is compatible with OSGi).

This can be caused by any of your (transitive) dependencies used. The project info reporting plugin tries to parse all those pom.xml files, and list the information in the site dependency information section.

If you upgrade this plugin to the latest version, for example 3.6.0 at the time of writing, these error messages will disappear. Update this in your pom.xml:

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-project-info-reports-plugin</artifactId>
                <version>3.6.0</version>
            </plugin>

You can find the most recent version of this plugin here: https://mvnrepository.com/artifact/org.apache.maven.plugins/maven-project-info-reports-plugin

Now, this will still not support bundle, but at least it will not log a huge error + stacktrace anymore for every pom it can't parse. Instead, the warnings have been replaced with the following info messages:

[INFO] Unable to create Maven project from repository for artifact '...', for more information run with -X

Only when you run in debug mode (-X on the mvn command) will you see the full error message, which will still tell you it doesn't support bundle.

This at least cleans up your logging, and won't break any build automation systems that check the maven output log for warnings/errors.

References:

Upvotes: 0

Related Questions