In Maven, including dependency via <dependency> OR importing the package inside <Import-Package>. Which one of the two should be used?
<configuration>
<instructions>
<Import-Package>
javax.inject;version=0.0.0,
org.xbc.web.core.service;version=0.0.0,
*
</Import-Package>
<Sling-Model-Packages>
org.xbc.core
</Sling-Model-Packages>
</instructions>
</configuration>
Above mentioned packages are duplicated in below dependencies
<dependency>
<groupId>javax.inject</groupId>
<artifactId>javax.inject</artifactId>
<version>1</version>
</dependency>
<dependency>
<groupId>org.xbc.web</groupId>
<artifactId>fullton-project.core</artifactId>
<scope>provided</scope>
</dependency>
Solved! Go to Solution.
Views
Replies
Total Likes
At a high level-
Import-Package is for importing available dependencies when the state of osgi bundle is changed during its lifecycle in the container (Felix), Version 0.0.0 indicates that it should start from the lowest version, pick whatever version is available as mentioned in manifest and satisfy the dependency at runtime in Felix.
The packages mentioned here may/may not be available/packaged within the bundle but may be available/registered in Felix
You may choose to control it at a granular level that import * but not one package or something similar to that. import-package is required to create the manifest file properties
Dependency on other hand works with dependency management to download the packages in local repo/nexus etc. and to mark that a particular bundle should be applied at specific scope mentioned inside <scope>. It defines the scopes of dependent bundles and which can again be superseded with import-package configuration to allow/deny the packaging of that bundle
Views
Replies
Total Likes
Go through this once. Apache Felix - Apache Felix Maven Bundle Plugin (BND)
It have list of all the tags and details
Views
Replies
Total Likes
Hi Hemant - I have gone through the link. But don't understand why javax.inject, is defined under the import-package tag and in dependency-tag both.
Views
Replies
Total Likes
<import-package>:import packages means including a existing jar. you can include the third party jar using it. suppose you have a another different project (like web service calls) in your complete project. then you can include it using import packages. plugins generates the Import-Package bundle manifest header based on the contents of the bundle.
<dependency> : It downloads the jar at run time.
Views
Replies
Total Likes
javax.inject is for dependency injection. whatever dependencies that you download, you can inject and use via import-package.
consider the example of sling models , check a sample sling model and see the use of javax.inject
Views
Replies
Total Likes
my only point is whatever we include in <import-pakage> tag, Can't we just include a dependency for that tag like below. What is the harm? what is the benefit of <import-pakage> tag providing over a dependency tag?
<dependency>
<groupId>javax.inject</groupId>
<artifactId>javax.inject</artifactId>
<version>1</version>
</dependency>
<dependency>
<groupId>org.xbc.web</groupId>
<artifactId>fullton-project.core</artifactId>
<scope>provided</scope>
</dependency>
Views
Replies
Total Likes
At a high level-
Import-Package is for importing available dependencies when the state of osgi bundle is changed during its lifecycle in the container (Felix), Version 0.0.0 indicates that it should start from the lowest version, pick whatever version is available as mentioned in manifest and satisfy the dependency at runtime in Felix.
The packages mentioned here may/may not be available/packaged within the bundle but may be available/registered in Felix
You may choose to control it at a granular level that import * but not one package or something similar to that. import-package is required to create the manifest file properties
Dependency on other hand works with dependency management to download the packages in local repo/nexus etc. and to mark that a particular bundle should be applied at specific scope mentioned inside <scope>. It defines the scopes of dependent bundles and which can again be superseded with import-package configuration to allow/deny the packaging of that bundle
Views
Replies
Total Likes