Sapphire Modeling Tycho build support
This page is for adopters of Sapphire framework that also use Tycho to build their eclipse plugins.
For any users that are trying to use tycho to build their eclipse plugins that use sapphire's model annotations, you will be required to configure tycho to generate the model classes as part of the maven build. In the sample Sapphire plugins this is done with a customBuildCallbacks.xml which is a facility for PDE build. Tycho doesn't support this ability out of the box but it can be easily configured by making some changes to your pom.xml and a edited version of the customBuildCallbacks.xml sample. Here is a link to the customBuildCallbacks.xml sample in CVS
In the pom.xml for any plugin that has sapphire generated models you need to have the pom run an ant script during the generate-sources phase. To do this requires both changes to pom.xml and also changes to the customBuildCallbacks.xml provided in the sapphire samples.
- In your pom.xml used snippet  to launch the ant script during generate-sources
- In customBuildCallback.xml, set the default ant target to be pre.@dot 
- modify the location of ant-contrib.jar for my build environment
- Change the <safe-apt /> task  to reference classpath refs provided by maven3/tycho
- Change the <taskdef /> element  for how to find the sapphire SDK ant task
- In plugin.xml you need to add optional dependencies these bundles , so that when maven/tycho generates the classpath references it will include those two jars on the classpath. There are other ways to do this in maven/tycho that are more elegant.
<build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-antrun-plugin</artifactId> <version>1.6</version> <executions> <execution> <id>generate-sources</id> <phase>generate-sources</phase> <configuration> <target> <ant antfile="customBuildCallbacks.xml" inheritRefs="true" /> </target> </configuration> <goals> <goal>run</goal> </goals> </execution> </executions> </plugin> </plugins> </build>
<project name="Build specific targets and properties" default="pre.@dot">
<safe-apt srcdir="src" destdir=".apt_generated" preprocessdir=".apt_generated" classpathref="maven.compile.classpath" factorypathref="maven.compile.classpath" compile="false"/>
<taskdef resource="org/eclipse/sapphire/sdk/build/antlib.xml" classpathref="maven.compile.classpath"/>
 Optional dependencies in MANIFEST.MF
Alternative Using Codehaus APT Plugin
Instead of using the Ant invocation specified above, you may use the Codehaus APT plugin. This simplifies the build process a bit. To configure your project:
- Follow step  above, adding the sdk plugins as optional dependencies to your plugin manifest.
- Configure the APT plugin in the build section of your pom as follows:
<build> <plugins> <plugin> <groupId>org.codehaus.mojo</groupId> <artifactId>apt-maven-plugin</artifactId> <version>1.0-alpha-4</version> <executions> <execution> <goals> <goal>process</goal> </goals> </execution> </executions> <configuration> <factory>org.eclipse.sapphire.sdk.build.processor.internal.APFactory</factory> </configuration> </plugin> </plugins> </build>