Quantcast

Steps to get the Nexus p2 repository plugin to run (I want to use this for Tycho builds)

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Steps to get the Nexus p2 repository plugin to run (I want to use this for Tycho builds)

a.shewring
Hi there

I want to try the p2 support in Nexus OSS (via the p2 repository plugin which was recently open sourced). I followed the instructions on the page

https://docs.sonatype.org/display/Nexus/Nexus+OSGi+Experimental+Features+-+P2+Repository+Plugin

At least one person has managed to get the p2 functionality to run with recent 1.10.0-SNAPSHOT versions (see the comment on that page).
 
I found the latest snapshots of all the required components:
* Nexus itself (nexus-oss-webapp-1.10.0-20111213.030726-160-bundle)
* Nexus p2 repository plugin (nexus-p2-repository-plugin-1.0-20111130.160618-32-bundle.zip)
* Nexus capabilities plugin (nexus-capabilities-plugin-1.10.0-20111214.183234-178-bundle.zip) AND
* Nexus p2 bridge plugin (nexus-p2-bridge-plugin-1.0-20111213.032133-777-bundle.zip).

Unfortunately Nexus refuses to start with this combination. Below is an extract from the wrapper log:

jvm 1    | -------------------------------------------------
jvm 1    | 2011-12-15 01:15:23 INFO  [7-main-thread-1] - org.sonatype.nexus.DefaultNexus - Activating locally installed plugins...
jvm 1    | [WARNING] Error initializing: org.sonatype.nexus.DefaultNexus@310caf
jvm 1    | java.lang.NullPointerException
jvm 1    | at org.sonatype.nexus.plugins.DefaultNexusPluginManager.activatePlugin(DefaultNexusPluginManager.java:189)
jvm 1    | at org.sonatype.nexus.plugins.DefaultNexusPluginManager.activatePlugin(DefaultNexusPluginManager.java:143)
jvm 1    | at org.sonatype.nexus.plugins.DefaultNexusPluginManager.activatePlugin(DefaultNexusPluginManager.java:192)
jvm 1    | at org.sonatype.nexus.plugins.DefaultNexusPluginManager.activatePlugin(DefaultNexusPluginManager.java:143)
jvm 1    | at org.sonatype.nexus.plugins.DefaultNexusPluginManager.activateInstalledPlugins(DefaultNexusPluginManager.java:126)
jvm 1    | at org.sonatype.nexus.DefaultNexus.initialize(DefaultNexus.java:538)
jvm 1    | at org.sonatype.guice.plexus.lifecycles.PlexusLifecycleManager.initialize(PlexusLifecycleManager.java:338)
jvm 1    | at org.sonatype.guice.plexus.lifecycles.PlexusLifecycleManager.manageLifecycle(PlexusLifecycleManager.java:296)
jvm 1    | at org.sonatype.guice.plexus.lifecycles.PlexusLifecycleManager.onProvision(PlexusLifecycleManager.java:148)
jvm 1    | at com.google.inject.internal.ProvisionListenerStackCallback$Provision.provision(ProvisionListenerStackCallback.java:108)
jvm 1    | at com.google.inject.internal.ProvisionListenerStackCallback.provision(ProvisionListenerStackCallback.java:55)
jvm 1    | at com.google.inject.internal.ProviderInternalFactory.circularGet(ProviderInternalFactory.java:68)
jvm 1    | at com.google.inject.internal.InternalFactoryToInitializableAdapter.get(InternalFactoryToInitializableAdapter.java:45)
[...]

Does anyone have some current instructions to set up the p2 repository plugin? I also tried the plugin with the latest release version of Nexus (1.9.2.3), but this did not work either. I don't have the logs for that, however.

Thanks,
Andrew
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Steps to get the Nexus p2 repository plugin to run (I want to use this for Tycho builds)

Rafał Krzewski
FYI, I managed to get P2 repository plugin going by searching getting the following from https://repository.sonatype.org/

org.sonatype.nexus nexus-oss-webapp 2.0-SNAPSHOT (nexus-oss-webapp-2.0-20111229.182359-1-bundle.zip)
org.sonatype.nexus.plugins nexus-capabilities-plugin 2.0-SNAPSHOT (nexus-capabilities-plugin-2.0-20120102.160942-2-bundle.zip)
org.sonatype.nexus.plugins nexus-p2-bridge-plugin 1.0-SNAPSHOT (nexus-p2-bridge-plugin-1.0-20120102.161341-881-bundle.zip)
org.sonatype.nexus.plugins nexus-p2-repository-plugin 1.0-SNAPSHOT (nexus-p2-repository-plugin-1.0-20120102.164205-47-bundle.zip)

