Monday, January 7, 2013

Tycho build 6: Building products

Now that we can build almost everything, there is just one step missing: building an RCP application.

Tycho Tutorials

1 Building plug-ins
2 Global maven settings
3 Global build project
4 Building features
5 Building p2 update sites
6 Building products
7 Plug-in unit tests
8 Using target platforms
9 Updating version numbers

Source code for this tutorial is available on googlecode as a single zip archive, as a Team Project Set or you can checkout the SVN projects directly.

Step 1: Convert required projects

Our example product has additional dependencies to com.example.tycho.product and com.example.tycho.product.feature which are not part of our maven build yet. To build our product we need to convert them first.

So convert those two projects to maven projects. Afterwards add both of them to our releng pom file. Nothing new so far.


Remember to remove the build section from the pom file for eclipse-plugins.


Step 2: Create a project for our product

Create a new General/Project called com.example.tycho.releng.product. Convert it to a maven project with Packaging set to eclipse-repository. Add the new project to our releng pom file as a module like we did for all the other projects.

Now move the file com.example.tycho.product/Tycho.product to the root folder of our newly created project. Tycho will not pick up product files by default, so we need to adjust our com.example.tycho.releng.product/pom.xml file a little. Add the following section within the project node:
 <build>
  <plugins>
   <plugin>
    <groupId>org.eclipse.tycho</groupId>
    <artifactId>tycho-p2-director-plugin</artifactId>
    <version>${tycho-version}</version>
    <executions>
     <execution>
      <!-- install the product using the p2 director -->
      <id>materialize-products</id>
      <goals>
       <goal>materialize-products</goal>
      </goals>
     </execution>
     <execution>
      <!-- create zip file with the installed product -->
      <id>archive-products</id>
      <goals>
       <goal>archive-products</goal>
      </goals>
     </execution>
    </executions>
   </plugin>
  </plugins>
 </build>

Step 3: Set start levels of your product bundles

There is one more step to take before we can run the build. It seems that PDE build (the thing that runs when you export an RCP product) adds some magic regarding bundle start levels. In fact it adjusts some autostart settings which we need to teach tycho manually.

Open your product definition file and switch to the Configuration tab. Add all plug-ins from the screenshot and set their start levels accordingly.


Save your product and start the build process. You should find your product in com.example.tycho.releng.product/target/products/tycho.product/win32/win32/x86. There will also be a zipped version available in the target/products folder.

If you have problems with the startup levels for your build, then use the Eclipse Product export wizard from the Overview tab of your product file. Switch to the folder where you exported your product to and open the file configuration/org.eclipse.equinox.simpleconfigurator/bundles.info. Each line holds an entry of type

bundle_name,version,location,startlevel,autostart

Find all bundles where autostart is set to true and add them in your product configuration file with their according start levels.

Optional: Adding p2.inf files

If you want to add additional p2 information to your product build, place your p2 file in the same folder as your project file and name it <project_name>.p2.inf.

Eg. create a file com.example.tycho.releng.product/Tycho.p2.inf with following content to add the Juno repository to the preconfigured update sites:

instructions.configure=\
org.eclipse.equinox.p2.touchpoint.eclipse.addRepository(type:0,location:http${#58}//download.eclipse.org/releases/juno,name:Juno);\
org.eclipse.equinox.p2.touchpoint.eclipse.addRepository(type:1,location:http${#58}//download.eclipse.org/releases/juno,name:Juno);

Optional: Build for multiple platforms

Adding another platform is simple: just ad a new environment to your master pom file:
      <environment>
       <os>macosx</os>
       <ws>cocoa</ws>
       <arch>x86_64</arch>
      </environment>
 

5 comments:

  1. I just switched to building my Eclipse product using Tycho and this is a really great tutorial, thanks for writing it.

    When I build my product, .eclipseproduct is generated. How can customize this file to my product? Right now, all I get are default value:

    name=Eclipse Platform
    id=org.eclipse.platform
    version=3.7.0

    In my product feature's POM I have tycho-packaing-plugin defined: http://pastebin.com/LbX1fgLG. I thought defining product would take care of that. In fact looking at .eclipseproduct file during various stages of the build I do see .eclipseproduct getting populated with my product id, but in final product it's gone.

    Thanks!

    ReplyDelete
    Replies
    1. Before I reade your comment I was completely unaware of this file. You might want to ask this question on the tycho users mailing list

      Delete
  2. Hi Christian,

    the best Tycho-tutorial I found, thanks for writing it!

    I encountered an issue when running the build after adding the product. Tycho is complaining about "Duplicate Reactor IUs":

    de.jmware.myproject.product 1.0.0 => [/sourcefolder/de.jmware.myproject.product, /sourcefolder/de.jmware.myproject.parent.product]

    The second project is the one I added following your tutorial (Section 9 "Building Products").

    I googled around but didn't found really helpful comments on this error. Seems that the Reactor UIs are built on artifactid and version, but these two are different in the projects mentioned above.

    Do you know how to solve this issue?

    Thanks in advance, Jens

    ReplyDelete
    Replies
    1. Ok, I found the error: product_id in product definition file was the same as the artifactid.
      Greets, Jens

      Delete
    2. Thanks for sharing this solution. I was not aware of this problem either.

      Delete