maven-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rfscho...@apache.org
Subject svn commit: r1686634 - in /maven/plugins/trunk/maven-dependency-plugin: pom.xml src/main/java/org/apache/maven/plugin/dependency/fromDependencies/AbstractDependencyFilterMojo.java src/main/java/org/apache/maven/plugin/dependency/tree/TreeMojo.java
Date Sat, 20 Jun 2015 14:57:57 GMT
Author: rfscholte
Date: Sat Jun 20 14:57:56 2015
New Revision: 1686634

URL: http://svn.apache.org/r1686634
Log:
[MDEP-494] Remove/replace Maven2 specific code
Remove ( project.getArtifact() == null ) check, which referred to a Maven2 bug
Remove DependencyTreeBuilder, which also disabled verbose option

Modified:
    maven/plugins/trunk/maven-dependency-plugin/pom.xml
    maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/fromDependencies/AbstractDependencyFilterMojo.java
    maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/tree/TreeMojo.java

Modified: maven/plugins/trunk/maven-dependency-plugin/pom.xml
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-dependency-plugin/pom.xml?rev=1686634&r1=1686633&r2=1686634&view=diff
==============================================================================
--- maven/plugins/trunk/maven-dependency-plugin/pom.xml (original)
+++ maven/plugins/trunk/maven-dependency-plugin/pom.xml Sat Jun 20 14:57:56 2015
@@ -210,7 +210,7 @@ under the License.
     <dependency>
       <groupId>org.apache.maven.shared</groupId>
       <artifactId>maven-dependency-tree</artifactId>
-      <version>2.2</version>
+      <version>3.0-SNAPSHOT</version>
     </dependency>
     <dependency>
       <groupId>org.apache.maven.shared</groupId>
@@ -360,6 +360,8 @@ under the License.
               <projectsDirectory>src/it/projects</projectsDirectory>
               <pomExcludes>
                 <pomExclude>purge-local-repository-bad-pom/pom.xml</pomExclude>
+                <!-- verbose was using Maven2 code, removed with MDEP-494, requires MSHARED-339
to be fixed first -->
+                <pomExclude>tree-verbose/pom.xml</pomExclude>
               </pomExcludes>
               <!-- for mrm -->
               <settingsFile>src/it/mrm/settings.xml</settingsFile>

Modified: maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/fromDependencies/AbstractDependencyFilterMojo.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/fromDependencies/AbstractDependencyFilterMojo.java?rev=1686634&r1=1686633&r2=1686634&view=diff
==============================================================================
--- maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/fromDependencies/AbstractDependencyFilterMojo.java
(original)
+++ maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/fromDependencies/AbstractDependencyFilterMojo.java
Sat Jun 20 14:57:56 2015
@@ -289,7 +289,7 @@ public abstract class AbstractDependency
                                                 DependencyUtil.cleanToBeTokenizedString(
this.excludeArtifactIds ) ) );
 
         // start with all artifacts.
