Compilation issues due to inter Dependency between bundles

selvendranr1864

07-02-2019

Hi,

I am facing compilation problems due to dependency is not getting resolved between bundles.

Interface A is in Bundle A. Abstract Class B implements A in Bundle B. Added A dependency in B pom.xml. Now Class C in Bundle C extends Class B from bundle B. Hence added bundle B dependency in Bundle C pom.xml as shown in the attached image. But the issue is I still getting compilation issue in Bundle C saying it is not able to resolve Interface A which is in Bundle A.

1686436_pastedImage_0.png

I am not clear why is it so? Bundle C extends only Class B in Bundle B. If I add Bundle A dependency in Bundle C then it is compiled correctly without any issues.

Could you guys please let me understand about this behavior. Actually our requirement is to create a modularity between bundles hence Bundle C should not have any dependency with Bundle A. Is there any other way to achieve this without adding the Bundle A dependency in Bundle C.

Thanks,

Selva

Message was edited by: Selvendran Rengasamy

Accepted Solutions (1)

Accepted Solutions (1)

selvendranr1864

18-02-2019

Hi,

By changing the dependency scope from provide to scope in Bundle B has resolved this issue. Thanks

@gauravb41175071 for helping out.

1694038_pastedImage_0.png

Thanks,

Selva

Answers (7)

Answers (7)

selvendranr1864

11-02-2019

Hi Gaurav,

Attached projects are not real time projects. I have created those to replicate the same scenario. I am building each core independently.

Regarding Export-Package,I have tried with the changes in Bundle B and Bundle C pom.xml as shown below and the same is merged to gitHub.

<plugin>

    <groupId>org.apache.felix</groupId>

    <artifactId>maven-bundle-plugin</artifactId>

    <extensions>true</extensions>

  <configuration>

    <instructions>

    <Export-Package>!com.bundleA.services.*</Export-Package>

    </instructions>

    </configuration>

  </plugin>

Checked in MANIFEST file of Bundle B, and there is no export package. It is present only in Bundle A. Could you please check and let me know on how to resolve this issue.

Bundle A MANIFEST:

1689529_pastedImage_0.png

Bundle B MANIFEST:

1689530_pastedImage_1.png

Thanks,

Selva

Gaurav-Behl

MVP

11-02-2019

I'm unable to locate the reactor project in the shared code. How do you build the projects? Is there any parent project that controls/orders these bundles?

In addition to that, I don't see the <configuration> section for maven-bundle-plugin as recommended above.

E.g.

<plugin>

   <groupId>org.apache.felix</groupId>

   <artifactId>maven-bundle-plugin</artifactId>

   <extensions>true</extensions>

  <configuration>

   <instructions>

   <Export-Package>org.foo.myproject.api</Export-Package>

   <Private-Package>org.foo.myproject.*</Private-Package>

   <Bundle-Activator>org.foo.myproject.impl1.Activator</Bundle-Activator>

   </instructions>

   </configuration>

  </plugin>

selvendranr1864

11-02-2019

Hi,

I tried blocking specific package from Bundle B, but still the compilation issue is not resolved. Create a sample bundles and added the interfaces and classes as mentioned in my above comments and uploaded in https://github.com/selvendrancq/10917778-AEM_Community_Compilation_Issues_Bundle_Dependency.git.

Could you please take a look at it and let me know if I am missing anything.

Below is the screenshot of the issue which I am getting while compiling Class C

1689236_pastedImage_1.png

Thanks,

Selva

selvendranr1864

07-02-2019

Now we are keeping the interface and implementation in the same bundle, but still the compilation issue exists.

I can see how to export packages, could you please guide me in how to explicitly block certain packages in the pom.xml

1686777_pastedImage_0.png

Thanks,

Selva

Gaurav-Behl

MVP

07-02-2019

The ideal way is to follow maven multi-module archetype.

If you want to proceed with your custom way, then you need to make sure the imports and exports for each bundle are tightened up. e.g. If interface A is in bundle A then only bundle A should export A and it should not be exported by either bundle B or bundle C to avoid transitive exports and ambiguities. You may need to block it explicitly in individual pom.xml of B & C.

smacdonald2008

07-02-2019

In a Java project that is created by a Maven Archetype project, it cleaner to try and put Interfaces and implementation classes in the same bundle. In this manner - you do not run into these issues.