Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Tasty Recipes for OSGi Bundles


Published on

Introduction to the Eclipse Bundle Recipe project and how to generate OSGi bundles for any library in Maven Central or in a Maven repository behind corporate walls.

Published in: Software
  • Be the first to comment

  • Be the first to like this

Tasty Recipes for OSGi Bundles

  1. 1. Tasty Recipes for OSGi Bundles Gunnar Wagenknecht (@guw)
  2. 2. – Someone asking for help! „I’m trying to use this library from Maven. It doesn’t work in OSGi. How can I make it work?“
  3. 3. The
 Eclipse Bundle Recipe
  4. 4. – „The EBR project provides a library of templates and tools that can be used to create bundles for open source projects.“
  5. 5. How it works
  6. 6. Prerequisites git clone ... git://
  7. 7. Create a Recipe mvn ebr:create-recipe 
  8. 8. osgi.bnd Define what packages to export and import and how Make use of rules/macros to simplify your life
  9. 9. osgi.bnd package-version=${version;===;${Bundle-Version}} Export-Package: 
 *;version="${package-version}" Import-Package: 
  10. 10. Build the Bundle mvn clean package
  11. 11. Result • OSGi Bundle • Ready for localization • License information • Eclipse Source Bundle • Eclipse p2 meta data • Eclipse about files
  12. 12. Tips &Tricks
  13. 13. Regular Dependencies package-version=${version;===;${Bundle-Version}} 
 javax-ws-version=2.3 Export-Package: 
 ... Import-Package:*; 
 *;resolution:=optional becomes: [2.3,3)
  14. 14. Internal Dependencies package-version=${version;===;${Bundle-Version}} Export-Package: 
 ... Import-Package: 
 *;resolution:=optional becomes: [1.1.3,1.2) becomes: [1.1.3,1.1.4)
  15. 15. Re-use jersey-common-exports= 
 *.internal*;... Export-Package: ${jersey-common-exports} jersey-common-imports=*;version="[2.0,3)", 
 *;resolution:=optional Import-Package: ${jersey-common-imports}
  16. 16. Include & Override -include: ~../jersey-common/osgi.bnd Import-Package: 
  17. 17. Partial Bundles <project xmlns="" ...> <properties> <!-- only include the org.slf4j.impl package --> <recipe.includes>org/slf4j/impl/*.*</recipe.includes> </properties> </project>
  18. 18. Partial Bundles <project xmlns="" ...> <properties> <!-- exclude the org.slf4j.impl package --> <recipe.excludes>org/slf4j/impl/*.*</recipe.excludes> </properties> </project>
  19. 19. SpecialVersions <project xmlns="" ...> <dependencies> <dependency> <groupId>org.glassfish.hk2</groupId> <artifactId>hk2-api</artifactId> <version>2.4.0-b07</version> </dependency> </dependencies> <properties> <!-- the HK2 version suffix --> <hk2.version.suffix>b07</hk2.version.suffix> <!-- add special qualifier for HK2 --> <recipe.qualifier.format> '${hk2.version.suffix}-v’yyyyMMdd-HHmm </recipe.qualifier.format> </properties> </project> osgi.bnd: package-version=${version;===;${Bundle-Version}}.${hk2.version.suffix}
  20. 20. EBR 
  21. 21. Bundle Symbolic Name • Always add “.ebr”! • Helps identifying source of bundle easier.
  22. 22. MY_EBR_BUNDLES_GROUP • The Maven group identifier of recipies is just a placeholder. • The EBR project will not publish recipies to a Maven repository. • But you can!
  23. 23. No Downloads • EBR produces only recipies! • There are no bundles to download. • This is due to legal reasons.
  24. 24. EBR 
 On Premise
  25. 25. Prerequisites git clone replace group id build recipies build p2 repository
  26. 26. Contribute to EBR • Clone the Git repository • Create recipies • Push a Gerrit Review or submit a pull request
  27. 27. Get support for creating & contributing recipes!