I have an OSGi bundle that was built using Maven by another team. The POM file declares its packaging as “bundle” and uses the Apache Felix plugin.
I need to deploy this artifact to a local Maven repository (Nexus) so that it can be used by our internal projects.
I have used the deploy:deploy-file target to deploy the bundle to the repository, just as you would with a standard JAR file and this works without error. I extracted the embedded POM from the bundle and passed that on the command line, so the command line was:
mvn deploy:deploy-file -Dfile=3rdpartybundle.jar -DpomFile=pom.xml -DrepositoryId=internal -Durl=http://internalserver/nexus
The issue is that when I deploy it like this, the packaging is set to bundle and as a result the name of the artifact in the repository ends up with a .bundle extension, instead of a .jar extension.
Now, we cannot figure out how to declare it as a dependency. If we declare it like this:
<dependency>
<groupId>...</groupId>
<artifactId>...</artifactId>
<version>...</version>
<type>bundle</type>
</dependency>
We get an error stating that the dependency cannot be resolved. The interesting thing is that the GAV coordinates in the error message actually has “jar” as the value for the type of the dependency even though we set it as “bundle”.
If we change the dependency to:
<dependency>
<groupId>...</groupId>
<artifactId>...</artifactId>
<version>...</version>
<type>jar</type>
</dependency>
We get the exact same unresolved dependency error.
So how are you supposed to deploy an artifact packaged as a bundle to a Maven repository, so that it can be used as a compile time dependency for another project?
Thanks
Thanks for the answers, I think I have a workaround (I wouldn’t call it a solution though).
@earcar is on the right track, although that solution doesn’t leverage all of the information available in the pom.xml that is available in the 3rd party bundle already (particularly the dependencies).
So what seems to work, even though the documentation for the deploy:deploy-file is a little vague, is that you can pass a pom.xml file AND also set the packaging parameter at the same time. So my command line now looks like this:
Doing it this way, the pom.xml in the repository still says that the packaging is of type “bundle”, and includes all of the dependencies etc., but the artifact itself has a .jar file extension.
Then when we declare our dependency as type JAR, Maven is able to resolve it successfully:
This basically solves our problem. I am not sure how portable or reliable this is though. FWIW, we are running Maven 3.0.3
Thanks for the help.