- Documentation (2.3.0)
- Release Notes
- Tutorials
- Reference
- Introduction
- Settings Files
- Ivy Files
- Ant Tasks
- Using standalone
- OSGi
- Developer doc
Building an Eclipse plugin
Note that this feature is considered as experimental. It should work with simple configuration but may not in complex ones. If you have any issue with that feature, you are welcomed to come discussed your use case on the ivy-user mailing list, or discuss about implementation issues or improvement you may have found on ant-dev. |
Quick setup
In few steps, we will setup a build to compile and package an Eclipse plugin.- download this ivy.xml, this ivysettings.xml, this ivysettings.properties, this build.xml, and put them into your plugin folder;
- in the ivysettings.properties, specify the location of the plugins folder of your Eclipse target;
- in the ivy.xml, change the symbolic name declared in the extends element;
- (optional) by default the build.xml is expecting the sources to be in the src folder. You may want to edit it if it is not the case
- (optional) if Ivy is not in Ant's classpath, get the jar of Apache Ivy and edit the build.xml accordingly (see the comments at the begining of the file)
First, Ivy needs to aggregate the OSGi metadata of the target platform. To do so just launch:
ant buildobrYou need to run that command only once. Or each time your target platform get modified.
Then to resolve and build, just run:
ant build
Eclipse setup
You probably have already configured your project in Eclipse via the PDE. Let's see how to chnage that and use Apache IvyDE.- so first remove from your project's classpath the PDE dependencies container;
- then right click on the ivy.xml you just added and select "Add Ivy library";
- in the configuration panel of the IvyDE classpath container, as the settings file put '${workspace_loc:mypluginproject/ivysettings.xml}';
- click finish and your Eclipse project should build now.
Details on the setup
The repository
When building an Eclipse plugin, we are relying on a "target platform", the Eclipse installation we want our plugin to be eventually installed into. For Ivy, this will represent the repository of artifacts.Ivy needs an aggragation of the OSGi metadata in order to resolve a such repository. The Ant task buildobr build a OBR (OSGi Bundle Repository) descriptor file from a set of OSGi bundles. So here we are using this Ant task to gather OSGi metadata from the Eclipse plugins in the "target platform". In the above exemple, the file is build in target/repo-eclipse.xml.
The plugin to be build has then a ivy.xml file describing its depedencies to be used by Ivy. Since the actual depedencies are in the MANIFEST.MF file, in the ivy.xml file we specify that it extends META-INF/MANIFEST.MF. So there not much dependencies specified in the ivy.xml. But as Ivy doesn't support the Bundle-Fragment OSGi feature, the ivy.xml can help specify the missing dependencies.
Having this setup, it is then a standard Ant+Ivy build. Ivy computes the classpath to be then used by the javac tasks. Note that javac is not aware of the OSGi metadata and is then incapable of failing to compile if private packages are accessed.