////
   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

     https://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.
////

= Building a standard OSGi bundle

[NOTE]
====
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 discuss your use case on the link:https://ant.apache.org/ivy/mailing-lists.html[ivy-user] mailing list, or discuss about implementation issues or improvement you may have found, on link:https://ant.apache.org/ivy/mailing-lists.html[ant-dev].

====


'''

*TODO - WORK IN PROGRESS*

'''


This page describes how to build an OSGi(TM) bundle with Apache Ivy(TM). In this use case, we just basically want to compute a classpath to compile, optionally one for testing too, and then publish our bundle in a OSGi aware repository.

In order to produce OSGi metadata of sufficient quality and to avoid maintaining them manually, the link:http://bndtools.org/[bnd] tool will be used. The approach taken is then an "Ivy file first" approach. The dependencies will be specified in the `ivy.xml` file, the `MANIFEST.MF` being generated from the computed classpath.



== Quick setup

In few steps, we will setup a build to compile and publish an OSGi bundle.

    * download this link:../samples/standard-osgi/ivy.xml[ivy.xml], this link:../samples/standard-osgi/ivysettings.xml[ivysettings.xml], this link:../samples/standard-osgi/build.xml[build.xml], this link:../samples/standard-osgi/org.apache.ivy.sample.standard-osgi.bnd[bnd file], and put them into your project folder

    * in the `ivysettings.properties`, specify the location of the plugins folder of your Eclipse target

    * (*__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, link:https://ant.apache.org/ivy/download.cgi[download the Ivy jar] and edit the `build.xml` accordingly (see the comments at the beginning of the file)

To build the project, run:

[source]
----
ant build
----
