Why is the <packaging> element included
-
20-04-2021 - |
Question
When I navigate to - http://search.maven.org/#artifactdetails%7Corg.apache.portals.pluto%7Cpluto-container-api%7C2.0.2%7Cbundle
the dependency is -
<dependency>
<groupId>org.apache.portals.pluto</groupId>
<artifactId>pluto-container-api</artifactId>
<version>2.0.2</version>
<packaging>bundle</packaging>
</dependency>
Should it not be -
<dependency>
<groupId>org.apache.portals.pluto</groupId>
<artifactId>pluto-container-api</artifactId>
<version>2.0.2</version>
</dependency>
As including the tag seems to cause an error, attached -
Solution
It seems like a fair assumption that the XML you quote is intended to be copied and pasted into a pom.xml.
You're right. Removing <packaging>
is the correct thing to do.
There's no need to specify the type, because the bundles artifacts have a 'jar' extension anyway. Even if the packaging was not 'jar' ‒say, for example, it was 'war'‒ the correct element to use would be <type>
and not <packaging>
.
OTHER TIPS
The artifact was build using the maven-bundle-plugin to enable the artifact to be used in OSGi environments (can be seen in the parent pom of this bundle). This plugin introduces the 'bundle
' packaging type.
As the artifact is still a 'jar' you can skip specifying the <type>
in your dependency section (The presented <dependency>
section of the repository web interface you mentioned is wrong. There is no <packaging>
element inside <dependency>
. <packaging>
is one of the maven coordinates).