Vainolo's Blog

Creating and Using an Eclipse Update Site using Maven, Tycho and Github

leave a comment

After deciding that it was about time to learn maven, I managed to convert all of my projects to maven, using m2e and tycho. Everything was fine until I decided to use non-eclipse libraries inside my eclipse projects. This is one of the points I REALLY hate about eclipse – its either their way or the highway.

I wanted to use the guava library in my project, so I created an eclipse plugin project from jar, changed it to a maven project, updated everything and BOOM – project config is destroyed. This is because eclipse manages dependencies in one file (MANIFEST.MF) and maven manages the dependencies in another file (obviously you know this, pom.xml). And it’s either one or the other.

So after some trying I gave up and stopped using maven for a couple of days. This was a very good thing because it let my brain do background processing to find the solution which somehow I couldn’t find. And while it breaks some of maven’s philosophy, it works: manage the libraries manually in a simple plug-in project, deploy it to a repository (p2, of course) and use this repository in the other eclipse projects that use the libraries. And what better place to put my repository than in github? So here is the tale of my journey.

First, instead of creating a plugin project from jars, I created a simple plugin project with no content. To this project I added a directory that contains all of the jars I wanted, added them to the plugin project configuration (stating also the exported packages). The directory was then added as a resource directory to the pom.xml file, like this:

<!-- inside the build section -->
  <resources>
    <resource>
      <directory>/resources</directory>
    </resource>
  </resources>

At this point maven (actually m2e) told me that the project was outdated so I should run Maven->Update Project but I am now smarter so I will not do this, because it simply destroys the eclipse project configuration, so DON’T DO IT.

Anyway, after this, I had to add all of the needed eclipse boilerplate projects (feature, p2, and releng) in order to create the site in an ordered way (this tutorial will teach you how to do it). And now for the final touch: putting the update site in github. At first I copied the results (using maven) of the build to another directory where a git repository is located, but then I remembered that my project is also at github, so I can use the project directly as an update site (just need remove the .gitignore entries for jar files). So doing this, the update site is easy to config in the using project (note the use of raw in the address, to get the real file and not the github page of the file):

<repositories>
  <repository>
    <id>indigo</id>
    <url>http://download.eclipse.org/releases/indigo</url>
    <layout>p2</layout>
  </repository>
<!-- My Repo -->
  <repository>
    <id>jdraw2d</id>
    <url>https://raw.github.com/vainolo/jdraw2d/master/com.vainolo.jdraw2d.releng.p2/target/repository</url>
    <layout>p2</layout>
  </repository>
</repositories>

The actual dependencies plugin dependencies are managed in the MANIFEST.MF file, and not in the maven file.

The files where all of these steps were applied can be found here. Enjoy!

Enhanced by Zemanta

Written by vainolo

March 6th, 2013 at 10:18 pm

Posted in Programming

Tagged with , , , ,

Leave a Reply

%d bloggers like this: