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.
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
Solved! Go to Solution.
Views
Replies
Total Likes
Hi,
By changing the dependency scope from provide to scope in Bundle B has resolved this issue. Thanks
Thanks,
Selva
Views
Replies
Total Likes
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.
Views
Replies
Total Likes
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.
Views
Replies
Total Likes
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
Thanks,
Selva
Views
Replies
Total Likes
To deny a package, use !<package_name>
Views
Replies
Total Likes
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
Thanks,
Selva
Views
Replies
Total Likes
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>
Views
Replies
Total Likes
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:
Bundle B MANIFEST:
Thanks,
Selva
Views
Replies
Total Likes
Hi,
By changing the dependency scope from provide to scope in Bundle B has resolved this issue. Thanks
Thanks,
Selva
Views
Replies
Total Likes
Views
Likes
Replies
Views
Likes
Replies