-        @SuppressWarnings( "unchecked" ) Set<Artifact> artifacts = project.getArtifacts();
+        Set<Artifact> artifacts = project.getArtifacts();
 
         if ( includeParents )
         {
@@ -347,15 +347,6 @@ public abstract class AbstractDependency
         {
             project = project.getParent();
 
-            if ( project.getArtifact() == null )
-            {
-                // Maven 2.x bug
-                Artifact artifact =
-                    factory.createBuildArtifact( project.getGroupId(), project.getArtifactId(),
project.getVersion(),
-                                                 project.getPackaging() );
-                project.setArtifact( artifact );
-            }
-
             if ( !artifacts.add( project.getArtifact() ) )
             {
                 // artifact already in the set

Modified: maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/tree/TreeMojo.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/tree/TreeMojo.java?rev=1686634&r1=1686633&r2=1686634&view=diff
==============================================================================
--- maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/tree/TreeMojo.java
(original)
+++ maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/tree/TreeMojo.java
Sat Jun 20 14:57:56 2015
@@ -19,12 +19,21 @@ package org.apache.maven.plugin.dependen
  * under the License.
  */
 
+import java.io.File;
+import java.io.IOException;
+import java.io.StringWriter;
+import java.io.Writer;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
 import org.apache.maven.artifact.repository.ArtifactRepository;
 import org.apache.maven.artifact.resolver.filter.ArtifactFilter;
 import org.apache.maven.artifact.resolver.filter.ScopeArtifactFilter;
 import org.apache.maven.artifact.versioning.ArtifactVersion;
 import org.apache.maven.artifact.versioning.Restriction;
 import org.apache.maven.artifact.versioning.VersionRange;
+import org.apache.maven.execution.MavenSession;
 import org.apache.maven.plugin.AbstractMojo;
 import org.apache.maven.plugin.MojoExecutionException;
 import org.apache.maven.plugin.MojoFailureException;
@@ -49,17 +58,6 @@ import org.apache.maven.shared.dependenc
 import org.apache.maven.shared.dependency.graph.traversal.FilteringDependencyNodeVisitor;
 import org.apache.maven.shared.dependency.graph.traversal.SerializingDependencyNodeVisitor;
 import org.apache.maven.shared.dependency.graph.traversal.SerializingDependencyNodeVisitor.GraphTokens;
-import org.apache.maven.shared.dependency.tree.DependencyTreeBuilder;
-import org.apache.maven.shared.dependency.tree.DependencyTreeBuilderException;
-import org.apache.maven.shared.dependency.tree.traversal.SerializingDependencyNodeVisitor.TreeTokens;
-
-import java.io.File;
-import java.io.IOException;
-import java.io.StringWriter;
-import java.io.Writer;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
 
 /**
  * Displays the dependency tree for this project.
@@ -80,6 +78,9 @@ public class TreeMojo
     @Parameter( defaultValue = "${project}", readonly = true, required = true )
     private MavenProject project;
 
+    @Parameter( defaultValue = "${session}", readonly = true, required = true )
+    private MavenSession session;
+
     /**
      * The dependency tree builder to use.
      */
@@ -87,12 +88,6 @@ public class TreeMojo
     private DependencyGraphBuilder dependencyGraphBuilder;
 
     /**
-     * The dependency tree builder to use for verbose output.
-     */
-    @Component
-    private DependencyTreeBuilder dependencyTreeBuilder;
-
-    /**
      * If specified, this parameter will cause the dependency tree to be written to the path
specified, instead of
      * writing to the console.
      *
@@ -244,25 +239,16 @@ public class TreeMojo
 
             if ( verbose )
             {
-                // verbose mode force Maven 2 dependency tree component use
-                if ( ! isMaven2x() )
-                {
-                    getLog().warn( "Using Maven 2 dependency tree to get verbose output,
"
-                                       + "which may be inconsistent with actual Maven 3 resolution"
);
-                }
-                dependencyTreeString =
-                    serializeVerboseDependencyTree( dependencyTreeBuilder.buildDependencyTree(
project,
-                                                                                        
      localRepository,
-                                                                                        
      artifactFilter ) );
+                // To fix we probably need a different DependencyCollector in Aether, which
doesn't remove nodes which
+                // have already been resolved.
+                getLog().info( "Verbose not supported since maven-dependency-plugin 3.0"
);
             }
-            else
-            {
-                // non-verbose mode use dependency graph component, which gives consistent
results with Maven version
-                // running
-                rootNode = dependencyGraphBuilder.buildDependencyGraph( project, artifactFilter
);
+            
+            // non-verbose mode use dependency graph component, which gives consistent results
with Maven version
+            // running
+            rootNode = dependencyGraphBuilder.buildDependencyGraph( project, artifactFilter
);
 
-                dependencyTreeString = serializeDependencyTree( rootNode );
-            }
+            dependencyTreeString = serializeDependencyTree( rootNode );
 
             if ( outputFile != null )
             {
@@ -279,10 +265,6 @@ public class TreeMojo
         {
             throw new MojoExecutionException( "Cannot build project dependency graph", exception
);
         }
-        catch ( DependencyTreeBuilderException exception )
-        {
-            throw new MojoExecutionException( "Cannot build project dependency tree", exception
);
-        }
         catch ( IOException exception )
         {
             throw new MojoExecutionException( "Cannot serialise project dependency graph",
exception );
@@ -380,49 +362,6 @@ public class TreeMojo
         return writer.toString();
     }
 
-    /**
-     * Serializes the specified dependency tree to a string.
-     *
-     * @param rootNode the dependency tree root node to serialize
-     * @return the serialized dependency tree
-     */
-    private String serializeVerboseDependencyTree( org.apache.maven.shared.dependency.tree.DependencyNode
rootNode )
-    {
-        StringWriter writer = new StringWriter();
-
-        final TreeTokens treeTokens = toTreeTokens( tokens );
-        org.apache.maven.shared.dependency.tree.traversal.DependencyNodeVisitor visitor =
-            new org.apache.maven.shared.dependency.tree.traversal.SerializingDependencyNodeVisitor(
writer,
-                                                                                        
           treeTokens );
-
-        // TODO: remove the need for this when the serializer can calculate last nodes from
visitor calls only
-        visitor = new org.apache.maven.shared.dependency.tree.traversal.BuildingDependencyNodeVisitor(
visitor );
-
-        org.apache.maven.shared.dependency.tree.filter.DependencyNodeFilter filter =
-            createVerboseDependencyNodeFilter();
-
-        if ( filter != null )
-        {
-            org.apache.maven.shared.dependency.tree.traversal.CollectingDependencyNodeVisitor
collectingVisitor =
-                new org.apache.maven.shared.dependency.tree.traversal.CollectingDependencyNodeVisitor();
-            org.apache.maven.shared.dependency.tree.traversal.DependencyNodeVisitor firstPassVisitor
=
-                new org.apache.maven.shared.dependency.tree.traversal.FilteringDependencyNodeVisitor(
collectingVisitor,
-                                                                                        
             filter );
-            rootNode.accept( firstPassVisitor );
-
-            final List<org.apache.maven.shared.dependency.tree.DependencyNode> nodes
= collectingVisitor.getNodes();
-            org.apache.maven.shared.dependency.tree.filter.DependencyNodeFilter secondPass
=
-                new org.apache.maven.shared.dependency.tree.filter.AncestorOrSelfDependencyNodeFilter(
nodes );
-            visitor =
-                new org.apache.maven.shared.dependency.tree.traversal.FilteringDependencyNodeVisitor(
visitor,
-                                                                                        
             secondPass );
-        }
-
-        rootNode.accept( visitor );
-
-        return writer.toString();
-    }
-
     public DependencyNodeVisitor getSerializingDependencyNodeVisitor( Writer writer )
     {
         if ( "graphml".equals( outputType ) )
@@ -474,39 +413,6 @@ public class TreeMojo
     }
 
     /**
-     * Gets the tree tokens instance for the specified name.
-     *
-     * @param tokens the tree tokens name
-     * @return the <code>TreeTokens</code> instance
-     */
-    private TreeTokens toTreeTokens( String tokens )
-    {
-        TreeTokens treeTokens;
-
-        if ( "whitespace".equals( tokens ) )
-        {
-            getLog().debug( "+ Using whitespace tree tokens" );
-
-            treeTokens =
-                org.apache.maven.shared.dependency.tree.traversal.SerializingDependencyNodeVisitor.WHITESPACE_TOKENS;
-        }
-        else if ( "extended".equals( tokens ) )
-        {
-            getLog().debug( "+ Using extended tree tokens" );
-
-            treeTokens =
-                org.apache.maven.shared.dependency.tree.traversal.SerializingDependencyNodeVisitor.EXTENDED_TOKENS;
-        }
-        else
-        {
-            treeTokens =
-                org.apache.maven.shared.dependency.tree.traversal.SerializingDependencyNodeVisitor.STANDARD_TOKENS;
-        }
-
-        return treeTokens;
-    }
-
-    /**
      * Gets the dependency node filter to use when serializing the dependency graph.
      *
      * @return the dependency node filter, or <code>null</code> if none required
@@ -540,45 +446,6 @@ public class TreeMojo
         return filters.isEmpty() ? null : new AndDependencyNodeFilter( filters );
     }
 
-    /**
-     * Gets the dependency node filter to use when serializing the dependency tree.
-     *
-     * @return the dependency node filter, or <code>null</code> if none required
-     */
-    private org.apache.maven.shared.dependency.tree.filter.DependencyNodeFilter createVerboseDependencyNodeFilter()
-    {
-        List<org.apache.maven.shared.dependency.tree.filter.DependencyNodeFilter> filters
=
-            new ArrayList<org.apache.maven.shared.dependency.tree.filter.DependencyNodeFilter>();
-        org.apache.maven.shared.dependency.tree.filter.DependencyNodeFilter filter;
-
-        // filter includes
-        if ( includes != null )
-        {
-            List<String> patterns = Arrays.asList( includes.split( "," ) );
-
-            getLog().debug( "+ Filtering dependency tree by artifact include patterns: "
+ patterns );
-
-            ArtifactFilter artifactFilter = new StrictPatternIncludesArtifactFilter( patterns
);
-            filter = new org.apache.maven.shared.dependency.tree.filter.ArtifactDependencyNodeFilter(
artifactFilter );
-            filters.add( filter );
-        }
-
-        // filter excludes
-        if ( excludes != null )
-        {
-            List<String> patterns = Arrays.asList( excludes.split( "," ) );
-
-            getLog().debug( "+ Filtering dependency tree by artifact exclude patterns: "
+ patterns );
-
-            ArtifactFilter artifactFilter = new StrictPatternExcludesArtifactFilter( patterns
);
-            filter = new org.apache.maven.shared.dependency.tree.filter.ArtifactDependencyNodeFilter(
artifactFilter );
-            filters.add( filter );
-        }
-
-        return filters.isEmpty() ? null
-                        : new org.apache.maven.shared.dependency.tree.filter.AndDependencyNodeFilter(
filters );
-    }
-
     //following is required because the version handling in maven code
     //doesn't work properly. I ripped it out of the enforcer rules.
 



Mime
View raw message