Is it possible to have multiple OSGI bundles in 1 project? If yes, how? | Community
Skip to main content
jayv25585659
Level 8
May 29, 2022
Solved

Is it possible to have multiple OSGI bundles in 1 project? If yes, how?

  • May 29, 2022
  • 2 replies
  • 852 views

As above.

 

as an example: I want to have  2 bundles ((com.myhost.www.core1 and com.myhost.www.core2) in my project. This means if I go to /system/console/bundles, both core1 and core2 are listed.

-------

from what I understand, the OSGI bundle is basically the jar version of the core folder.

 

Thanks

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by SantoshSai

Hi @jayv25585659 

Yes, it is possible to have multiple OSGi bundles in one project. Kindly follow below steps to achieve as per your above requirement

1. Typically create separate maven projects next to the core maven project
                                                      OR
   Copy core module paste parallel to core and rename to core2, do change in pom.xml accordingly.

<parent> 
<groupId>training</groupId>
<artifactId>training</artifactId>
<version>1.0-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<artifactId>com.myhost.www.core2</artifactId>
<packaging>bundle</packaging>
<name>AEM Training OSGI - Core 2</name>
<description>Core bundle for training</description>

2.Embed it to ui.apps pom.xml 

<embedded>
<groupId>training</groupId>
<artifactId>com.myhost.www.core2</artifactId>
<target>/apps/training/install</target>
</embedded>

3. Add dependency to ui.apps pom.xml 

<dependency>
<groupId>training</groupId>
<artifactId>com.myhost.www.core2</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>


Github Reference: https://github.com/sansai2011/training 

 

To understand in details, how can it be done please visit my blog here https://www.techinnovia.com/package-import-and-export/ where I have created multiple bundles in one single project as shown in below picture.













Also would suggest you to go through this https://youtu.be/flIp_1o4Nt0 video clip (belongs to same article) for better understanding.

Hope that helps you!

Regards,
Santosh

2 replies

SantoshSai
Community Advisor
SantoshSaiCommunity AdvisorAccepted solution
Community Advisor
May 29, 2022

Hi @jayv25585659 

Yes, it is possible to have multiple OSGi bundles in one project. Kindly follow below steps to achieve as per your above requirement

1. Typically create separate maven projects next to the core maven project
                                                      OR
   Copy core module paste parallel to core and rename to core2, do change in pom.xml accordingly.

<parent> 
<groupId>training</groupId>
<artifactId>training</artifactId>
<version>1.0-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<artifactId>com.myhost.www.core2</artifactId>
<packaging>bundle</packaging>
<name>AEM Training OSGI - Core 2</name>
<description>Core bundle for training</description>

2.Embed it to ui.apps pom.xml 

<embedded>
<groupId>training</groupId>
<artifactId>com.myhost.www.core2</artifactId>
<target>/apps/training/install</target>
</embedded>

3. Add dependency to ui.apps pom.xml 

<dependency>
<groupId>training</groupId>
<artifactId>com.myhost.www.core2</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>


Github Reference: https://github.com/sansai2011/training 

 

To understand in details, how can it be done please visit my blog here https://www.techinnovia.com/package-import-and-export/ where I have created multiple bundles in one single project as shown in below picture.













Also would suggest you to go through this https://youtu.be/flIp_1o4Nt0 video clip (belongs to same article) for better understanding.

Hope that helps you!

Regards,
Santosh

Santosh Sai
sunil_kumar_
Level 5
May 29, 2022

@jayv25585659 
Yes, You can have bundles with same Symbolic Name and different versions. You can have in parallel. But what is your use case. What are you trying to achieve with 2 bundles.