elharo commented on a change in pull request #92:
URL: 
https://github.com/apache/maven-dependency-plugin/pull/92#discussion_r467126945



##########
File path: src/it/projects/tree-verbose/verify.bsh
##########
@@ -27,11 +27,10 @@ String expected = FileUtils.fileRead( new File( basedir, 
"expected.txt" ) );
 actual = actual.replaceAll( "[\n\r]+", "\n" );
 expected = expected.replaceAll( "[\n\r]+", "\n" );
 
-System.out.println( "Checking dependency tree..." );
-
 if ( !actual.equals( expected ) )
 {
-    throw new Exception( "Unexpected dependency tree" );
+    throw new Exception( "Unexpected dependency tree." + 
System.lineSeperator() + "Expected:" + System.lineSeperator()

Review comment:
       separator

##########
File path: pom.xml
##########
@@ -423,12 +415,10 @@ 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>
               <pomIncludes>
                 <pomInclude>*/pom.xml</pomInclude>
-                <pomInclude>purge-local-repository-without-pom</pomInclude>
+                
<!--<pomInclude>purge-local-repository-without-pom</pomInclude>-->

Review comment:
       What's up with this test? It should either be uncommented or removed. 

##########
File path: src/it/projects/unpack-custom-ear/verify.groovy
##########
@@ -17,5 +17,11 @@
  * under the License.
  */
 def buildLog = new File( basedir, 'build.log' )
+String fileContents = buildLog.text
 assert buildLog.exists()
-assert buildLog.text.contains( "[DEBUG] Found unArchiver by type: " )
+assert buildLog.length() != 0
+
+println "BuildLog Length:"

Review comment:
       we should probably take these two out now that debugging is done. 
Assertions can stay

##########
File path: 
src/main/java/org/apache/maven/plugins/dependency/tree/verbose/RepositoryUtility.java
##########
@@ -0,0 +1,208 @@
+package org.apache.maven.plugins.dependency.tree.verbose;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.maven.repository.internal.MavenRepositorySystemUtils;
+import org.eclipse.aether.DefaultRepositorySystemSession;
+import org.eclipse.aether.RepositorySystem;
+import org.eclipse.aether.RepositorySystemSession;
+import org.eclipse.aether.artifact.Artifact;
+import org.eclipse.aether.artifact.DefaultArtifact;
+import org.eclipse.aether.collection.DependencySelector;
+import org.eclipse.aether.repository.LocalRepository;
+import org.eclipse.aether.repository.RemoteRepository;
+import org.eclipse.aether.resolution.VersionRangeRequest;
+import org.eclipse.aether.resolution.VersionRangeResolutionException;
+import org.eclipse.aether.resolution.VersionRangeResult;
+import org.eclipse.aether.util.graph.selector.AndDependencySelector;
+import org.eclipse.aether.util.graph.selector.ExclusionDependencySelector;
+import org.eclipse.aether.util.graph.selector.ScopeDependencySelector;
+import 
org.eclipse.aether.util.graph.transformer.ChainedDependencyGraphTransformer;
+import org.eclipse.aether.util.graph.transformer.JavaDependencyContextRefiner;
+import org.eclipse.aether.version.Version;
+
+import java.io.File;
+import java.io.IOException;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.util.Arrays;
+
+/**
+ * Aether initialization. This uses org.eclipse.aether:aether-api:0.9.0.M2. 
There are many other versions of Aether
+ * from Sonatype and the Eclipse Project, eventually you may want to change it 
over to
+ * org.apache.maven.resolver:maven-resolver-api.
+ */
+final class RepositoryUtility
+{
+
+    public static final RemoteRepository CENTRAL = new 
RemoteRepository.Builder( "central", "default",
+            "https://repo1.maven.org/maven2/"; ).build();
+
+    private RepositoryUtility()
+    {
+    }
+
+    private static DefaultRepositorySystemSession 
createDefaultRepositorySystemSession( RepositorySystem system )
+    {
+        DefaultRepositorySystemSession session = 
MavenRepositorySystemUtils.newSession();
+        LocalRepository localRepository = new LocalRepository( 
findLocalRepository() );
+        session.setLocalRepositoryManager( system.newLocalRepositoryManager( 
session, localRepository ) );
+        return session;
+    }
+
+    /**
+     * Opens a new Maven repository session that looks for the local 
repository in the customary ~/.m2 directory. If not
+     * found, it creates an initially empty repository in a temporary location.
+     */
+    private static DefaultRepositorySystemSession newSession( RepositorySystem 
system )
+    {
+        DefaultRepositorySystemSession session = 
createDefaultRepositorySystemSession( system );
+        return session;
+    }
+
+    /**
+     * Open a new Maven repository session for full dependency graph 
resolution.
+     *
+     * @see {@link VerboseDependencyGraphBuilder}
+     */
+    static DefaultRepositorySystemSession newSessionForFullDependency( 
RepositorySystem system )
+    {
+        // This combination of DependencySelector comes from the default 
specified in
+        // `MavenRepositorySystemUtils.newSession`.
+        // LinkageChecker needs to include 'provided'-scope and optional 
dependencies.
+        DependencySelector dependencySelector = new AndDependencySelector(
+                // ScopeDependencySelector takes exclusions. 'Provided' scope 
is not here to avoid
+                // false positive in LinkageChecker.
+                new ScopeDependencySelector(), // removed "test" parameter
+                new ExclusionDependencySelector() );
+
+        return newSession( system, dependencySelector );
+    }
+
+    private static DefaultRepositorySystemSession newSession( RepositorySystem 
system,
+                                                              
DependencySelector dependencySelector )
+    {
+        DefaultRepositorySystemSession session = 
createDefaultRepositorySystemSession( system );
+        session.setDependencySelector( dependencySelector );
+
+        // By default, Maven's MavenRepositorySystemUtils.newSession() returns 
a session with
+        // ChainedDependencyGraphTransformer(ConflictResolver(...), 
JavaDependencyContextRefiner()).
+        // Because the full dependency graph does not resolve conflicts of 
versions, this session does
+        // not use ConflictResolver.
+        session.setDependencyGraphTransformer(
+                new ChainedDependencyGraphTransformer( new 
CycleBreakerGraphTransformer(), // Avoids StackOverflowError
+                        new JavaDependencyContextRefiner() ) );
+
+        // No dependency management in the full dependency graph
+        session.setDependencyManager( null );
+
+        return session;
+    }
+
+    private static String findLocalRepository()
+    {
+        // TODO is there Maven code for this?

Review comment:
       we should resolve this todo. 

##########
File path: src/it/projects/tree-verbose-small/verify.bsh
##########
@@ -0,0 +1,35 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import java.io.*;
+import org.codehaus.plexus.util.*;
+
+String actual = FileUtils.fileRead( new File( basedir, "target/tree.txt" ) );
+String expected = FileUtils.fileRead( new File( basedir, "expected.txt" ) );
+
+actual = actual.replaceAll( "[\n\r]+", "\n" );
+expected = expected.replaceAll( "[\n\r]+", "\n" );
+
+if ( !actual.equals( expected ) )
+{
+    throw new Exception( "Unexpected dependency tree." + 
System.lineSeperator() + "Expected:" + System.lineSeperator()

Review comment:
       I think this and below should be `System.lineSeparator​`
   i.e. seperator --> separator
   
   It's concerning that nothing caught this.
   
   
   

##########
File path: 
src/main/java/org/apache/maven/plugins/dependency/tree/verbose/RepositoryUtility.java
##########
@@ -0,0 +1,208 @@
+package org.apache.maven.plugins.dependency.tree.verbose;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.maven.repository.internal.MavenRepositorySystemUtils;
+import org.eclipse.aether.DefaultRepositorySystemSession;
+import org.eclipse.aether.RepositorySystem;
+import org.eclipse.aether.RepositorySystemSession;
+import org.eclipse.aether.artifact.Artifact;
+import org.eclipse.aether.artifact.DefaultArtifact;
+import org.eclipse.aether.collection.DependencySelector;
+import org.eclipse.aether.repository.LocalRepository;
+import org.eclipse.aether.repository.RemoteRepository;
+import org.eclipse.aether.resolution.VersionRangeRequest;
+import org.eclipse.aether.resolution.VersionRangeResolutionException;
+import org.eclipse.aether.resolution.VersionRangeResult;
+import org.eclipse.aether.util.graph.selector.AndDependencySelector;
+import org.eclipse.aether.util.graph.selector.ExclusionDependencySelector;
+import org.eclipse.aether.util.graph.selector.ScopeDependencySelector;
+import 
org.eclipse.aether.util.graph.transformer.ChainedDependencyGraphTransformer;
+import org.eclipse.aether.util.graph.transformer.JavaDependencyContextRefiner;
+import org.eclipse.aether.version.Version;
+
+import java.io.File;
+import java.io.IOException;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.util.Arrays;
+
+/**
+ * Aether initialization. This uses org.eclipse.aether:aether-api:0.9.0.M2. 
There are many other versions of Aether
+ * from Sonatype and the Eclipse Project, eventually you may want to change it 
over to
+ * org.apache.maven.resolver:maven-resolver-api.
+ */
+final class RepositoryUtility
+{
+
+    public static final RemoteRepository CENTRAL = new 
RemoteRepository.Builder( "central", "default",
+            "https://repo1.maven.org/maven2/"; ).build();
+
+    private RepositoryUtility()
+    {
+    }
+
+    private static DefaultRepositorySystemSession 
createDefaultRepositorySystemSession( RepositorySystem system )
+    {
+        DefaultRepositorySystemSession session = 
MavenRepositorySystemUtils.newSession();
+        LocalRepository localRepository = new LocalRepository( 
findLocalRepository() );
+        session.setLocalRepositoryManager( system.newLocalRepositoryManager( 
session, localRepository ) );
+        return session;
+    }
+
+    /**
+     * Opens a new Maven repository session that looks for the local 
repository in the customary ~/.m2 directory. If not
+     * found, it creates an initially empty repository in a temporary location.
+     */
+    private static DefaultRepositorySystemSession newSession( RepositorySystem 
system )
+    {
+        DefaultRepositorySystemSession session = 
createDefaultRepositorySystemSession( system );
+        return session;
+    }
+
+    /**
+     * Open a new Maven repository session for full dependency graph 
resolution.
+     *
+     * @see {@link VerboseDependencyGraphBuilder}
+     */
+    static DefaultRepositorySystemSession newSessionForFullDependency( 
RepositorySystem system )
+    {
+        // This combination of DependencySelector comes from the default 
specified in
+        // `MavenRepositorySystemUtils.newSession`.
+        // LinkageChecker needs to include 'provided'-scope and optional 
dependencies.
+        DependencySelector dependencySelector = new AndDependencySelector(
+                // ScopeDependencySelector takes exclusions. 'Provided' scope 
is not here to avoid
+                // false positive in LinkageChecker.
+                new ScopeDependencySelector(), // removed "test" parameter
+                new ExclusionDependencySelector() );
+
+        return newSession( system, dependencySelector );
+    }
+
+    private static DefaultRepositorySystemSession newSession( RepositorySystem 
system,
+                                                              
DependencySelector dependencySelector )
+    {
+        DefaultRepositorySystemSession session = 
createDefaultRepositorySystemSession( system );
+        session.setDependencySelector( dependencySelector );
+
+        // By default, Maven's MavenRepositorySystemUtils.newSession() returns 
a session with
+        // ChainedDependencyGraphTransformer(ConflictResolver(...), 
JavaDependencyContextRefiner()).
+        // Because the full dependency graph does not resolve conflicts of 
versions, this session does
+        // not use ConflictResolver.
+        session.setDependencyGraphTransformer(
+                new ChainedDependencyGraphTransformer( new 
CycleBreakerGraphTransformer(), // Avoids StackOverflowError
+                        new JavaDependencyContextRefiner() ) );
+
+        // No dependency management in the full dependency graph
+        session.setDependencyManager( null );
+
+        return session;
+    }
+
+    private static String findLocalRepository()
+    {
+        // TODO is there Maven code for this?
+        Path home = Paths.get( System.getProperty( "user.home" ) );
+        Path localRepo = home.resolve( ".m2" ).resolve( "repository" );
+        if ( Files.isDirectory( localRepo ) )
+        {
+            return localRepo.toAbsolutePath().toString();
+        }
+        else
+        {
+            return makeTemporaryLocalRepository();

Review comment:
       This one concerns me. It might not be appropriate in the context of a 
maven plugin. Unlike cloud-opensource-java, there really should be a local repo 
already. 

##########
File path: 
src/main/java/org/apache/maven/plugins/dependency/tree/verbose/OsProperties.java
##########
@@ -0,0 +1,89 @@
+package org.apache.maven.plugins.dependency.tree.verbose;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import java.util.HashMap;
+import java.util.Locale;
+import java.util.Map;
+
+/**
+ * Platform-dependent project properties normalized from ${os.name} and 
${os.arch}. Netty uses these to select
+ * system-specific dependencies through the
+ * <a href='https://github.com/trustin/os-maven-plugin'>os-maven-plugin</a>.
+ */
+final class OsProperties
+{
+
+    public static Map<String, String> detectOsProperties()

Review comment:
       non-public

##########
File path: 
src/main/java/org/apache/maven/plugins/dependency/tree/verbose/RepositoryUtility.java
##########
@@ -0,0 +1,208 @@
+package org.apache.maven.plugins.dependency.tree.verbose;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.maven.repository.internal.MavenRepositorySystemUtils;
+import org.eclipse.aether.DefaultRepositorySystemSession;
+import org.eclipse.aether.RepositorySystem;
+import org.eclipse.aether.RepositorySystemSession;
+import org.eclipse.aether.artifact.Artifact;
+import org.eclipse.aether.artifact.DefaultArtifact;
+import org.eclipse.aether.collection.DependencySelector;
+import org.eclipse.aether.repository.LocalRepository;
+import org.eclipse.aether.repository.RemoteRepository;
+import org.eclipse.aether.resolution.VersionRangeRequest;
+import org.eclipse.aether.resolution.VersionRangeResolutionException;
+import org.eclipse.aether.resolution.VersionRangeResult;
+import org.eclipse.aether.util.graph.selector.AndDependencySelector;
+import org.eclipse.aether.util.graph.selector.ExclusionDependencySelector;
+import org.eclipse.aether.util.graph.selector.ScopeDependencySelector;
+import 
org.eclipse.aether.util.graph.transformer.ChainedDependencyGraphTransformer;
+import org.eclipse.aether.util.graph.transformer.JavaDependencyContextRefiner;
+import org.eclipse.aether.version.Version;
+
+import java.io.File;
+import java.io.IOException;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.util.Arrays;
+
+/**
+ * Aether initialization. This uses org.eclipse.aether:aether-api:0.9.0.M2. 
There are many other versions of Aether
+ * from Sonatype and the Eclipse Project, eventually you may want to change it 
over to
+ * org.apache.maven.resolver:maven-resolver-api.
+ */
+final class RepositoryUtility
+{
+
+    public static final RemoteRepository CENTRAL = new 
RemoteRepository.Builder( "central", "default",

Review comment:
       non-public

##########
File path: 
src/main/java/org/apache/maven/plugins/dependency/tree/verbose/VerboseDependencyGraphBuilder.java
##########
@@ -0,0 +1,332 @@
+package org.apache.maven.plugins.dependency.tree.verbose;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.maven.model.DependencyManagement;
+import org.apache.maven.model.Model;
+import org.apache.maven.model.Repository;
+import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.project.MavenProject;
+import org.eclipse.aether.DefaultRepositorySystemSession;
+import org.eclipse.aether.RepositorySystem;
+import org.eclipse.aether.artifact.Artifact;
+import org.eclipse.aether.artifact.DefaultArtifact;
+import org.eclipse.aether.collection.CollectRequest;
+import org.eclipse.aether.graph.DefaultDependencyNode;
+import org.eclipse.aether.graph.Dependency;
+import org.eclipse.aether.graph.DependencyNode;
+import org.eclipse.aether.repository.RemoteRepository;
+import org.eclipse.aether.resolution.DependencyRequest;
+import org.eclipse.aether.resolution.DependencyResult;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import static 
org.apache.maven.plugins.dependency.tree.verbose.RepositoryUtility.mavenRepositoryFromUrl;
+
+/**
+ * Builds the VerboseDependencyGraph
+ */
+public class VerboseDependencyGraphBuilder

Review comment:
       does this need to be public?

##########
File path: 
src/main/java/org/apache/maven/plugins/dependency/tree/verbose/VerboseGraphSerializer.java
##########
@@ -0,0 +1,311 @@
+package org.apache.maven.plugins.dependency.tree.verbose;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.eclipse.aether.artifact.Artifact;
+import org.eclipse.aether.graph.DependencyNode;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+import java.util.Queue;
+import java.util.Set;
+
+/**
+ * Parses dependency graph and outputs in text format for end user to review.
+ */
+public final class VerboseGraphSerializer

Review comment:
       does this need to be public?




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Reply via email to