Although the original aim of Ant4Eclipse is to let you access project information for simple and JDT-based projects from within ant, it is also possible to build PDE-based projects (e.g. Plug-in Projects or Feature Projects). Therefore Ant4Eclipse provides a set of low-level ant tasks (e.g. executePluginProject
or executeFeature
) and some additional high-level ant macros that can be used to perform more complex tasks like building plug-in or feature projects. This tutorial gives you a step-by-step introduction in how to build PDE Plug-in and Feature projects with Ant4Eclipse.
Download example
Step 1: Setting up the example workspace
The example application used in this tutorial is an OSGi- and Swing-based application named Sherlog that allows you to analyze different kinds of log files. It consist of several (binary) bundles in a target platform and approximately twenty plug-in projects. If you want to learn more about Sherlog please visit the Sherlog website. You can download the source code as a zip file containing the workspace snapshot. After extracting the zip file your example workspace looks like in the following picture.
Step 2: Creating a build project
To build the example application, please create a new folder named org.ant4eclipse.pde.example
. Download the latest release of ant4eclipse and unzip it to org.ant4eclipse.pde.example/ant4eclipse
. After unzipping your folder should look as in the following picture.
Step 3: Create a build.xml
<?xml version="1.0"?> <project name="build.ant4eclipse" basedir="." default="build" xmlns:ant4eclipse="antlib:org.ant4eclipse"> <!-- define ant4eclipse tasks --> <taskdef uri="antlib:org.ant4eclipse" resource="org/ant4eclipse/antlib.xml" /> <!-- import the ant4eclipse pde macros --> <import file="${basedir}/ant4eclipse/macros/a4e-pde-macros.xml" /> <!-- define the workspace location here --> <property name="workspaceDirectory" value="${basedir}/.." /> <!-- define your jdk location here --> <ant4eclipse:installedJREs> <jre id="jdk16" location="R:/software/jdk/jdk16" /> </ant4eclipse:installedJREs> <!-- define the target platform location --> <ant4eclipse:targetPlatform id="my.target.platform"> <location dir="${workspaceDirectory}/target.platform/codehaus" /> <location dir="${workspaceDirectory}/target.platform/ebr" /> <location dir="${workspaceDirectory}/target.platform/equinox-3.5" /> <location dir="${workspaceDirectory}/target.platform/javakontor" /> </ant4eclipse:targetPlatform> <!-- ================================= target: build ================================= --> <target name="build"> <!-- iterate over all projects in the workspace --> <ant4eclipse:executeProjectSet workspaceDirectory="${workspaceDirectory}" allWorkspaceProjects="true"> <!-- execute the contained build steps for all plug-in projects --> <ant4eclipse:forEachProject filter="(executeProjectSet.org.eclipse.pde.PluginNature=*)"> <!--call the build plug-in project --> <buildPlugin workspaceDirectory="${workspaceDirectory}" projectname="${executeProjectSet.project.name}" targetplatformid="my.target.platform" destination="${basedir}/destination" /> </ant4eclipse:forEachProject> </ant4eclipse:executeProjectSet> </target> </project>
Step 4: Run the build
To execute the build file, simply call ant in the build directory (org.ant4eclipse.pde.example
). Don't forget to specify the ant4eclipse jar and all the provided jars as ant libraries:
ant -lib ant4eclipse/org.ant4eclipse_<version>.jar -lib ant4eclipse/libs
- Printer-friendly version
- Login to post comments