Applied patch (FELIXM2-5) for dealing with inter-bundle transitive
dependencies.
git-svn-id: https://svn.apache.org/repos/asf/incubator/felix/trunk@465705 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/tools/maven2/maven-osgi-plugin/src/main/java/org/apache/felix/tools/maven/plugin/OsgiJarMojo.java b/tools/maven2/maven-osgi-plugin/src/main/java/org/apache/felix/tools/maven/plugin/OsgiJarMojo.java
index 1dc9b07..639ab14 100644
--- a/tools/maven2/maven-osgi-plugin/src/main/java/org/apache/felix/tools/maven/plugin/OsgiJarMojo.java
+++ b/tools/maven2/maven-osgi-plugin/src/main/java/org/apache/felix/tools/maven/plugin/OsgiJarMojo.java
@@ -629,6 +629,7 @@
*/
private void addEmbeddedJars() throws MojoExecutionException {
Set artifacts = project.getArtifacts();
+ Map artifactMap = ArtifactUtils.artifactMapByArtifactId( artifacts );
for (Iterator it = artifacts.iterator(); it.hasNext();) {
Artifact artifact = (Artifact) it.next();
@@ -639,6 +640,25 @@
if ("jar".equals(type)) {
// Do not include artifacts which are inlined
if (!(inlinedArtifacts.contains(artifact.getArtifactId()))) {
+
+ // Do not include artifacts provided by another bundle
+ boolean isProvidedByBundle = false;
+ Iterator iter = artifact.getDependencyTrail().iterator();
+ iter.next(); // skip this project
+ while ( iter.hasNext() )
+ {
+ String id = (String) iter.next();
+ Artifact element = (Artifact) artifactMap.get( id );
+ if ( element != null
+ && "osgi-bundle".equals( element.getType() ) )
+ {
+ isProvidedByBundle = true;
+ break;
+ }
+ }
+ if ( isProvidedByBundle )
+ continue;
+
File depFile = artifact.getFile();
try {
diff --git a/tools/maven2/maven-osgi-plugin/src/main/resources/META-INF/plexus/components.xml b/tools/maven2/maven-osgi-plugin/src/main/resources/META-INF/plexus/components.xml
index 317baf6..077b15b 100644
--- a/tools/maven2/maven-osgi-plugin/src/main/resources/META-INF/plexus/components.xml
+++ b/tools/maven2/maven-osgi-plugin/src/main/resources/META-INF/plexus/components.xml
@@ -30,7 +30,6 @@
<implementation>org.apache.maven.artifact.handler.DefaultArtifactHandler</implementation>
<configuration>
<type>osgi-bundle</type>
- <includesDependencies>true</includesDependencies>
<language>java</language>
<extension>jar</extension>
<addedToClasspath>true</addedToClasspath>