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

= OSGi

Since Apache Ivy(TM) 2.3, some support for OSGi(TM) dependency management has been introduced.



WARNING: 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].


So with a standard ivy.xml, you can express some dependency on some OSGi bundle and every of their transitive dependencies will be resolved. You can also declare in your ivy.xml some OSGi dependency, like a `Require-Bundle`, an `Import-Package` or an `Import-Service`, miming an OSGi MANIFEST.MF.


== Note on the implementation


With OSGi we can declare different kind of capabilities of a bundle which can match different kind of requirements of some other bundles (`Require-Bundle`/`Bundle-SymbolicName`, `Import-Package`/`Export-Package`, `Import-Service`/`Export-Service`). In Ivy we only have one kind of requirement and one kind of capability: the symbolic name of the bundle. Due to that restriction Ivy may not resolve exactly how we would expect with OSGi.  The runtime of Ivy won't be as smart as a pure OSGi dependency manager. But we think that the mapping is working for most of the use cases involving OSGi dependencies management.

Details on the mapping of the OSGi dependency model into Ivy's one can be found in this link:osgi/osgi-mapping{outfilesuffix}[page].


== Repository descriptor based resolvers


Since the nature of the OSGi dependencies, resolving against a repository cannot be started before acquiring the metadata of every bundle of the repository. To resolve an `Import-Package`, Ivy has to find every bundle which has the proper `Export-Package`. So unlike the usual Ivy resolvers, the OSGi capable ones have to get the descriptor before starting a resolve.

The descriptor probably being not instantly downloaded, the descriptor is put in cache. (FIXME not implemented)


== Use cases


Here are different use case of using the OSGi capabilities of Ivy:


* link:osgi/eclipse-plugin{outfilesuffix}[building an Eclipse(TM) plugin] +

* link:osgi/standard-osgi{outfilesuffix}[building a standard OSGi bundle] +

* link:osgi/target-platform{outfilesuffix}[managing a "target" platform] +
