博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
How to use Ivy to manage your OSGi bundle dependen
阅读量:6842 次
发布时间:2019-06-26

本文共 4348 字,大约阅读时间需要 14 分钟。

  hot3.png

Intro

This tutorial provides an example of how to setup your project and manage your bundle dependencies using and . The code and config samples are based on a project, but should apply equally to any OSGi project.

The main problem with using Ivy with OSGi bundles, at the time of writing this tutorial, is that many open source project don't ship up-to-date bundles (there are a few exceptions, such as ). Also, Ivy piggy-backs off repos, which do contain some bundles, but it is still a bit ad-hoc and incomplete.

Another problem is when building an Eclipe RCP application, if you want to create your own , you either dump all the RCP SDK bundles into a directory, or you copy them over individually by hand. Both of these methods can be fine for one-off projects, but if you have many projects on the go, each with different dependencies, it all starts to get a bit messy.

This tutorial doesn't go into the detail of how to compile your bundle with Ant, it is assumed you are either using the Eclipse PDE or have already rolled your own build script.

Ant, Ivy and Bundles

The tutorial application will use the following project layout. Thecoyote-bundleandroadrunner-bundleare provided as stubs for the main project implementation, and outside the scope of this tutorial.

Thelibdirectory is used to contain the Antlib-build.xml, which manages the external bundle dependencies for the project. This script is intended as a utility script that will be imported by the two project bundles, rather than being a standalone build script.

  • acme-project
    • coyote-bundle/
      • build.xml
      • ivy.xml
      • ...
    • roadrunner-bundle/
      • build.xml
      • ivy.xml
      • ...
    • lib/
      • bundles/
      • lib-build.xml
      • ivysettings.xml

To add Ivy support, thelib-build.xmlcontains the following targets.

   
   
   
   
   
   

When new bundle dependencies are added to theivy.xmlfile, thelib-install-bundlestarget is used to build theacme-project/lib/bundlesdirectory. This directory can also be used as the root directory for a Target Platform, when developing with the Eclipse PDE.

This is where things start to get a little tricky. Ivy was not really intended to be used for OSGi bundles, because it doesn't support introspection of the bundle meta-data to determine external dependencies.

Thankfully, the Ivy tool is very flexible and transparent, and can fairly easily be made to support bundle dependencies. This is also made easier by the great work done on the , where many common open source projects are provided as bundles, and with Ivy<dependency/>snippets to add to yourivy.xmlfiles.

The following shows the content of theivysettings.xmlfile, foracme-project, which uses the , and other dependencies provided by the SpringSource repo.

   
   
       
   
       
           
       
   
       
       
       
           
           
               
               
           
                       
           
               
               
           
                       
               
               
           
       
   

Finally, we can declare our project dependencies and Ivy can start to do its thing. Here is the content of theivy.xmlfile for thecoyote-bundle:

   
   
              
       
       
       
       
       
       
       
       
       
       
   

As you can see in the above, thecoyote-bundlenow has the dependencies required to create a bundle using Spring. As powerful as Spring is, you are still probably going to need more external dependencies if you are building a 'real world' application, especially if it's based on Eclipse RCP.

At this time, there is no Ivy repo that contains up-to-date Eclipse RCP bundles (well, certainly any that I know of). So, as mentioned in the Intro, the options are to download the RCP SDK and dump all the files into theacme-project/lib/bundles, or copy them by hand if you prefer to be a little more precise.

转载于:https://my.oschina.net/yygh/blog/601541

你可能感兴趣的文章
15.4. Service-oriented architecture (SOA)
查看>>
Oracle的一些基本索引
查看>>
shell中if语句的格式以及使用
查看>>
SAP Lenoardo Machine Learning
查看>>
5 Ways to Sell SAP S/4 HANA
查看>>
JS编程建议——26:小心if嵌套的思维陷阱
查看>>
Singleton(单例)模式和Double-Checked Locking(双重检查锁定)模式
查看>>
HDOJ 1013 Digital Roots
查看>>
软硬差异定性未来发展 笔电屏幕走在分岔路口
查看>>
Java魔法堂:JVM的运行模式 (转)
查看>>
thinkPHP四种URL访问方式(二)
查看>>
HDOJ 1064Financial Management
查看>>
全局变量声明的规范化(转)
查看>>
统一用户名
查看>>
Xamarin.Android开发实践(七)
查看>>
使用InstallShield打包VS程序
查看>>
我的Android进阶之旅------&gt;Android关于HttpsURLConnection一个忽略Https证书是否正确的Https请求工具类...
查看>>
shell正则表达式匹配样例
查看>>
Sublime Text 的安装和配置
查看>>
数据库设计三大范式
查看>>