Embed Third party dependency using bnd-maven-plugin

This post explains the use of bnd-maven-plugin to embed third party dependency 

bnd-maven-plugin

Two main instructions of bnd-maven-plugin that serves the purpose are detailed below. 

  • -conditionalpackage 
    • pick packages from respective library and copy them in the bundle. Any dependencies of those copied packages will also be copied if they match the selectors.
    • This means we need to explicitly list all the Java package names of desired dependency as part of this instruction (including its transitive dependencies)
    • More about conditionalpackage instruction from official docs - https://bnd.bndtools.org/instructions/conditionalpackage.html
  • -includeresource 
    • For including resource inline
      • -includeresource: @artifactId-version.jar!/*
    • For embedding as a jar with an entry in bundle class path
      • -includeresource: artifactId-version.jar;lib:=true
    • For several other possible combinations for including the resource, please check - https://bnd.bndtools.org/instructions/includeresource.html
With complete understanding on these two instructions from official docs + based on how we would like the dependency to be included, we can use any one of the instruction with its respective options accordingly. 

Sample plugin entry for the dependency jackson-dataformat-csv (Supports reading and writing CSV)
where ${jackson-dataformat-csv.version} in the instruction resolves to a maven property holding the artifact version (2.9.5) as defined in parent pom.xml.
  • conditionalpackage
  • includeresource inline
  • includeresource embed (as a jar with class path entry)

Other blog posts for embedding third party dependency using maven-bundle-plugin

Comments

  1. Description: Experience a realm of unmatched comfort and luxury with the best rooms in Nagercoil  at Hotel Vijayetha. Immerse yourself in a world where modern elegance meets warm hospitality, creating a haven for discerning travelers seeking the epitome of accommodation.

    Our best rooms are thoughtfully designed to provide a tranquil retreat for both business and leisure guests. From intimate singles to spacious suites, each room is adorned with tasteful decor, contemporary furnishings, and premium amenities to ensure a restful sanctuary.

    Indulge in a culinary journey at our on-site restaurant, offering exquisite flavors and culinary delights. The central location of Hotel Vijayetha provides easy access to local attractions, business centers, and transportation hubs, making it the ideal choice for those seeking convenience and style.

    Unwind in the plush surroundings, relish the warmth of attentive staff, and enjoy the convenience of modern amenities such as high-speed Wi-Fi and well-appointed bathrooms. Hotel Vijayetha's commitment to excellence guarantees that your stay in Nagercoil is marked by comfort, style, and an unparalleled level of service.

    Book the best rooms in Nagercoil at Hotel Vijayetha and elevate your travel experience to new heights. Whether you're on a business trip or exploring the city's cultural gems, our best rooms redefine the meaning of luxury and ensure a memorable stay..visit us on https://www.hotelvijayetha.com/our-rooms/.!!!

    ReplyDelete
  2. Great guide! I was struggling to understand how to use the bnd-maven-plugin for third-party dependencies. This made things much clearer.
    Snacks Distributorship
    Fume Scrubber manufacturers

    ReplyDelete
  3. Can you explain the difference between Embed-Dependency and Include-Resource in bnd-maven-plugin? I’m a bit confused.
    Warehouse Rack in India
    Industrial rack manufacturer in Noida

    ReplyDelete
  4. Thanks for this! I didn’t know you could handle dependencies this way with Maven. This will be really helpful for my project.
    Manual Dust Collector Delhi
    Centrifugal Blower in delhi

    ReplyDelete
  5. Quick question: Does embedding dependencies increase the JAR size significantly? Wondering about the trade-offs here.
    tunnel ventilation system
    long span rack in delhi

    ReplyDelete
  6. Nice post! I was looking for a simple solution for embedding libraries in OSGi bundles. bnd-maven-plugin seems perfect.
    Heavy Duty Rack in Hyderabad
    Heavy Duty Mezzanine Floor in Delhi

    ReplyDelete
  7. Good job! I liked the step-by-step instructions. I was able to get my project working within minutes.
    warehouse storage racks in delhi
    mezzanine floor noida

    ReplyDelete
  8. Suggestion: Could you cover a bit about potential issues when embedding dependencies with bnd-maven-plugin?
    modular mezzanine floor manufacturer
    heavy duty rack gurgaon

    ReplyDelete
  9. Very useful! I had no idea that I could automate this process. I’ll definitely be using this in my Maven builds.
    cable tray in delhi
    slotted angle rack in India

    ReplyDelete
  10. Love it! This blog makes understanding Maven configurations a lot easier, especially for beginners. Thanks!
    long span rack noida
    pallet rack in gurgaon

    ReplyDelete
  11. Does this plugin work well with complex multi-module projects? I'd love to see some tips on that.
    mezzanine floor ghaziabad
    office chair in gurgaon

    ReplyDelete
  12. Excellent article! Really concise and informative. Can we use bnd-maven-plugin with non-OSGi projects too?
    Franchise Event
    Distributorship Opportunities

    ReplyDelete
  13. New to Maven: How does embedding dependencies here differ from using the shade plugin?
    two tier racking system
    Tea Distributorship

    ReplyDelete
  14. Just what I needed! Thank you for explaining the Embed-Dependency syntax in detail. Made my life easier!
    Pure Lavender Oil Manufacturer in Korea
    Sparsh Bagga

    ReplyDelete
  15. Interesting approach! I usually use the assembly plugin for packaging, but this seems more straightforward for dependencies.
    fabric storage rack manufacturer
    SEO Company

    ReplyDelete
  16. Helpful read! Do you have any troubleshooting tips for when dependencies don’t embed correctly?
    strech wrapping machine delhi
    Retail Franchise

    ReplyDelete
  17. One question: Is there any performance impact at runtime when dependencies are embedded this way?
    Centrifugal Blowers
    Pallet rack manufacturer in India

    ReplyDelete

Post a Comment

Popular posts from this blog

Embedding Third party dependency/OSGi bundle in AEM application hosted in AEMasCS

OSGI Factory Configuration implementation