In Maven, including dependency via <dependency> OR importing the package inside <Import-Package>. Which one of the two should be used?
In Maven, including dependency via <dependency> OR importing the package inside <Import-Package>. Which one of the two should be used?
- 1. In my project core pom.xml, there is <Import-Package>javax.inject;version=0.0.0<Import-Package> and also following dependency. I am not clear why both are being used? I mean, if we are already including the dependency via below-mentioned method, then why do we need to use the same inside <Import-Package>?
<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>
- 2. Same scenario is happening in my project. My project A is dependent on project B, there also I have noticed that package path has been added in <Import-Package> and dependency has been added for project B in core/pom.xml of Project A. why both? Somebody please clarify this.