I'm also interested in OBR support so I also got:

org.sonatype.nexus.plugins nexus-p2-repository-plugin 1.10.0-SNAPSHOT (org.sonatype.nexus.plugins nexus-p2-repository-plugin)

Nexus started up cleanly and I was able to configure the P2 and OBR goodies.

Here's what I tried with those plugins:

* mirror of remote P2 repository used by Tycho for dependency resolution - it worked, Tycho loaded P2 metadata from Nexus, but no actual bundle/feature transfer occurred as I had the stuff already cached in my local repo. I'll try blowing it away and reloading later. I had trouble setting up a mirror through ,m2/settings.xml but I might have missed something obvious. I'll recheck that later.

* P2 metadata generator capability on a hosted M2 repo. - I've deployed plugins and features built with Tycho to Nexus. The files are similar to those generated by Tycho but have slightly different suffixes/classifiers - -p2Artifacts.xml/-p2Content.xml from Nexus vs -p2artifacts.xml/-p2metadata.xml from Tycho.

* P2 aggregator capability on a hosted M2 repo. - I though it was not working, but then I noticed it created a P2 repository in <REPO>/.meta/p2 directory that is hidden by Nexus repository browser view. IMHO this is not intuitive and makes the resulting P2 repostitory URL rather ugly. Still - it works. I would prefer to have artifacts.xml and content.xml generated in the root of the repository or in /p2 subdirectory that will be visible in the browser. Perhaps it could be added as a configuration option?
Anyway, I was able to connect to the repository but it appeared to be empty. A quick check revealed that the aggregated repository contained only plugin bundles but not eclipse features. The repository is usable as it is for build dependency resolution, but if feature aggregation support was added in the future, Nexus could be also used to actually provision P2 applications.

* OBR virtual repository on top of a hosted Maven2 repository - just as P2 repository plugin it generated obr.xml catalog inside <REPO>.meta/ directory. Otherwise it was great. I could connect to to it using bndtools and browse the bundles.
I like the capabilities approach very much, it would be great it the OBR plugin worked in the same way. OBR repository can have any physical layout, including Maven2 layout so everything that's needed is obr.xml generation, quite unlike Maven2/Maven1 virtual repositories where directory structure needs to be adapted. There's however one particular virtual repository that I'd like to see: OBR over P2. Eclipse Orbit project has a bunch of good stuff OSGified and they are publishing a P2 repository. I would like to use those bundles with bndtools (http://bndtools.org/) but it does not "speak" P2, AFAICT. I don't know to what extent can the metadata be automatically translated between P2 and OBR but if Nexus could act as the bridge between those two, it would be great.

Many thanks to Sonatype for making those plugins to OSS edition users!

Cheers,
Rafał
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Steps to get the Nexus p2 repository plugin to run (I want to use this for Tycho builds)

a.shewring
Thanks a lot for your effort and feedback Rafał! Regarding your comments on "P2 aggregator capability on a hosted M2 repo", can we raise this on the Nexus Jira? The idea of using Nexus for provisioning is quite compelling.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Steps to get the Nexus p2 repository plugin to run (I want to use this for Tycho builds)

Rafał Krzewski
No problem, that was quite a fun exercise :)

Feel free to raise this in Nexus Jira.

There's one more piece related to using Nexus for provisioning - aggregating category.xml files.

As I understand this, this is an PDE / Eclipse installer specific extension to P2 that combines installable features into categories. When a P2 repository does not contain category.xml file at it's root, it appears empty in the installer wizard, unless the user unchecks "group items by category" option - that's why it's important from usability point of view.

If I were to implement such feature in Nexus, I would traverse the repository / watch the incoming artifacts and detect those with eclipse-repository packaging defined in the POM, produced by Tycho. For each such POM, open the artifact file - it's a ZIP and extract category.xml file at it's root. The file contains <category-def> items and <feature> items. These can be aggregated easily - features need to be simply collected and category definitions need to be merged whenever their id matches. There's one bit to pay attention for - when <category-def> ids match but their names differ, a decision needs to be taken. One could for example sort the files before merging according to groupId and artifactId (ascending) and version (descending, with proper version sorting semantics) and assume first occurrence wins approach. Descending version sort is important because matching/clashing category ids are going to occur mostly when merging subsequent versions of the same site.

Oh, and there's probably l10n support for category names. That needs to be taken into account too.

If you can spare the time and post it to Nexus Jira, it would be great.

cheers,
Rafał
Loading...