You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@felix.apache.org by gn...@apache.org on 2015/07/09 21:45:10 UTC

svn commit: r1690153 - in /felix/trunk/bundleplugin: ./ src/main/java/org/apache/felix/bundleplugin/ src/test/java/org/apache/felix/bundleplugin/

Author: gnodet
Date: Thu Jul  9 19:45:09 2015
New Revision: 1690153

URL: http://svn.apache.org/r1690153
Log:
[FELIX-3565] Embed-Transitive leaks transitive dependencies of excluded artifacts

Modified:
    felix/trunk/bundleplugin/pom.xml
    felix/trunk/bundleplugin/src/main/java/org/apache/felix/bundleplugin/AbstractDependencyFilter.java
    felix/trunk/bundleplugin/src/main/java/org/apache/felix/bundleplugin/AntPlugin.java
    felix/trunk/bundleplugin/src/main/java/org/apache/felix/bundleplugin/BundleAllPlugin.java
    felix/trunk/bundleplugin/src/main/java/org/apache/felix/bundleplugin/BundlePlugin.java
    felix/trunk/bundleplugin/src/main/java/org/apache/felix/bundleplugin/DependencyEmbedder.java
    felix/trunk/bundleplugin/src/main/java/org/apache/felix/bundleplugin/DependencyExcluder.java
    felix/trunk/bundleplugin/src/main/java/org/apache/felix/bundleplugin/InstructionsPlugin.java
    felix/trunk/bundleplugin/src/main/java/org/apache/felix/bundleplugin/ManifestPlugin.java
    felix/trunk/bundleplugin/src/test/java/org/apache/felix/bundleplugin/AbstractBundlePluginTest.java
    felix/trunk/bundleplugin/src/test/java/org/apache/felix/bundleplugin/BlueprintComponentTest.java
    felix/trunk/bundleplugin/src/test/java/org/apache/felix/bundleplugin/BundleAllPluginTest.java
    felix/trunk/bundleplugin/src/test/java/org/apache/felix/bundleplugin/BundlePluginTest.java

Modified: felix/trunk/bundleplugin/pom.xml
URL: http://svn.apache.org/viewvc/felix/trunk/bundleplugin/pom.xml?rev=1690153&r1=1690152&r2=1690153&view=diff
==============================================================================
--- felix/trunk/bundleplugin/pom.xml (original)
+++ felix/trunk/bundleplugin/pom.xml Thu Jul  9 19:45:09 2015
@@ -142,7 +142,7 @@
   <dependency>
    <groupId>org.apache.maven</groupId>
    <artifactId>maven-core</artifactId>
-   <version>2.0.7</version>
+   <version>2.2.0</version>
   </dependency>
   <dependency>
    <groupId>org.apache.maven</groupId>

Modified: felix/trunk/bundleplugin/src/main/java/org/apache/felix/bundleplugin/AbstractDependencyFilter.java
URL: http://svn.apache.org/viewvc/felix/trunk/bundleplugin/src/main/java/org/apache/felix/bundleplugin/AbstractDependencyFilter.java?rev=1690153&r1=1690152&r2=1690153&view=diff
==============================================================================
--- felix/trunk/bundleplugin/src/main/java/org/apache/felix/bundleplugin/AbstractDependencyFilter.java (original)
+++ felix/trunk/bundleplugin/src/main/java/org/apache/felix/bundleplugin/AbstractDependencyFilter.java Thu Jul  9 19:45:09 2015
@@ -22,15 +22,26 @@ package org.apache.felix.bundleplugin;
 import java.util.Collection;
 import java.util.Iterator;
 import java.util.LinkedHashSet;
+import java.util.List;
 import java.util.Map;
+import java.util.Set;
 import java.util.regex.Pattern;
 
 import org.apache.maven.artifact.Artifact;
+import org.apache.maven.artifact.resolver.filter.AndArtifactFilter;
+import org.apache.maven.artifact.resolver.filter.ArtifactFilter;
 import org.apache.maven.plugin.MojoExecutionException;
 
 import aQute.bnd.header.Attrs;
 import aQute.bnd.header.OSGiHeader;
 import aQute.bnd.osgi.Instruction;
+import org.apache.maven.shared.dependency.graph.DependencyNode;
+import org.apache.maven.shared.dependency.graph.filter.ArtifactDependencyNodeFilter;
+import org.apache.maven.shared.dependency.graph.filter.DependencyNodeFilter;
+import org.apache.maven.shared.dependency.graph.traversal.BuildingDependencyNodeVisitor;
+import org.apache.maven.shared.dependency.graph.traversal.CollectingDependencyNodeVisitor;
+import org.apache.maven.shared.dependency.graph.traversal.DependencyNodeVisitor;
+import org.apache.maven.shared.dependency.graph.traversal.FilteringDependencyNodeVisitor;
 
 
 /**
@@ -43,17 +54,22 @@ public abstract class AbstractDependency
     private static final Pattern MISSING_KEY_PATTERN = Pattern.compile( "(^|,)\\p{Blank}*(!)?\\p{Blank}*([a-zA-Z]+=)" );
 
     /**
+     * Dependency Graph.
+     */
+    private final DependencyNode m_dependencyGraph;
+    /**
      * Dependency artifacts.
      */
     private final Collection<Artifact> m_dependencyArtifacts;
 
 
-    public AbstractDependencyFilter( Collection<Artifact> dependencyArtifacts )
+    public AbstractDependencyFilter( DependencyNode dependencyGraph, Collection<Artifact> dependencyArtifacts )
     {
+        m_dependencyGraph = dependencyGraph;
         m_dependencyArtifacts = dependencyArtifacts;
     }
 
-    private static abstract class DependencyFilter
+    private static abstract class DependencyFilter implements ArtifactFilter
     {
         private final Instruction m_instruction;
         private final String m_defaultValue;
@@ -71,21 +87,7 @@ public abstract class AbstractDependency
             m_defaultValue = defaultValue;
         }
 
-
-        public void filter( Collection<Artifact> dependencies )
-        {
-            for ( Iterator<Artifact> i = dependencies.iterator(); i.hasNext(); )
-            {
-                if ( false == matches( i.next() ) )
-                {
-                    i.remove();
-                }
-            }
-        }
-
-
-        abstract boolean matches( Artifact dependency );
-
+        public abstract boolean include( Artifact dependency );
 
         boolean matches( String text )
         {
@@ -104,6 +106,26 @@ public abstract class AbstractDependency
         }
     }
 
