Sunday, January 6, 2013

Tycho build 5: Building p2 update sites

Now that we can build plug-ins and features the next step will be to build an update site.

Tycho Tutorials

For a list of all tycho related tutorials see Tycho Tutorials Overview

Source code for this tutorial is available on github as a single zip archive, as a Team Project Set or you can browse the files online.

Step 1: Create an update site project

Create a new project of type Plug-in Development/Update Site Project. Name it com.codeandme.tycho.releng.p2 and leave all the other settings to their defaults. You will end up in the Site Manifest Editor of your site.xml file. Add a New Category with some ID and a nice Name. Afterwards add the com.codeandme.tycho.plugin.feature to the category.



Step 2: Convert to maven project

Tycho expects the update site content to be stored in a file called category.xml. So rename site.xml to that name. You can still use the Site Manifest Editor to update your site contents afterwards.

Now convert the p2 project to a maven project. The procedure is the same as before, only Packaging should be set to eclipse-repository.


Switch to your com.codeandme.tycho.releng/pom.xml and add the com.codeandme.tycho.releng.p2 project as a module. Remember to check Update POM parent section in selected projects. Fix the build error as before and run your maven build.

You can find your p2 update site in com.codeandme.tycho.releng.p2/target/repository. If you like you can immediately use this location to install your feature into your running eclipse instance.

22 comments:

  1. Hi,
    nice tutorial! Is it possible to let maven automatically add the new feature to the category.xml and arifacts.jar and content.jar like eclipse does in an update site project?

    Thanks for your nice work!

    Christian

    ReplyDelete
    Replies
    1. Sorry, I do not understand your question. This tutorial shows how to build update sites with maven. To add additional features to your site you need to add them manually to your category.xml file.

      Delete
    2. Ok thank you, I thought it would be possible that maven adds the newes version of a feature to the category.xml, so that I have a list of all versions, it would be usefull for CI with jenkins. But writing a scipt for it can't be difficult.

      Delete
    3. The locally built update site could be merged into an existing update site. This allows to accumulate multiple versions within a single p2 site. Please look at the tycho documentation for an exact description

      Delete
    4. Thank you! I think the mirror goal from the tycho p2 Extras Plugin is exacly what I need :)

      Delete
  2. Hi!
    I build p2 both both inside Eclipse IDE and outside Eclipse on my PC. No problem.
    But when I let Jenkins build my p2 project I get the following error:
    ......releng.p2: No content specified for p2 repository
    Sure, I rename site.xml to Category.xml.
    Any idea? Thanks in advance!

    ReplyDelete
    Replies
    1. Just a guess: is your Jenkins build running on linux and your IDE on windows? You might want to try to rename Category.xml to category.xml then...

      Delete
  3. Your're right! :) It's working now. Thaks! Your turials are really good.

    ReplyDelete
  4. Do you know how can I approach the problem of creating a Feature / Update Site programatically? Is Tycho based on Eclipse PDE? Thanks!

    ReplyDelete
    Replies
    1. Tycho is based on maven and is NOT based on PDE or Eclipse. You may use maven calls to create template projects. I guess you could create an empty feature that way. But you would need to modify the feature.xml to add plugins to it manually. Best go for the eclipse forum on PDE. As PDE has wizards and export filters for features, there might be a way to reuse them.

      Delete
  5. This comment has been removed by the author.

    ReplyDelete
  6. I use the site.xml and pom.xml as the same in you ,but I have the same problem is : com.codeandme.tycho.releng.p2: No content specified for p2 repository -> [Help 1] .
    I don't why it happened ,thinks for helping !

    ReplyDelete
    Replies
    1. Check out the first sentence in step 2. It tells you to rename site.xml...

      Delete
    2. I forget it ! Think you very much!
      But I don't why rename the site.xml to category.xml.

      Delete
  7. Hi Christian,

    Thank you for your good tutorial.

    When we start adding dependencies, our feature build fails caused by those dependencies not found in mars p2 repository.

    So we setup our own p2 repository with this tutorial to contain all the dependencies, but since the feature build fails, the update site fails too. So we have kind of circular situation here.

    Any idea ?

    Thanks in advanced.

    Regards,
    Setya

    ReplyDelete
    Replies
    1. When your feature does not build, you need to fix that first before you try to build an update site. Eventually have a look at tutorial 8 about target platforms.

      Delete
    2. Hi Christian,

      Maybe I'm a little missed the tutorial flow here.

      If I have dependencies outside Mars, shouldn't I set up target platform project 1st followed by feature and p2 ?

      In your tutorial the order does not matter since all dependencies can be satisfied from Mars ?

      Thanks & Regards,
      Setya

      Delete
    3. Correct, I suggest you follow the tutorial until you have all the pieces together, then start adapting it for your plugins and needs. In your case, you should use a target platform.

      Delete
  8. Hello and thanks for the explanatory tutorial,


    When I add platform dependencies on the feature e.g.

    os="linux", ws="gtk" , arch="x86_64"


    I am able to build the project, but, update-site fails with error :

    [ERROR] Failed to execute goal org.eclipse.tycho:tycho-p2-repository-plugin:0.26.0:assemble-repository (default-assemble-repository) on project ... : Execution default-assemble-repository of goal org.eclipse.tycho:tycho-p2-repository-plugin:0.26.0:assemble-repository failed: Cannot resolve dependencies of MavenProject ...

    Inside master pom I have added the above environment inside build->plugin->configuration->environments tag

    What am I missing here ?

    ReplyDelete
    Replies
    1. I mean "I am able to build the feature itself but not the update site"

      Delete
    2. Looks like my problem is described here https://bugs.eclipse.org/bugs/show_bug.cgi?id=407273

      Delete