What is a p2 repository?

armin.miedl picture armin.miedl · May 10, 2017 · Viewed 10.8k times · Source

I'm working on a project now for a few months where we use "p2-repositories". I know that I get my dependencies from them. But now I want do dive deeper into the subject and I wonder what exactly is a p2-repository - the definition.

I think it has something to do with OSGi and with Nexus. But where does it come from? Am I bound to Nexus when I use p2 repositories? Or is this the common standard from OSGi? Or Eclipse/Maven/Tycho?

Why do I need p2-repositories, when I can have Maven? Or why can't I use Maven?

Answer

Christian Schneider picture Christian Schneider · May 10, 2017

P2 repositories are very common in the eclipse ecosystem. They combine the artifacts (bundles), the meta data and can also contain eclipse features.

P2 repositories are generally completely independent of maven repositories and nexus. Nexus has some support for p2 features which is probably the connection you have with it.

Another way of providing deployments in OSGi is using Apache Karaf features. These list the bundles to install as urls to each bundle. Such a url can also be a mvn url with maven coordinates. In this case the features as well as the bundles are located in maven.

A third way is to use OSGi bundle repositories. This is an OSGi standard and is used in bndtools. They just host the index of the meta data and a url to the bundle. It can be integrated with maven.

Unfortunately these ways of deployment are mutually exclusive. So you best use the one that is the most prominent for the platform you develop on. So for example if almost all of your dependencies are from eclipse projects then p2 is natural.