+    private static class TrimmingDependencyNodeFilter implements DependencyNodeFilter
+    {
+        private DependencyNodeFilter dependencyNodeFilter;
+
+        public TrimmingDependencyNodeFilter( DependencyNodeFilter dependencyNodeFilter ) 
+        {
+            this.dependencyNodeFilter = dependencyNodeFilter;
+        }
+        
+        public boolean accept( DependencyNode node )
+        {
+            boolean accepted = dependencyNodeFilter.accept( node );
+            if( !accepted )
+            {
+                List<DependencyNode> children = node.getChildren();
+                children.clear();
+            }
+            return accepted;
+        }
+    }
 
     protected final void processInstructions( String header ) throws MojoExecutionException
     {
@@ -111,7 +133,6 @@ public abstract class AbstractDependency
 
         Collection<Artifact> availableDependencies = new LinkedHashSet<Artifact>( m_dependencyArtifacts );
 
-        DependencyFilter filter;
         for ( Iterator<Map.Entry<String,Attrs>> clauseIterator = instructions.entrySet().iterator(); clauseIterator.hasNext(); )
         {
             String inline = "false";
@@ -128,22 +149,24 @@ public abstract class AbstractDependency
                 primaryKey = primaryKey.substring( 1 );
             }
 
+            final AndArtifactFilter andArtifactFilter = new AndArtifactFilter();
             if ( !"*".equals( primaryKey ) )
             {
-                filter = new DependencyFilter( primaryKey )
+                ArtifactFilter filter = new DependencyFilter( primaryKey )
                 {
                     @Override
-                    boolean matches( Artifact dependency )
+                    public boolean include( Artifact dependency )
                     {
                         return super.matches( dependency.getArtifactId() );
                     }
                 };
                 // FILTER ON MAIN CLAUSE
-                filter.filter( filteredDependencies );
+                andArtifactFilter.add(filter);
             }
 
             for ( Iterator<Map.Entry<String,String>> attrIterator = clause.getValue().entrySet().iterator(); attrIterator.hasNext(); )
             {
+                final ArtifactFilter filter;
                 // ATTRIBUTE: KEY --> REGEXP
                 Map.Entry<String,String> attr = attrIterator.next();
                 if ( "groupId".equals( attr.getKey() ) )
@@ -151,7 +174,7 @@ public abstract class AbstractDependency
                     filter = new DependencyFilter( attr.getValue() )
                     {
                         @Override
-                        boolean matches( Artifact dependency )
+                        public boolean include( Artifact dependency )
                         {
                             return super.matches( dependency.getGroupId() );
                         }
@@ -162,7 +185,7 @@ public abstract class AbstractDependency
                     filter = new DependencyFilter( attr.getValue() )
                     {
                         @Override
-                        boolean matches( Artifact dependency )
+                        public boolean include( Artifact dependency )
                         {
                             return super.matches( dependency.getArtifactId() );
                         }
@@ -173,7 +196,7 @@ public abstract class AbstractDependency
                     filter = new DependencyFilter( attr.getValue() )
                     {
                         @Override
-                        boolean matches( Artifact dependency )
+                        public boolean include( Artifact dependency )
                         {
                             try
                             {
@@ -192,7 +215,7 @@ public abstract class AbstractDependency
                     filter = new DependencyFilter( attr.getValue(), "compile" )
                     {
                         @Override
-                        boolean matches( Artifact dependency )
+                        public boolean include( Artifact dependency )
                         {
                             return super.matches( dependency.getScope() );
                         }
@@ -203,7 +226,7 @@ public abstract class AbstractDependency
                     filter = new DependencyFilter( attr.getValue(), "jar" )
                     {
                         @Override
-                        boolean matches( Artifact dependency )
+                        public boolean include( Artifact dependency )
                         {
                             return super.matches( dependency.getType() );
                         }
@@ -214,7 +237,7 @@ public abstract class AbstractDependency
                     filter = new DependencyFilter( attr.getValue() )
                     {
                         @Override
-                        boolean matches( Artifact dependency )
+                        public boolean include( Artifact dependency )
                         {
                             return super.matches( dependency.getClassifier() );
                         }
@@ -225,7 +248,7 @@ public abstract class AbstractDependency
                     filter = new DependencyFilter( attr.getValue(), "false" )
                     {
                         @Override
-                        boolean matches( Artifact dependency )
+                        public boolean include( Artifact dependency )
                         {
                             return super.matches( "" + dependency.isOptional() );
                         }
@@ -242,9 +265,11 @@ public abstract class AbstractDependency
                 }
 
                 // FILTER ON EACH ATTRIBUTE
-                filter.filter( filteredDependencies );
+                andArtifactFilter.add( filter );
             }
 
+            filteredDependencies( andArtifactFilter, filteredDependencies );
+
             if ( isNegative )
             {
                 // negative clauses reduce the set of available artifacts
@@ -265,4 +290,43 @@ public abstract class AbstractDependency
 
 
     protected abstract void processDependencies( Collection<Artifact> dependencies, String inline );
+
+    private void filteredDependencies( final ArtifactFilter artifactFilter, Collection<Artifact> filteredDependencies )
+    {
+        CollectingDependencyNodeVisitor collectingDependencyNodeVisitor = new CollectingDependencyNodeVisitor();
+        final Artifact rootArtifact = m_dependencyGraph.getArtifact();
+        ArtifactFilter filter = new ArtifactFilter()
+        {
+
+
+            public boolean include( Artifact artifact )
+            {
+                return artifact.equals( rootArtifact ) || artifactFilter.include( artifact );
+            }
+
+
+        };
+        DependencyNodeFilter dependencyNodeFilter = new ArtifactDependencyNodeFilter( filter );
+        dependencyNodeFilter = new TrimmingDependencyNodeFilter( dependencyNodeFilter );
+        DependencyNodeVisitor dependencyNodeVisitor =
+                new FilteringDependencyNodeVisitor( collectingDependencyNodeVisitor, dependencyNodeFilter );
+        dependencyNodeVisitor = new BuildingDependencyNodeVisitor( dependencyNodeVisitor );
+        m_dependencyGraph.accept( dependencyNodeVisitor );
+        List<DependencyNode> dependencyNodes = collectingDependencyNodeVisitor.getNodes();
+        Set<String> ids = new LinkedHashSet<String>( dependencyNodes.size() );
+        for( DependencyNode dependencyNode : dependencyNodes ) {
+            Artifact artifact = dependencyNode.getArtifact();
+            String id = artifact.getId();
+            ids.add(id);
+        }
+        for (Iterator<Artifact> iterator = filteredDependencies.iterator(); iterator.hasNext();)
+        {
+            Artifact artifact = iterator.next();
+            String id = artifact.getId();
+            if (!ids.contains(id))
+            {
+                iterator.remove();
+            }
+        }
+    }
 }

Modified: felix/trunk/bundleplugin/src/main/java/org/apache/felix/bundleplugin/AntPlugin.java
URL: http://svn.apache.org/viewvc/felix/trunk/bundleplugin/src/main/java/org/apache/felix/bundleplugin/AntPlugin.java?rev=1690153&r1=1690152&r2=1690153&view=diff
==============================================================================
--- felix/trunk/bundleplugin/src/main/java/org/apache/felix/bundleplugin/AntPlugin.java (original)
+++ felix/trunk/bundleplugin/src/main/java/org/apache/felix/bundleplugin/AntPlugin.java Thu Jul  9 19:45:09 2015
@@ -29,6 +29,7 @@ import org.apache.maven.plugin.MojoExecu
 import org.apache.maven.plugins.annotations.Mojo;
 import org.apache.maven.plugins.annotations.ResolutionScope;
 import org.apache.maven.project.MavenProject;
+import org.apache.maven.shared.dependency.graph.DependencyNode;
 import org.codehaus.plexus.util.FileUtils;
 import org.codehaus.plexus.util.IOUtil;
 import org.codehaus.plexus.util.StringUtils;
@@ -49,7 +50,7 @@ public class AntPlugin extends BundlePlu
 
 
     @Override
-    protected void execute( MavenProject currentProject, Map<String, String> originalInstructions, Properties properties,
+    protected void execute( MavenProject currentProject, DependencyNode dependencyGraph, Map<String, String> originalInstructions, Properties properties,
         Jar[] classpath ) throws MojoExecutionException
     {
         final String artifactId = getProject().getArtifactId();
@@ -58,7 +59,8 @@ public class AntPlugin extends BundlePlu
         try
         {
             // assemble bundle as usual, but don't save it - this way we have all the instructions we need
-            Builder builder = buildOSGiBundle( currentProject, originalInstructions, properties, classpath );
+            Builder builder = buildOSGiBundle( currentProject,
+                    dependencyGraph, originalInstructions, properties, classpath );
             Properties bndProperties = builder.getProperties();
 
             // cleanup and remove all non-strings from the builder properties

Modified: felix/trunk/bundleplugin/src/main/java/org/apache/felix/bundleplugin/BundleAllPlugin.java
URL: http://svn.apache.org/viewvc/felix/trunk/bundleplugin/src/main/java/org/apache/felix/bundleplugin/BundleAllPlugin.java?rev=1690153&r1=1690152&r2=1690153&view=diff
==============================================================================
--- felix/trunk/bundleplugin/src/main/java/org/apache/felix/bundleplugin/BundleAllPlugin.java (original)
+++ felix/trunk/bundleplugin/src/main/java/org/apache/felix/bundleplugin/BundleAllPlugin.java Thu Jul  9 19:45:09 2015
@@ -329,7 +329,7 @@ public class BundleAllPlugin extends Man
             instructions.put( Analyzer.IMPORT_PACKAGE, wrapImportPackage );
 
             project.getArtifact().setFile( getFile( artifact ) );
-            File outputFile = getOutputFile( artifact );
+            File outputFile = getOutputFile(artifact);
 
             if ( project.getArtifact().getFile().equals( outputFile ) )
             {
@@ -342,7 +342,8 @@ public class BundleAllPlugin extends Man
                 //                    + " to the same file, try cleaning: " + outputFile );
             }
 
-            Analyzer analyzer = getAnalyzer( project, instructions, new Properties(), getClasspath( project ) );
+            org.apache.maven.shared.dependency.graph.DependencyNode dependencyGraph = buildDependencyGraph( project );
+            Analyzer analyzer = getAnalyzer( project, dependencyGraph, instructions, new Properties(), getClasspath( project, dependencyGraph ) );
 
             Jar osgiJar = new Jar( project.getArtifactId(), project.getArtifact().getFile() );
 

Modified: felix/trunk/bundleplugin/src/main/java/org/apache/felix/bundleplugin/BundlePlugin.java
URL: http://svn.apache.org/viewvc/felix/trunk/bundleplugin/src/main/java/org/apache/felix/bundleplugin/BundlePlugin.java?rev=1690153&r1=1690152&r2=1690153&view=diff
==============================================================================
--- felix/trunk/bundleplugin/src/main/java/org/apache/felix/bundleplugin/BundlePlugin.java (original)
+++ felix/trunk/bundleplugin/src/main/java/org/apache/felix/bundleplugin/BundlePlugin.java Thu Jul  9 19:45:09 2015
@@ -64,6 +64,9 @@ import org.apache.maven.plugins.annotati
 import org.apache.maven.plugins.annotations.ResolutionScope;
 import org.apache.maven.project.MavenProject;
 import org.apache.maven.project.MavenProjectHelper;
+import org.apache.maven.shared.dependency.graph.DependencyGraphBuilder;
+import org.apache.maven.shared.dependency.graph.DependencyGraphBuilderException;
+import org.apache.maven.shared.dependency.graph.DependencyNode;
 import org.apache.maven.shared.osgi.DefaultMaven2OsgiConverter;
 import org.apache.maven.shared.osgi.Maven2OsgiConverter;
 import org.codehaus.plexus.archiver.UnArchiver;
@@ -160,6 +163,9 @@ public class BundlePlugin extends Abstra
     @Component
     private ArtifactHandlerManager m_artifactHandlerManager;
 
+    @Component
+    private DependencyGraphBuilder m_dependencyGraphBuilder;
+
     /**
      * Project types which this plugin supports.
      */
@@ -233,6 +239,19 @@ public class BundlePlugin extends Abstra
         return project;
     }
 
+    protected DependencyNode buildDependencyGraph( MavenProject mavenProject ) throws MojoExecutionException
+    {
+        DependencyNode dependencyGraph;
+        try
+        {
+            dependencyGraph = m_dependencyGraphBuilder.buildDependencyGraph( mavenProject, null );
+        }
+        catch ( DependencyGraphBuilderException e )
+        {
+            throw new MojoExecutionException( e.getMessage(), e );
+        }
+        return dependencyGraph;
+    }
 
     /**
      * @see org.apache.maven.plugin.AbstractMojo#execute()
@@ -250,16 +269,16 @@ public class BundlePlugin extends Abstra
             return;
         }
 
-        execute( getProject(), instructions, properties );
+        execute( getProject(), buildDependencyGraph(getProject()), instructions, properties );
     }
 
 
-    protected void execute( MavenProject currentProject, Map<String, String> originalInstructions, Properties properties )
+    protected void execute( MavenProject currentProject, DependencyNode dependencyGraph, Map<String, String> originalInstructions, Properties properties )
         throws MojoExecutionException
     {
         try
         {
-            execute( currentProject, originalInstructions, properties, getClasspath( currentProject ) );
+            execute( currentProject, dependencyGraph, originalInstructions, properties, getClasspath( currentProject, dependencyGraph ) );
         }
         catch ( IOException e )
         {
@@ -336,13 +355,13 @@ public class BundlePlugin extends Abstra
     }
 
 
-    protected void execute( MavenProject currentProject, Map<String, String> originalInstructions, Properties properties,
+    protected void execute( MavenProject currentProject, DependencyNode dependencyGraph, Map<String, String> originalInstructions, Properties properties,
         Jar[] classpath ) throws MojoExecutionException
     {
         try
         {
             File jarFile = new File( getBuildDirectory(), getBundleName( currentProject ) );
-            Builder builder = buildOSGiBundle( currentProject, originalInstructions, properties, classpath );
+            Builder builder = buildOSGiBundle( currentProject, dependencyGraph, originalInstructions, properties, classpath );
             boolean hasErrors = reportErrors( "Bundle " + currentProject.getArtifact(), builder );
             if ( hasErrors )
             {
@@ -572,7 +591,7 @@ public class BundlePlugin extends Abstra
     }
 
 
-    protected void addMavenInstructions( MavenProject currentProject, Builder builder ) throws Exception
+    protected void addMavenInstructions( MavenProject currentProject, DependencyNode dependencyGraph, Builder builder ) throws Exception
     {
         if ( currentProject.getBasedir() != null )
         {
@@ -587,8 +606,8 @@ public class BundlePlugin extends Abstra
         }
 
         // update BND instructions to embed selected Maven dependencies
-        Collection<Artifact> embeddableArtifacts = getEmbeddableArtifacts( currentProject, builder );
-        new DependencyEmbedder( getLog(), embeddableArtifacts ).processHeaders( builder );
+        Collection<Artifact> embeddableArtifacts = getEmbeddableArtifacts( currentProject, dependencyGraph, builder );
+        new DependencyEmbedder( getLog(), dependencyGraph, embeddableArtifacts ).processHeaders( builder );
 
         if ( dumpInstructions != null || getLog().isDebugEnabled() )
         {
@@ -616,16 +635,16 @@ public class BundlePlugin extends Abstra
     }
 
 
-    protected Builder buildOSGiBundle( MavenProject currentProject, Map<String, String> originalInstructions, Properties properties,
+    protected Builder buildOSGiBundle( MavenProject currentProject, DependencyNode dependencyGraph, Map<String, String> originalInstructions, Properties properties,
         Jar[] classpath ) throws Exception
     {
         Builder builder = getOSGiBuilder( currentProject, originalInstructions, properties, classpath );
 
-        addMavenInstructions( currentProject, builder );
+        addMavenInstructions( currentProject, dependencyGraph, builder );
 
         builder.build();
 
-        mergeMavenManifest( currentProject, builder );
+        mergeMavenManifest( currentProject, dependencyGraph, builder );
 
         return builder;
     }
@@ -736,7 +755,7 @@ public class BundlePlugin extends Abstra
     }
 
 
-    protected void mergeMavenManifest( MavenProject currentProject, Builder builder ) throws Exception
+    protected void mergeMavenManifest( MavenProject currentProject, DependencyNode dependencyGraph, Builder builder ) throws Exception
     {
         Jar jar = builder.getJar();
 
@@ -831,7 +850,7 @@ public class BundlePlugin extends Abstra
             String importPackages = bundleManifest.getMainAttributes().getValue( "Import-Package" );
             if ( importPackages != null )
             {
-                Set optionalPackages = getOptionalPackages( currentProject );
+                Set optionalPackages = getOptionalPackages( currentProject, dependencyGraph );
 
                 Map<String, ? extends Map<String, String>> values = new Analyzer().parseHeader( importPackages );
                 for ( Map.Entry<String, ? extends Map<String, String>> entry : values.entrySet() )
@@ -868,19 +887,16 @@ public class BundlePlugin extends Abstra
     }
 
 
-    protected Set<String> getOptionalPackages( MavenProject currentProject ) throws IOException, MojoExecutionException
+    protected Set<String> getOptionalPackages( MavenProject currentProject, DependencyNode dependencyGraph ) throws IOException, MojoExecutionException
     {
         ArrayList<Artifact> inscope = new ArrayList<Artifact>();
-        final Collection<Artifact> artifacts = getSelectedDependencies( currentProject.getArtifacts() );
+        final Collection<Artifact> artifacts = getSelectedDependencies( dependencyGraph, currentProject.getArtifacts() );
         for ( Iterator<Artifact> it = artifacts.iterator(); it.hasNext(); )
         {
             Artifact artifact = it.next();
             if ( artifact.getArtifactHandler().isAddedToClasspath() )
             {
-                if ( !Artifact.SCOPE_TEST.equals( artifact.getScope() ) )
-                {
-                    inscope.add( artifact );
-                }
+                inscope.add( artifact );
             }
         }
 
@@ -1077,7 +1093,7 @@ public class BundlePlugin extends Abstra
     }
 
 
-    protected Jar[] getClasspath( MavenProject currentProject ) throws IOException, MojoExecutionException
+    protected Jar[] getClasspath( MavenProject currentProject, DependencyNode dependencyGraph ) throws IOException, MojoExecutionException
     {
         List<Jar> list = new ArrayList<Jar>();
 
@@ -1086,25 +1102,22 @@ public class BundlePlugin extends Abstra
             list.add( new Jar( ".", getOutputDirectory() ) );
         }
 
-        final Collection<Artifact> artifacts = getSelectedDependencies( currentProject.getArtifacts() );
+        final Collection<Artifact> artifacts = getSelectedDependencies( dependencyGraph, currentProject.getArtifacts() );
         for ( Iterator<Artifact> it = artifacts.iterator(); it.hasNext(); )
         {
             Artifact artifact = it.next();
             if ( artifact.getArtifactHandler().isAddedToClasspath() )
             {
-                if ( !Artifact.SCOPE_TEST.equals( artifact.getScope() ) )
+                File file = getFile( artifact );
+                if ( file == null )
                 {
-                    File file = getFile( artifact );
-                    if ( file == null )
-                    {
-                        getLog().warn(
-                            "File is not available for artifact " + artifact + " in project "
-                                + currentProject.getArtifact() );
-                        continue;
-                    }
-                    Jar jar = new Jar( artifact.getArtifactId(), file );
-                    list.add( jar );
+                    getLog().warn(
+                        "File is not available for artifact " + artifact + " in project "
+                            + currentProject.getArtifact() );
+                    continue;
                 }
+                Jar jar = new Jar( artifact.getArtifactId(), file );
+                list.add( jar );
             }
         }
         Jar[] cp = new Jar[list.size()];
@@ -1113,7 +1126,7 @@ public class BundlePlugin extends Abstra
     }
 
 
-    private Collection<Artifact> getSelectedDependencies( Collection<Artifact> artifacts ) throws MojoExecutionException
+    private Collection<Artifact> getSelectedDependencies( DependencyNode dependencyGraph, Collection<Artifact> artifacts ) throws MojoExecutionException
     {
         if ( null == excludeDependencies || excludeDependencies.length() == 0 )
         {
@@ -1125,7 +1138,7 @@ public class BundlePlugin extends Abstra
         }
 
         Collection<Artifact> selectedDependencies = new LinkedHashSet<Artifact>( artifacts );
-        DependencyExcluder excluder = new DependencyExcluder( artifacts );
+        DependencyExcluder excluder = new DependencyExcluder( dependencyGraph, artifacts );
         excluder.processHeaders( excludeDependencies );
         selectedDependencies.removeAll( excluder.getExcludedArtifacts() );
 
@@ -1539,7 +1552,7 @@ public class BundlePlugin extends Abstra
     }
 
 
-    protected Collection<Artifact> getEmbeddableArtifacts( MavenProject currentProject, Analyzer analyzer )
+    protected Collection<Artifact> getEmbeddableArtifacts( MavenProject currentProject, DependencyNode dependencyGraph, Analyzer analyzer )
         throws MojoExecutionException
     {
         final Collection<Artifact> artifacts;
@@ -1556,7 +1569,7 @@ public class BundlePlugin extends Abstra
             artifacts = currentProject.getDependencyArtifacts();
         }
 
-        return getSelectedDependencies( artifacts );
+        return getSelectedDependencies( dependencyGraph, artifacts );
     }
 
 

Modified: felix/trunk/bundleplugin/src/main/java/org/apache/felix/bundleplugin/DependencyEmbedder.java
URL: http://svn.apache.org/viewvc/felix/trunk/bundleplugin/src/main/java/org/apache/felix/bundleplugin/DependencyEmbedder.java?rev=1690153&r1=1690152&r2=1690153&view=diff
==============================================================================
--- felix/trunk/bundleplugin/src/main/java/org/apache/felix/bundleplugin/DependencyEmbedder.java (original)
+++ felix/trunk/bundleplugin/src/main/java/org/apache/felix/bundleplugin/DependencyEmbedder.java Thu Jul  9 19:45:09 2015
@@ -27,6 +27,7 @@ import java.util.LinkedHashSet;
 import org.apache.maven.artifact.Artifact;
 import org.apache.maven.plugin.MojoExecutionException;
 import org.apache.maven.plugin.logging.Log;
+import org.apache.maven.shared.dependency.graph.DependencyNode;
 import org.codehaus.plexus.util.StringUtils;
 
 import aQute.bnd.osgi.Analyzer;
@@ -64,9 +65,9 @@ public final class DependencyEmbedder ex
     private final Collection<Artifact> m_embeddedArtifacts;
 
 
-    public DependencyEmbedder( Log log, Collection<Artifact> dependencyArtifacts )
+    public DependencyEmbedder( Log log, DependencyNode dependencyGraph, Collection<Artifact> dependencyArtifacts )
     {
-        super( dependencyArtifacts );
+        super( dependencyGraph, dependencyArtifacts );
 
         m_inlinedPaths = new LinkedHashSet<String>();
         m_embeddedArtifacts = new LinkedHashSet<Artifact>();

Modified: felix/trunk/bundleplugin/src/main/java/org/apache/felix/bundleplugin/DependencyExcluder.java
URL: http://svn.apache.org/viewvc/felix/trunk/bundleplugin/src/main/java/org/apache/felix/bundleplugin/DependencyExcluder.java?rev=1690153&r1=1690152&r2=1690153&view=diff
==============================================================================
--- felix/trunk/bundleplugin/src/main/java/org/apache/felix/bundleplugin/DependencyExcluder.java (original)
+++ felix/trunk/bundleplugin/src/main/java/org/apache/felix/bundleplugin/DependencyExcluder.java Thu Jul  9 19:45:09 2015
@@ -24,6 +24,7 @@ import java.util.HashSet;
 
 import org.apache.maven.artifact.Artifact;
 import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.shared.dependency.graph.DependencyNode;
 
 
 /**
@@ -39,9 +40,9 @@ public final class DependencyExcluder ex
     private final Collection<Artifact> m_excludedArtifacts;
 
 
-    public DependencyExcluder( Collection<Artifact> dependencyArtifacts )
+    public DependencyExcluder( DependencyNode dependencyGraph, Collection<Artifact> dependencyArtifacts )
     {
-        super( dependencyArtifacts );
+        super( dependencyGraph, dependencyArtifacts );
 
         m_excludedArtifacts = new HashSet<Artifact>();
     }

Modified: felix/trunk/bundleplugin/src/main/java/org/apache/felix/bundleplugin/InstructionsPlugin.java
URL: http://svn.apache.org/viewvc/felix/trunk/bundleplugin/src/main/java/org/apache/felix/bundleplugin/InstructionsPlugin.java?rev=1690153&r1=1690152&r2=1690153&view=diff
==============================================================================
--- felix/trunk/bundleplugin/src/main/java/org/apache/felix/bundleplugin/InstructionsPlugin.java (original)
+++ felix/trunk/bundleplugin/src/main/java/org/apache/felix/bundleplugin/InstructionsPlugin.java Thu Jul  9 19:45:09 2015
@@ -32,6 +32,7 @@ import org.apache.maven.plugins.annotati
 import org.apache.maven.project.MavenProject;
 
 import aQute.bnd.osgi.Jar;
+import org.apache.maven.shared.dependency.graph.DependencyNode;
 
 
 /**
@@ -41,7 +42,7 @@ import aQute.bnd.osgi.Jar;
 public class InstructionsPlugin extends BundlePlugin
 {
     @Override
-    protected void execute( MavenProject project, Map<String, String> instructions, Properties properties, Jar[] classpath )
+    protected void execute( MavenProject project, DependencyNode dependencyGraph, Map<String, String> instructions, Properties properties, Jar[] classpath )
         throws MojoExecutionException
     {
         if ( dumpInstructions == null )
@@ -51,7 +52,7 @@ public class InstructionsPlugin extends
 
         try
         {
-            addMavenInstructions( project, getOSGiBuilder( project, instructions, properties, classpath ) );
+            addMavenInstructions( project, dependencyGraph, getOSGiBuilder(project, instructions, properties, classpath) );
         }
         catch ( FileNotFoundException e )
         {

Modified: felix/trunk/bundleplugin/src/main/java/org/apache/felix/bundleplugin/ManifestPlugin.java
URL: http://svn.apache.org/viewvc/felix/trunk/bundleplugin/src/main/java/org/apache/felix/bundleplugin/ManifestPlugin.java?rev=1690153&r1=1690152&r2=1690153&view=diff
==============================================================================
--- felix/trunk/bundleplugin/src/main/java/org/apache/felix/bundleplugin/ManifestPlugin.java (original)
+++ felix/trunk/bundleplugin/src/main/java/org/apache/felix/bundleplugin/ManifestPlugin.java Thu Jul  9 19:45:09 2015
@@ -43,6 +43,7 @@ import aQute.bnd.osgi.Analyzer;
 import aQute.bnd.osgi.Builder;
 import aQute.bnd.osgi.Jar;
 import aQute.bnd.osgi.Resource;
+import org.apache.maven.shared.dependency.graph.DependencyNode;
 
 
 /**
@@ -61,13 +62,13 @@ public class ManifestPlugin extends Bund
 
 
     @Override
-    protected void execute( MavenProject project, Map<String, String> instructions, Properties properties, Jar[] classpath )
+    protected void execute( MavenProject project, DependencyNode dependencyGraph, Map<String, String> instructions, Properties properties, Jar[] classpath )
         throws MojoExecutionException
     {
         Manifest manifest;
         try
         {
-            manifest = getManifest( project, instructions, properties, classpath );
+            manifest = getManifest( project, dependencyGraph, instructions, properties, classpath );
         }
         catch ( FileNotFoundException e )
         {
@@ -102,17 +103,17 @@ public class ManifestPlugin extends Bund
     }
 
 
-    public Manifest getManifest( MavenProject project, Jar[] classpath ) throws IOException, MojoFailureException,
+    public Manifest getManifest( MavenProject project, DependencyNode dependencyGraph, Jar[] classpath ) throws IOException, MojoFailureException,
         MojoExecutionException, Exception
     {
-        return getManifest( project, new LinkedHashMap<String, String>(), new Properties(), classpath );
+        return getManifest( project, dependencyGraph, new LinkedHashMap<String, String>(), new Properties(), classpath );
     }
 
 
-    public Manifest getManifest( MavenProject project, Map<String, String> instructions, Properties properties, Jar[] classpath )
+    public Manifest getManifest( MavenProject project, DependencyNode dependencyGraph, Map<String, String> instructions, Properties properties, Jar[] classpath )
         throws IOException, MojoFailureException, MojoExecutionException, Exception
     {
-        Analyzer analyzer = getAnalyzer( project, instructions, properties, classpath );
+        Analyzer analyzer = getAnalyzer( project, dependencyGraph, instructions, properties, classpath );
         boolean hasErrors = reportErrors( "Manifest " + project.getArtifact(), analyzer );
         if ( hasErrors )
         {
@@ -150,19 +151,19 @@ public class ManifestPlugin extends Bund
     }
 
 
-    protected Analyzer getAnalyzer( MavenProject project, Jar[] classpath ) throws IOException, MojoExecutionException,
+    protected Analyzer getAnalyzer( MavenProject project, DependencyNode dependencyGraph, Jar[] classpath ) throws IOException, MojoExecutionException,
         Exception
     {
-        return getAnalyzer( project, new LinkedHashMap<String, String>(), new Properties(), classpath );
+        return getAnalyzer( project, dependencyGraph, new LinkedHashMap<String, String>(), new Properties(), classpath );
     }
 
 
-    protected Analyzer getAnalyzer( MavenProject project, Map<String, String> instructions, Properties properties, Jar[] classpath )
+    protected Analyzer getAnalyzer( MavenProject project, DependencyNode dependencyGraph, Map<String, String> instructions, Properties properties, Jar[] classpath )
         throws IOException, MojoExecutionException, Exception
     {
         if ( rebuildBundle && supportedProjectTypes.contains( project.getArtifact().getType() ) )
         {
-            return buildOSGiBundle( project, instructions, properties, classpath );
+            return buildOSGiBundle( project, dependencyGraph, instructions, properties, classpath );
         }
 
         File file = getOutputDirectory();
@@ -201,7 +202,7 @@ public class ManifestPlugin extends Bund
             analyzer.setProperty( Analyzer.EXPORT_PACKAGE, export );
         }
 
-        addMavenInstructions( project, analyzer );
+        addMavenInstructions( project, dependencyGraph, analyzer );
 
         // if we spot Embed-Dependency and the bundle is "target/classes", assume we need to rebuild
         if ( analyzer.getProperty( DependencyEmbedder.EMBED_DEPENDENCY ) != null && isOutputDirectory )
@@ -214,7 +215,7 @@ public class ManifestPlugin extends Bund
             analyzer.getJar().setManifest( analyzer.calcManifest() );
         }
 
-        mergeMavenManifest( project, analyzer );
+        mergeMavenManifest( project, dependencyGraph, analyzer );
 
         return analyzer;
     }

Modified: felix/trunk/bundleplugin/src/test/java/org/apache/felix/bundleplugin/AbstractBundlePluginTest.java
URL: http://svn.apache.org/viewvc/felix/trunk/bundleplugin/src/test/java/org/apache/felix/bundleplugin/AbstractBundlePluginTest.java?rev=1690153&r1=1690152&r2=1690153&view=diff
==============================================================================
--- felix/trunk/bundleplugin/src/test/java/org/apache/felix/bundleplugin/AbstractBundlePluginTest.java (original)
+++ felix/trunk/bundleplugin/src/test/java/org/apache/felix/bundleplugin/AbstractBundlePluginTest.java Thu Jul  9 19:45:09 2015
@@ -22,8 +22,20 @@ package org.apache.felix.bundleplugin;
 
 import java.io.File;
 
+import org.apache.maven.artifact.Artifact;
+import org.apache.maven.artifact.DefaultArtifact;
+import org.apache.maven.artifact.handler.ArtifactHandler;
+import org.apache.maven.artifact.handler.DefaultArtifactHandler;
+import org.apache.maven.artifact.repository.ArtifactRepository;
+import org.apache.maven.artifact.repository.DefaultArtifactRepository;
+import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout;
+import org.apache.maven.artifact.repository.layout.LegacyRepositoryLayout;
+import org.apache.maven.artifact.versioning.VersionRange;
+import org.apache.maven.plugin.testing.AbstractMojoTestCase;
 import org.apache.maven.plugin.testing.stubs.ArtifactStub;
 import org.apache.maven.plugin.testing.stubs.MavenProjectStub;
+import org.apache.maven.project.DefaultProjectBuilderConfiguration;
+import org.apache.maven.project.ProjectBuilderConfiguration;
 import org.codehaus.plexus.PlexusTestCase;
 
 
@@ -33,15 +45,28 @@ import org.codehaus.plexus.PlexusTestCas
  * @author <a href="mailto:carlos@apache.org">Carlos Sanchez</a>
  * @version $Id$
  */
-public abstract class AbstractBundlePluginTest extends PlexusTestCase
+public abstract class AbstractBundlePluginTest extends AbstractMojoTestCase
 {
 
     protected MavenProjectStub getMavenProjectStub()
     {
         MavenProjectStub project = new MavenProjectStub();
-        project.setGroupId( "group" );
-        project.setArtifactId( "project" );
+        project.setGroupId("group");
+        project.setArtifactId("project");
         project.setVersion( "1.2.3.4" );
+
+        VersionRange versionRange = VersionRange.createFromVersion( project.getVersion() );
+        ArtifactHandler artifactHandler = new DefaultArtifactHandler("pom");
+        Artifact artifact =
+            new DefaultArtifact( project.getGroupId(), project.getArtifactId(),
+                                 versionRange, null, "pom", null, artifactHandler );
+        artifact.setResolved( true );
+        project.setArtifact( artifact );
+        ProjectBuilderConfiguration projectBuilderConfiguration = new DefaultProjectBuilderConfiguration();
+        ArtifactRepositoryLayout layout = new LegacyRepositoryLayout();
+        ArtifactRepository artifactRepository = new DefaultArtifactRepository( "scratch", new File( getBasedir(), "target" + File.separatorChar + "scratch" ).toURI().toString(), layout );
+        projectBuilderConfiguration.setLocalRepository( artifactRepository );
+        project.setProjectBuilderConfiguration( projectBuilderConfiguration );
         return project;
     }
 

Modified: felix/trunk/bundleplugin/src/test/java/org/apache/felix/bundleplugin/BlueprintComponentTest.java
URL: http://svn.apache.org/viewvc/felix/trunk/bundleplugin/src/test/java/org/apache/felix/bundleplugin/BlueprintComponentTest.java?rev=1690153&r1=1690152&r2=1690153&view=diff
==============================================================================
--- felix/trunk/bundleplugin/src/test/java/org/apache/felix/bundleplugin/BlueprintComponentTest.java (original)
+++ felix/trunk/bundleplugin/src/test/java/org/apache/felix/bundleplugin/BlueprintComponentTest.java Thu Jul  9 19:45:09 2015
@@ -36,14 +36,24 @@ import junit.framework.TestCase;
 
 import org.apache.felix.utils.manifest.Clause;
 import org.apache.felix.utils.manifest.Parser;
+import org.apache.maven.artifact.Artifact;
+import org.apache.maven.artifact.DefaultArtifact;
+import org.apache.maven.artifact.handler.ArtifactHandler;
+import org.apache.maven.artifact.handler.DefaultArtifactHandler;
+import org.apache.maven.artifact.versioning.VersionRange;
 import org.apache.maven.model.Resource;
+import org.apache.maven.plugin.testing.AbstractMojoTestCase;
 import org.apache.maven.plugin.testing.stubs.MavenProjectStub;
+import org.apache.maven.project.DefaultProjectBuilderConfiguration;
+import org.apache.maven.project.ProjectBuilderConfiguration;
+import org.apache.maven.shared.dependency.graph.DependencyGraphBuilder;
+import org.apache.maven.shared.dependency.graph.DependencyNode;
 import org.osgi.framework.Constants;
 
 import aQute.bnd.osgi.Builder;
 
 
-public class BlueprintComponentTest extends TestCase
+public class BlueprintComponentTest extends AbstractMojoTestCase
 {
 
     public void testBlueprintServices() throws Exception
@@ -83,18 +93,28 @@ public class BlueprintComponentTest exte
                 return new File( "target/tmp/basedir" );
             }
         };
-        project.setGroupId( "group" );
+        project.setGroupId("group");
         project.setArtifactId( "artifact" );
         project.setVersion( "1.1.0.0" );
+        VersionRange versionRange = VersionRange.createFromVersion(project.getVersion());
+        ArtifactHandler artifactHandler = new DefaultArtifactHandler( "jar" );
+        Artifact artifact = new DefaultArtifact(project.getGroupId(),project.getArtifactId(),versionRange, null, "jar", null, artifactHandler);
+        project.setArtifact(artifact);
+
+        ProjectBuilderConfiguration projectBuilderConfiguration = new DefaultProjectBuilderConfiguration();
+        projectBuilderConfiguration.setLocalRepository(null);
+        project.setProjectBuilderConfiguration(projectBuilderConfiguration);
+
         Resource r = new Resource();
         r.setDirectory( new File( "src/test/resources" ).getAbsoluteFile().getCanonicalPath() );
-        r.setIncludes( Arrays.asList( "**/*.*" ) );
-        project.addResource( r );
-        project.addCompileSourceRoot( new File( "src/test/resources" ).getAbsoluteFile().getCanonicalPath() );
+        r.setIncludes(Arrays.asList("**/*.*"));
+        project.addResource(r);
+        project.addCompileSourceRoot(new File("src/test/resources").getAbsoluteFile().getCanonicalPath());
 
         ManifestPlugin plugin = new ManifestPlugin();
         plugin.setBuildDirectory( "target/tmp/basedir/target" );
-        plugin.setOutputDirectory( new File( "target/tmp/basedir/target/classes" ) );
+        plugin.setOutputDirectory(new File("target/tmp/basedir/target/classes"));
+        setVariableValueToObject(plugin, "m_dependencyGraphBuilder", lookup(DependencyGraphBuilder.class.getName(), "default"));
 
         Map instructions = new HashMap();
         instructions.put( "service_mode", mode );
@@ -107,7 +127,8 @@ public class BlueprintComponentTest exte
         instructions.put( "Import-Service", "org.osgi.service.cm.ConfigurationAdmin;availability:=optional" );
 
         Properties props = new Properties();
-        Builder builder = plugin.buildOSGiBundle( project, instructions, props, plugin.getClasspath( project ) );
+        DependencyNode dependencyGraph = plugin.buildDependencyGraph(project);
+        Builder builder = plugin.buildOSGiBundle( project, dependencyGraph, instructions, props, plugin.getClasspath( project, dependencyGraph ) );
 
         Manifest manifest = builder.getJar().getManifest();
         String expSvc = manifest.getMainAttributes().getValue( Constants.EXPORT_SERVICE );

Modified: felix/trunk/bundleplugin/src/test/java/org/apache/felix/bundleplugin/BundleAllPluginTest.java
URL: http://svn.apache.org/viewvc/felix/trunk/bundleplugin/src/test/java/org/apache/felix/bundleplugin/BundleAllPluginTest.java?rev=1690153&r1=1690152&r2=1690153&view=diff
==============================================================================
--- felix/trunk/bundleplugin/src/test/java/org/apache/felix/bundleplugin/BundleAllPluginTest.java (original)
+++ felix/trunk/bundleplugin/src/test/java/org/apache/felix/bundleplugin/BundleAllPluginTest.java Thu Jul  9 19:45:09 2015
@@ -24,9 +24,15 @@ import java.io.File;
 import java.util.Collections;
 import java.util.Map;
 
+import org.apache.maven.artifact.Artifact;
+import org.apache.maven.artifact.DefaultArtifact;
+import org.apache.maven.artifact.handler.ArtifactHandler;
+import org.apache.maven.artifact.handler.DefaultArtifactHandler;
+import org.apache.maven.artifact.versioning.VersionRange;
 import org.apache.maven.plugin.testing.stubs.ArtifactStub;
 import org.apache.maven.plugin.testing.stubs.MavenProjectStub;
 import org.apache.maven.project.MavenProject;
+import org.apache.maven.shared.dependency.graph.DependencyGraphBuilder;
 
 
 /**
@@ -48,7 +54,7 @@ public class BundleAllPluginTest extends
     }
 
 
-    private void init()
+    private void init() throws Exception
     {
         plugin = new BundleAllPlugin();
         File baseDirectory = new File( getBasedir() );
@@ -56,6 +62,7 @@ public class BundleAllPluginTest extends
         plugin.setBuildDirectory( buildDirectory.getPath() );
         File outputDirectory = new File( buildDirectory, "test-classes" );
         plugin.setOutputDirectory( outputDirectory );
+        setVariableValueToObject(plugin, "m_dependencyGraphBuilder", lookup(DependencyGraphBuilder.class.getName(), "default"));
     }
 
 
@@ -86,12 +93,11 @@ public class BundleAllPluginTest extends
             testFile.delete();
         }
 
-        ArtifactStub artifact = new ArtifactStub();
-        artifact.setGroupId( "group" );
-        artifact.setArtifactId( "artifact" );
-        artifact.setVersion( "1.0.0.0" );
+        VersionRange versionRange = VersionRange.createFromVersion("1.0.0.0");
+        ArtifactHandler artifactHandler = new DefaultArtifactHandler( "jar" );
+        Artifact artifact = new DefaultArtifact("group","artifact",versionRange, null, "jar", null, artifactHandler);
 
-        MavenProject project = new MavenProjectStub();
+        MavenProject project = getMavenProjectStub();
         project.setGroupId( artifact.getGroupId() );
         project.setArtifactId( artifact.getArtifactId() );
         project.setVersion( artifact.getVersion() );

Modified: felix/trunk/bundleplugin/src/test/java/org/apache/felix/bundleplugin/BundlePluginTest.java
URL: http://svn.apache.org/viewvc/felix/trunk/bundleplugin/src/test/java/org/apache/felix/bundleplugin/BundlePluginTest.java?rev=1690153&r1=1690152&r2=1690153&view=diff
==============================================================================
--- felix/trunk/bundleplugin/src/test/java/org/apache/felix/bundleplugin/BundlePluginTest.java (original)
+++ felix/trunk/bundleplugin/src/test/java/org/apache/felix/bundleplugin/BundlePluginTest.java Thu Jul  9 19:45:09 2015
@@ -34,6 +34,8 @@ import java.util.jar.Manifest;
 import org.apache.maven.model.Organization;
 import org.apache.maven.plugin.testing.stubs.MavenProjectStub;
 import org.apache.maven.project.MavenProject;
+import org.apache.maven.shared.dependency.graph.DependencyGraphBuilder;
+import org.apache.maven.shared.dependency.graph.DependencyNode;
 import org.osgi.framework.Constants;
 
 import aQute.bnd.osgi.Analyzer;
@@ -58,7 +60,8 @@ public class BundlePluginTest extends Ab
         super.setUp();
         plugin = new BundlePlugin();
         plugin.setBuildDirectory( "." );
-        plugin.setOutputDirectory( new File( getBasedir(), "target" + File.separatorChar + "scratch" ) );
+        plugin.setOutputDirectory(new File(getBasedir(), "target" + File.separatorChar + "scratch"));
+        setVariableValueToObject(plugin, "m_dependencyGraphBuilder", lookup(DependencyGraphBuilder.class.getName(), "default"));
     }
 
 
@@ -233,7 +236,8 @@ public class BundlePluginTest extends Ab
             + "*;classifier=;type=jar;scope=runtime" );
         Properties props = new Properties();
 
-        Builder builder = plugin.buildOSGiBundle( project, instructions, props, plugin.getClasspath( project ) );
+        DependencyNode dependencyGraph = plugin.buildDependencyGraph(project);
+        Builder builder = plugin.buildOSGiBundle( project, dependencyGraph, instructions, props, plugin.getClasspath( project, dependencyGraph ) );
         Manifest manifest = builder.getJar().getManifest();
 
         String bcp = manifest.getMainAttributes().getValue( Constants.BUNDLE_CLASSPATH );
@@ -262,7 +266,8 @@ public class BundlePluginTest extends Ab
         instructions.put( DependencyEmbedder.EMBED_DEPENDENCY, "!type=jar, !artifactId=c" );
         Properties props = new Properties();
 
-        Builder builder = plugin.buildOSGiBundle( project, instructions, props, plugin.getClasspath( project ) );
+        DependencyNode dependencyGraph = plugin.buildDependencyGraph(project);
+        Builder builder = plugin.buildOSGiBundle( project, dependencyGraph, instructions, props, plugin.getClasspath( project, dependencyGraph ) );
         Manifest manifest = builder.getJar().getManifest();
 
         String bcp = manifest.getMainAttributes().getValue( Constants.BUNDLE_CLASSPATH );
@@ -291,7 +296,8 @@ public class BundlePluginTest extends Ab
         instructions.put( DependencyEmbedder.EMBED_DEPENDENCY, "c;type=jar,c;type=sources" );
         Properties props = new Properties();
 
-        Builder builder = plugin.buildOSGiBundle( project, instructions, props, plugin.getClasspath( project ) );
+        DependencyNode dependencyGraph = plugin.buildDependencyGraph(project);
+        Builder builder = plugin.buildOSGiBundle( project, dependencyGraph, instructions, props, plugin.getClasspath( project, dependencyGraph ) );
         Manifest manifest = builder.getJar().getManifest();
 
         String bcp = manifest.getMainAttributes().getValue( Constants.BUNDLE_CLASSPATH );
@@ -320,7 +326,8 @@ public class BundlePluginTest extends Ab
         instructions.put( DependencyEmbedder.EMBED_DEPENDENCY, "artifactId=a|b" );
         Properties props = new Properties();
 
-        Builder builder = plugin.buildOSGiBundle( project, instructions, props, plugin.getClasspath( project ) );
+        DependencyNode dependencyGraph = plugin.buildDependencyGraph(project);
+        Builder builder = plugin.buildOSGiBundle( project, dependencyGraph, instructions, props, plugin.getClasspath( project, dependencyGraph ) );
         Manifest manifest = builder.getJar().getManifest();
 
         String bcp = manifest.getMainAttributes().getValue( Constants.BUNDLE_CLASSPATH );
@@ -341,20 +348,22 @@ public class BundlePluginTest extends Ab
 
         artifacts.addAll( artifactFactory.getClassifiedArtifacts() );
         artifacts.addAll( artifactFactory.getScopedArtifacts() );
-        artifacts.addAll( artifactFactory.getTypedArtifacts() );
+        artifacts.addAll(artifactFactory.getTypedArtifacts());
 
         MavenProject project = getMavenProjectStub();
-        project.setDependencyArtifacts( artifacts );
+        project.setDependencyArtifacts(artifacts);
         Properties props = new Properties();
+        DependencyNode dependencyGraph = plugin.buildDependencyGraph(project);
+        Jar[] classpath = plugin.getClasspath(project, dependencyGraph);
 
         Map instructions1 = new HashMap();
         instructions1.put( DependencyEmbedder.EMBED_DEPENDENCY, "!scope=compile" );
-        Builder builder1 = plugin.buildOSGiBundle( project, instructions1, props, plugin.getClasspath( project ) );
+        Builder builder1 = plugin.buildOSGiBundle( project, dependencyGraph, instructions1, props, classpath );
         Manifest manifest1 = builder1.getJar().getManifest();
 
         Map instructions2 = new HashMap();
         instructions2.put( DependencyEmbedder.EMBED_DEPENDENCY, "scope=!compile" );
-        Builder builder2 = plugin.buildOSGiBundle( project, instructions2, props, plugin.getClasspath( project ) );
+        Builder builder2 = plugin.buildOSGiBundle( project, dependencyGraph, instructions2, props, classpath );
         Manifest manifest2 = builder2.getJar().getManifest();
 
         String bcp1 = manifest1.getMainAttributes().getValue( Constants.BUNDLE_CLASSPATH );
@@ -387,7 +396,8 @@ public class BundlePluginTest extends Ab
         props.put( "4", new HashMap( 2 ) );
         props.put( "1, two, 3.0", new char[5] );
 
-        Builder builder = plugin.getOSGiBuilder( project, new HashMap(), props, plugin.getClasspath( project ) );
+        DependencyNode dependencyGraph = plugin.buildDependencyGraph(project);
+        Builder builder = plugin.getOSGiBuilder( project, new HashMap(), props, plugin.getClasspath( project, dependencyGraph ) );
 
         File file = new File( getBasedir(), "target" + File.separatorChar + "test.props" );
         builder.getProperties().store( new FileOutputStream( file ), "TEST" );