Tycho allows to package such repositories very easily.
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 a source update site project
Create a new project of type Plug-in Development/Update Site Project. Name it com.codeandme.tycho.releng.p2.source and leave all the other settings to their defaults. You will end up in the Site Manifest Editor of your site.xml file. Instead of editing this file by hand we will immediately delete site.xml and copy over the category.xml file from com.codeandme.tycho.releng.p2.
Mavenize the project the same way as we did in tutorial 5: set Packaging to eclipse-repository and add the project to com.codeandme.tycho.releng/pom.xml.
Step 2: Modify category.xml
Source plug-ins and features will be created by tycho on the fly, so we have no real projects in the workspace we could add with the Site Manifest Editor. Therefore we need to open category.xml with the Text Editor. Tycho does not care about the url property, so remove it. Feature ids need to be changed to <original.id>.source.
If you like you can move all source features to a dedicated category:
<?xml version="1.0" encoding="UTF-8"?> <site> <feature id="com.codeandme.tycho.plugin.feature" version="1.0.0.qualifier"> <category name="source_components"/> </feature> <category-def name="source_components" label="Developer Resources"/> </site>Step 3: Configure tycho source builds
To enable source builds we need to extend com.codeandme.tycho.releng/pom.xml a bit. The source below contains only the additions to our pom file, so merge them accordingly (full version on github).
<properties> <tycho.extras.version>${tycho.version}</tycho.extras.version> </properties> <build> <plugins> <!-- enable source feature generation --> <plugin> <groupId>org.eclipse.tycho.extras</groupId> <artifactId>tycho-source-feature-plugin</artifactId> <version>${tycho.extras.version}</version> <executions> <execution> <id>source-feature</id> <phase>package</phase> <goals> <goal>source-feature</goal> </goals> </execution> </executions> <configuration> <excludes> <!-- provide plug-ins not containing any source code --> <plugin id="com.codeandme.tycho.product" /> </excludes> </configuration> </plugin> <plugin> <groupId>org.eclipse.tycho</groupId> <artifactId>tycho-source-plugin</artifactId> <version>${tycho.version}</version> <executions> <execution> <id>plugin-source</id> <goals> <goal>plugin-source</goal> </goals> </execution> </executions> </plugin> <plugin> <groupId>org.eclipse.tycho</groupId> <artifactId>tycho-p2-plugin</artifactId> <version>${tycho.version}</version> <executions> <execution> <id>attached-p2-metadata</id> <phase>package</phase> <goals> <goal>p2-metadata</goal> </goals> </execution> </executions> </plugin> </plugins> </build>When building source plug-ins, tycho expects every plug-in project to actually contain source code. If projects do not contain source, we need to exclude them as we do on line 26.
After building the project we will end up with a p2 site containing binary builds and source builds of each feature/plug-in.
This comment has been removed by the author.
ReplyDeleteSorry, the xml code was hidden:
DeleteChristian thanks for that great how to. IMHO there is one small type in "Step 2)"s example:
It says:
<feature id="com.codeandme.tycho.plugin.feature" version="1.0.0.qualifier">
but IMHO it should be:
<feature id="com.codeandme.tycho.plugin.feature" version="1.0.0.qualifier">
damm same mistake than you did...it should be:
Delete<feature id="com.codeandme.tycho.plugin.feature.source" version="1.0.0.qualifier">
Hi,
ReplyDeletePerhaps I am doing something wrong here, but I always get the [ERROR] Cannot resolve project dependencies:
for the feature id ending at .source
Am I missing something here?
I had the same problem, after some time fiddling around, I finally managed to include the sources into the p2-repository: You have to include the secound plugin declaration of the tycho-p2-plugin with it's goal "p2-metadata".
DeleteI omitted it first as this plugin was already declared in my poms...