4

Lars Vogel has a nice tutorial of how to build an eclipse plugin or rcp application with tycho (http://www.vogella.com/articles/EclipseTycho/article.html). This works well but there are two things I don't like. It builds against a repository that is somewhere and not in my control

  <repositories>
     <repository>
       <id>juno</id>
       <layout>p2</layout>
       <url>http://download.eclipse.org/releases/juno</url>
     </repository>
  </repositories>

and it does not show how the artifact can be used by another build. If possible I would like to build against a nexus repository where the target platform should be hosted and also the deployment of my build should be uploaded, so that another build can reference this as his target platform.

I have seen that there are some p2 plugins for nexus and also a nexus-unzip-plugin (https://bugs.eclipse.org/bugs/show_bug.cgi?id=393309) that can be used to navigate into an artifact but I have not enough knowledge to see how to stick these things together to be able building a eclipse plugin or rcp app against a nexus repository. Does someone one can show me the way to do that?

nickhar
  • 19,981
  • 12
  • 60
  • 73

2 Answers2

2

You should not need the nexus-p2-plugin. If you deploy your p2 repository as a zip file to your maven repository you should be able to use the unzip plugin. See the wiki page - http://wiki.eclipse.org/Tycho/Nexus_Unzip_Plugin for instructions on configuring it. I've extracted some of the steps here;

  1. Clone the repository (assuming git is installed)

    git clone git://git.eclipse.org/gitroot/tycho/org.eclipse.tycho.nexus.git

  2. Build the plugin (assuming maven is installed)

    mvn clean install

-- See "Deploying the plug-in" in the wiki page

  1. Stop your nexus installation

  2. Unzip org.eclipse.tycho.nexus.git/target/unzip-repository-plugin--bundle.jar into your sonatype-work/nexus/plugin-repository/

  3. Start your nexus installation

  4. See "Configuring an unzip repository" in the wiki page

  5. If your main repository is public and you have created a virtual unzip repository called public.unzip, a deployed p2 repository zip available at e.g.

    http://<NEXUS_HOST>/nexus/content/repositories/public/org/example/demo/org.example.demo.repository/0.1.0/org.example.demo.repository-0.1.0.zip
    

should be available as;

    http://<NEXUS_HOST>/nexus/content/repositories/public.unzip/org/example/demo/org.example.demo.repository/0.1.0/org.example.demo.repository-0.1.0.zip-unzip

You should be able to use that URL as your p2 repository URL in your builds.

Simon
  • 720
  • 4
  • 12
  • The Nexus Unzip Plugin is already build by the hudson instance [https://hudson.eclipse.org/hudson/](https://hudson.eclipse.org/hudson/). Sadly the artifact can not be downloaded by public. – Markus Schmidt Nov 28 '12 at 09:01
  • For now you can compile it yourself from source as per the above instructions. – Simon Nov 28 '12 at 11:10
  • Yes, thanks Simon. It's working. The trade-off is that you have always to provide a updatesite for depending projects. Even your core needs the rcp/osgi runtime as updatesite. – Markus Schmidt Nov 29 '12 at 08:45
  • I'm not sure I understand your comment. Do you mean the basic eclipse stuff is not in your repository and needs to be referenced separately? If so you can control this behaviour - see http://wiki.eclipse.org/Tycho/Packaging_Types#eclipse-repository. You could also create a composite p2 repository pointing to both your nexus artifact repository and the eclipse repository (or a mirror of it) - see http://wiki.eclipse.org/Equinox/p2/Composite_Repositories_(new%29 – Simon Nov 29 '12 at 12:14
  • My comment was about how a rcp app references the eclipse platform stuff. I made a update site project with eclipse, refered the eclipse bundles i needed. Then I build the update site and deployed it to the repository as a zip file. Maybe the packaging type "eclipse-repository" will do the job too. I haven't tried it yet. – Markus Schmidt Dec 05 '12 at 12:05
0

In order to build against Nexus and have others you have to:

  1. Install the Nexus P2 plugin into your instance and turn the publishing of artifacts on for the repository you intend to use.
  2. Add nexus as your maven repository to the maven repositories in your POM file, so you can use maven deploy to upload your plugins.
  3. Add the same nexus as am eclipse P2 repository, so your tycho build can download your plugins
  4. Build your artifacts (maven install)
  5. Deploy your artifacts to nexus (maven deploy)
  6. Provide those that want to reuse via tycho the address of your tycho server.

Notes:

  • Tycho builds are Eclipse builds, and Eclipse builds work with P2 repositories, remote maven repositories cannot be supported due to the fact that Eclipse picks the best version from the repo based on dependency requirements. This would cause lost of traffic to the maven repo and be too slow.
  • The only artifacts that are exposed by the Nexus P2 plugin are plugins (a.k.a. OSGI bundles). Eclipse has other items that are relevant for reuse in a build, like features and products. Hence if someone wants to reuse these items, you must host a P2 repository produced by the tycho build somewhere else for them.
  • If you call 'deploy' repeatedly, every artifact will have a new minor version number, if you are building a SNAPSHOT. Eclipse (and hence Tycho) does not know the concept of a snapshot and will deploy a version with a timestamp instead. This can lead to your nexus filling up.
Jörn Guy Süß
  • 1,408
  • 11
  • 18
  • I believe the unzip plugin avoids the need for the nexus p2 plugin. Instead the contents of the zip file are available as if it had been unzipped on a webserver somewhere. This permits all the p2 data to be available rather than just the plugins as supported by the nexus p2 plugin. – Simon Nov 23 '12 at 09:24