Hi I am using Old archetype which is using maven-bundle-plugin as below.
I want to convert this into bnd-maven-plugin which is part of new archetype .How to convert Import packages,Export Packages and embed dependency for bnd-maven-plugin.we are getting error
in start level 20 but no bundle is exporting these for that start level on running aem-analyzer plugin
Views
Replies
Total Likes
hi @Sb2512,
You can check the sample plugin here. You can also refer to the PR of ACS Commons, where a similar transition was done: https://github.com/Adobe-Consulting-Services/acs-aem-commons/pull/2761
Another useful article is https://wcm-io.atlassian.net/wiki/spaces/WCMIO/pages/1267040260/How+to+switch+from+maven-bundle-plug...
Bnd-maven-plugin : https://github.com/bndtools/bnd/blob/master/maven-plugins/bnd-maven-plugin/README.md
Hi @giuseppebag ,
Thanks for the reply.
What to use in case of Embed Dependency or if we want to use Third Party jar to add it in the OSGI bundle.
The above example provide some hint but not 100% sure how we can use for my Use case.
Views
Replies
Total Likes
Hi @Sb2512 ,
Try below solution:
1. Replace maven-bundle-plugin with bnd-maven-plugin
In your pom.xml:
<plugin>
<groupId>biz.aQute.bnd</groupId>
<artifactId>bnd-maven-plugin</artifactId>
<version>6.4.0</version> <!-- or latest -->
<executions>
<execution>
<goals>
<goal>bnd-process</goal>
</goals>
</execution>
</executions>
</plugin>
2. Add bnd.bnd file in the same module (typically under /core)
Create a bnd.bnd file (in the same directory as your pom.xml) with the following content:
Bundle-Name: My Bundle
Bundle-SymbolicName: com.mycompany.core
Bundle-Version: 1.0.0
# Import Packages
Import-Package: \
!org.codehaus.groovy.*,\
javax.inject;version=0.0.0,\
javax.annotation;version=0.0.0,\
!org.bouncycastle.*,\
!javax.cache.*,\
*
# Export Packages
Export-Package: \
com.akamai.edgegrid.signer.*
# Embedded Dependencies (include-dependency is bnd syntax)
-includeresource: \
@flying-saucer-core.jar,\
@flying-saucer-pdf.jar,\
@jsoup.jar,\
@javaslang.jar,\
@javaslang-jackson.jar
# Make sure they are included from dependencies
-runbundles: \
flying-saucer-core,\
flying-saucer-pdf,\
jsoup,\
javaslang,\
javaslang-jackson
3. Add the dependencies in pom.xml
Make sure the JARs to embed are added as dependencies with scope=compile:
<dependencies>
<dependency>
<groupId>org.jsoup</groupId>
<artifactId>jsoup</artifactId>
<version>1.13.1</version>
</dependency>
<dependency>
<groupId>org.xhtmlrenderer</groupId>
<artifactId>flying-saucer-core</artifactId>
<version>9.1.20</version>
</dependency>
<dependency>
<groupId>org.xhtmlrenderer</groupId>
<artifactId>flying-saucer-pdf</artifactId>
<version>9.1.20</version>
</dependency>
<dependency>
<groupId>io.vavr</groupId>
<artifactId>vavr</artifactId>
<version>0.10.3</version>
</dependency>
<dependency>
<groupId>io.vavr</groupId>
<artifactId>vavr-jackson</artifactId>
<version>0.10.3</version>
</dependency>
</dependencies>
4. Embed JARs in the OSGi bundle using bnd-maven-plugin
Ensure the bnd.bnd file points to where the dependencies are built (they must be in your local Maven repo or project build path).
You can also use -buildpath or configure -includeresource with ${@} to automate:
-includeresource: @${@}
But most commonly, just use @jar-name.jar or Maven coordinates if scripting with BND workspace.
Build your bundle:
mvn clean install
Then use:
unzip -l target/yourbundle.jar
You’ll see embedded JARs inside the bundle, and exports will reflect only what you declared.
Note:
Don't forget to remove maven-bundle-plugin from the old pom.xml.
The bnd.bnd file must reside in the same module as the bundle you're building.
The dependencies are pulled from the build path, so Maven must resolve them correctly.
Regards,
Amit
Just checking in — were you able to resolve your issue?
We’d love to hear how things worked out. If the suggestions above helped, marking a response as correct can guide others with similar questions. And if you found another solution, feel free to share it — your insights could really benefit the community. Thanks again for being part of the conversation!
Views
Replies
Total Likes
Views
Likes
Replies
Views
Likes
Replies