blob: 28c59c404a902c54a69a129eb724057e49263dd8 [file] [log] [blame]
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->
<html>
<head>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=ISO-8859-1">
<script type="text/javascript">var xookiConfig = {level: 1};</script>
<script type="text/javascript" src="../xooki/xooki.js"></script>
</head>
<body>
<textarea id="xooki-source">
<table class="notice">
<tr>
<td style="vertical-align: top"><img src="../images/warning.png" style="float:left;" /></td>
<td>
Note that this feature is considered as <b>experimental</b>. 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 <a href="http://ant.apache.org/ivy/mailing-lists.html">ivy-user</a> mailing list, or discuss about implementation issues or improvement you may have found on <a href="http://ant.apache.org/ivy/mailing-lists.html">ant-dev</a>.
</td>
</tr>
</table>
This page describes how to build an Eclipse&#153; plugin with Apache Ivy&#153; and its OSGi&#153; capabilities.
<h1>Quick setup</h1>
In few steps, we will setup a build to compile and package an Eclipse plugin.
<ol>
<li>download this <a href="../samples/eclipse-plugin/ivy.xml">ivy.xml<a>, this <a href="../samples/eclipse-plugin/ivysettings.xml">ivysettings.xml</a>, this <a href="../samples/eclipse-plugin/ivysettings.properties">ivysettings.properties</a>, this <a href="../samples/eclipse-plugin/build.xml">build.xml</a>, and put them into your plugin folder;</li>
<li>in the ivysettings.properties, specify the location of the plugins folder of your Eclipse target;</li>
<li>in the ivy.xml, change the symbolic name declared in the extends element;</li>
<li><i>(optional)</i> by default the build.xml is expecting the sources to be in the <tt>src</tt> folder. You may want to edit it if it is not the case</li>
<li><i>(optional)</i> if Ivy is not in Ant's classpath, get the jar of <a href="../download.html">Apache Ivy</a> and edit the build.xml accordingly (see the comments at the begining of the file)</li>
</ol>
And that's it ! Now let's use it.
First, Ivy needs to aggregate the OSGi metadata of the target platform. To do so just launch:
<code>ant buildobr</code>
You need to run that command only once. Or each time your target platform get modified.
Then to resolve and build, just run:
<code>ant build</code>
<h2>Eclipse setup</h2>
You probably have already configured your project in Eclipse via the PDE. Let's see how to chnage that and use <a href="http://ant.apache.org/ivy/ivyde/">Apache IvyDE</a>.
<ol>
<li>so first remove from your project's classpath the PDE dependencies container;</li>
<li>then right click on the ivy.xml you just added and select "Add Ivy library";</li>
<li>in the configuration panel of the IvyDE classpath container, as the settings file put '${workspace_loc:mypluginproject/ivysettings.xml}';</li>
<li>click finish and your Eclipse project should build now.</li>
</ol>
Nota Bene: to be resolved correctly Ivy is relying on the aggregated metadata of your target platform. Even if you want to only build with Eclipse, you will have to run the command <tt>ant obrindex</tt> at least one time.
<h1>Details on the setup</h1>
<h2>The repository</h2>
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 <a href="../use/buildobr.html">buildobr</a> 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 <tt>target/repo-eclipse.xml</tt>.
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 <tt>META-INF/MANIFEST.MF</tt>. So there not much dependencies specified in the ivy.xml. But as Ivy doesn't support the <tt>Bundle-Fragment</tt> 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 <tt>javac</tt> tasks. Note that <tt>javac</tt> is not aware of the OSGi metadata and is then incapable of failing to compile if private packages are accessed.
</textarea>
<script type="text/javascript">xooki.postProcess();</script>
</body>
</html>