You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by rf...@apache.org on 2021/06/05 15:24:16 UTC
[maven-dependency-tree] 01/01: Enable all tests and fix them. Only
verbose-IT is failing
This is an automated email from the ASF dual-hosted git repository.
rfscholte pushed a commit to branch fix-tests
in repository https://gitbox.apache.org/repos/asf/maven-dependency-tree.git
commit 3794e8aad8ad38a7b4920dffdaded843431f6715
Author: rfscholte <rf...@apache.org>
AuthorDate: Sat Jun 5 17:23:59 2021 +0200
Enable all tests and fix them. Only verbose-IT is failing
---
pom.xml | 20 ----
src/it/maven-version/invoker.properties | 2 +-
src/it/maven-version/pom.xml | 13 +--
src/it/mshared-167/expected-M2.txt | 18 ---
.../mshared-167/{expected-M3.txt => expected.txt} | 0
src/it/mshared-167/invoker.properties | 2 +-
src/it/mshared-167/pom.xml | 31 +----
src/it/mshared-167/verify.bsh | 9 +-
src/it/reactor/module-z-deps-y/pom.xml | 15 +--
src/it/reactor/verify.bsh | 9 +-
.../invoker.properties | 0
.../resolve-extension => setup-extension}/pom.xml | 0
.../ResolveDependenciesLifecycleParticipant.java | 12 +-
.../invoker.properties | 2 +-
.../resolve-extension => setup-plugin}/pom.xml | 72 +++++-------
.../src/main/java/graph/GraphMojo.java | 105 +++++++++++++++++
src/it/verbose/pom.xml | 17 +--
.../graph/DependencyCollectorBuilder.java | 4 +-
.../dependency/graph/internal/ArtifactKey.java | 11 +-
.../dependency/graph/internal/ConflictData.java | 77 ++++++++++++
.../DefaultDependencyCollectorBuilder.java | 6 +-
.../graph/internal/DefaultDependencyNode.java | 67 +++++++----
.../Maven31DependencyCollectorBuilder.java | 19 ++-
.../internal/Maven3DependencyCollectorBuilder.java | 3 +-
.../graph/internal/VerboseDependencyNode.java | 129 +++++++++++++++++++++
25 files changed, 428 insertions(+), 215 deletions(-)
diff --git a/pom.xml b/pom.xml
index 40ffc3b..a99ae47 100644
--- a/pom.xml
+++ b/pom.xml
@@ -116,14 +116,6 @@
</executions>
</plugin>
<plugin>
- <artifactId>maven-surefire-plugin</artifactId>
- <configuration>
- <excludes>
- <exclude>**/DefaultDependencyTreeBuilderTest*</exclude><!-- FIXME: conflict on DefaultArtifactFactory between maven-core 3.x and maven-artifact 2.x -->
- </excludes>
- </configuration>
- </plugin>
- <plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-invoker-plugin</artifactId>
<configuration>
@@ -134,18 +126,6 @@
<postBuildHookScript>verify</postBuildHookScript>
<localRepositoryPath>${project.build.directory}/local-repo</localRepositoryPath>
<settingsFile>src/it/settings.xml</settingsFile>
- <setupIncludes>
- <setupInclude>reactor/resolve-extension/pom.xml</setupInclude>
- </setupIncludes>
- <pomIncludes>
- <pomInclude>*/pom.xml</pomInclude>
- </pomIncludes>
- <pomExcludes> <!-- Tree ITs, must be transformed to graph ITs -->
- <pomExclude>maven-version/pom.xml</pomExclude>
- <pomExclude>mshared-167/pom.xml</pomExclude>
- <pomExclude>reactor/pom.xml</pomExclude>
- <pomExclude>verbose/pom.xml</pomExclude>
- </pomExcludes>
<properties>
<maven.compiler.source>${maven.compiler.source}</maven.compiler.source>
<maven.compiler.target>${maven.compiler.target}</maven.compiler.target>
diff --git a/src/it/maven-version/invoker.properties b/src/it/maven-version/invoker.properties
index 6e1a8cd..38ca093 100644
--- a/src/it/maven-version/invoker.properties
+++ b/src/it/maven-version/invoker.properties
@@ -15,4 +15,4 @@
# specific language governing permissions and limitations
# under the License.
-invoker.goals = clean dependency:tree
+invoker.goals = org.apache.maven.its.dependency-tree:graph-maven-plugin:graph
diff --git a/src/it/maven-version/pom.xml b/src/it/maven-version/pom.xml
index 289994a..2396604 100644
--- a/src/it/maven-version/pom.xml
+++ b/src/it/maven-version/pom.xml
@@ -70,19 +70,12 @@
<pluginManagement>
<plugins>
<plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-dependency-plugin</artifactId>
- <version>2.8</version>
+ <groupId>org.apache.maven.its.dependency-tree</groupId>
+ <artifactId>graph-maven-plugin</artifactId>
+ <version>1.0-SNAPSHOT</version>
<configuration>
<outputFile>target/tree.txt</outputFile>
</configuration>
- <dependencies>
- <dependency>
- <groupId>@project.groupId@</groupId>
- <artifactId>@project.artifactId@</artifactId>
- <version>@project.version@</version>
- </dependency>
- </dependencies>
</plugin>
</plugins>
</pluginManagement>
diff --git a/src/it/mshared-167/expected-M2.txt b/src/it/mshared-167/expected-M2.txt
deleted file mode 100644
index da04271..0000000
--- a/src/it/mshared-167/expected-M2.txt
+++ /dev/null
@@ -1,18 +0,0 @@
-org.apache.maven.its.dependency-tree:mshared-167:jar:1.0-SNAPSHOT
-\- org.apache.xmlgraphics:batik-swing:jar:1.7:compile
- +- org.apache.xmlgraphics:batik-awt-util:jar:1.7:compile
- +- org.apache.xmlgraphics:batik-bridge:jar:1.7:compile
- | +- org.apache.xmlgraphics:batik-anim:jar:1.7:compile
- | +- org.apache.xmlgraphics:batik-parser:jar:1.7:compile
- | +- org.apache.xmlgraphics:batik-script:jar:1.7:compile
- | +- org.apache.xmlgraphics:batik-xml:jar:1.7:compile
- | \- xalan:xalan:jar:2.6.0:compile
- +- org.apache.xmlgraphics:batik-css:jar:1.7:compile
- +- org.apache.xmlgraphics:batik-dom:jar:1.7:compile
- +- org.apache.xmlgraphics:batik-ext:jar:1.7:compile
- +- org.apache.xmlgraphics:batik-gui-util:jar:1.7:compile
- +- org.apache.xmlgraphics:batik-gvt:jar:1.7:compile
- +- org.apache.xmlgraphics:batik-svg-dom:jar:1.7:compile
- +- org.apache.xmlgraphics:batik-util:jar:1.7:compile
- +- xml-apis:xml-apis:jar:1.3.04:compile
- \- xml-apis:xml-apis-ext:jar:1.3.04:compile
diff --git a/src/it/mshared-167/expected-M3.txt b/src/it/mshared-167/expected.txt
similarity index 100%
rename from src/it/mshared-167/expected-M3.txt
rename to src/it/mshared-167/expected.txt
diff --git a/src/it/mshared-167/invoker.properties b/src/it/mshared-167/invoker.properties
index 6e1a8cd..38ca093 100644
--- a/src/it/mshared-167/invoker.properties
+++ b/src/it/mshared-167/invoker.properties
@@ -15,4 +15,4 @@
# specific language governing permissions and limitations
# under the License.
-invoker.goals = clean dependency:tree
+invoker.goals = org.apache.maven.its.dependency-tree:graph-maven-plugin:graph
diff --git a/src/it/mshared-167/pom.xml b/src/it/mshared-167/pom.xml
index 132e479..9f641f8 100644
--- a/src/it/mshared-167/pom.xml
+++ b/src/it/mshared-167/pom.xml
@@ -35,7 +35,6 @@
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
- <outputFile>target/tree-M2.txt</outputFile>
</properties>
<dependencies>
@@ -50,36 +49,14 @@
<pluginManagement>
<plugins>
<plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-dependency-plugin</artifactId>
- <version>2.8</version>
+ <groupId>org.apache.maven.its.dependency-tree</groupId>
+ <artifactId>graph-maven-plugin</artifactId>
+ <version>1.0-SNAPSHOT</version>
<configuration>
- <outputFile>${outputFile}</outputFile>
+ <outputFile>target/tree.txt</outputFile>
</configuration>
- <dependencies>
- <dependency>
- <groupId>@project.groupId@</groupId>
- <artifactId>@project.artifactId@</artifactId>
- <version>@project.version@</version>
- </dependency>
- </dependencies>
</plugin>
</plugins>
</pluginManagement>
</build>
-
- <profiles>
- <profile>
- <id>maven-3</id>
- <activation>
- <file>
- <!-- This employs that the basedir expression is only recognized by Maven 3.x (see MNG-2363) -->
- <exists>${basedir}</exists>
- </file>
- </activation>
- <properties>
- <outputFile>target/tree-M3.txt</outputFile>
- </properties>
- </profile>
- </profiles>
</project>
diff --git a/src/it/mshared-167/verify.bsh b/src/it/mshared-167/verify.bsh
index c5f7249..958b237 100644
--- a/src/it/mshared-167/verify.bsh
+++ b/src/it/mshared-167/verify.bsh
@@ -21,13 +21,8 @@ import java.io.*;
import org.codehaus.plexus.util.*;
-File outputFile = new File( basedir, "target/tree-M2.txt" );
-File expectedFile = new File( basedir, "expected-M2.txt" );
-if ( ! outputFile.exists() )
-{
- outputFile = new File( basedir, "target/tree-M3.txt" );
- expectedFile = new File( basedir, "expected-M3.txt" );
-}
+File outputFile = new File( basedir, "target/tree.txt" );
+File expectedFile = new File( basedir, "expected.txt" );
String actual = FileUtils.fileRead( outputFile );
String expected = FileUtils.fileRead( expectedFile );
diff --git a/src/it/reactor/module-z-deps-y/pom.xml b/src/it/reactor/module-z-deps-y/pom.xml
index f6788fc..9279585 100644
--- a/src/it/reactor/module-z-deps-y/pom.xml
+++ b/src/it/reactor/module-z-deps-y/pom.xml
@@ -51,16 +51,9 @@
<build>
<plugins>
<plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-dependency-plugin</artifactId>
- <version>2.8</version>
- <dependencies>
- <dependency>
- <groupId>@project.groupId@</groupId>
- <artifactId>@project.artifactId@</artifactId>
- <version>@project.version@</version>
- </dependency>
- </dependencies>
+ <groupId>org.apache.maven.its.dependency-tree</groupId>
+ <artifactId>graph-maven-plugin</artifactId>
+ <version>1.0-SNAPSHOT</version>
<executions>
<execution>
<id>default</id>
@@ -69,7 +62,7 @@
<outputFile>target/tree.txt</outputFile>
</configuration>
<goals>
- <goal>tree</goal>
+ <goal>graph</goal>
</goals>
</execution>
</executions>
diff --git a/src/it/reactor/verify.bsh b/src/it/reactor/verify.bsh
index cffa5c5..845be14 100644
--- a/src/it/reactor/verify.bsh
+++ b/src/it/reactor/verify.bsh
@@ -34,11 +34,6 @@ if ( !actual.equals( expected ) )
throw new Exception( "Unexpected dependency tree" );
}
-String resolved = FileUtils.fileRead( new File( basedir, "resolved-module-z-deps-y.txt" ) );
+File resolved = new File( basedir, "resolved-module-z-deps-y.txt" );
-if ( !"Could not resolve following dependencies: [org.apache.maven.its.dependency-tree:module-y-deps-x:jar:1.0-SNAPSHOT (compile), org.apache.maven.its.dependency-tree:module-x:jar:1.0-SNAPSHOT (compile)]".equals( resolved ) )
-{
- throw new Exception( "unexpected content in resolved-module-z-deps-y.txt written by ResolveDependenciesLifecycleParticipant" );
-}
-
-return true;
+return !resolved.exists();
diff --git a/src/it/reactor/resolve-extension/invoker.properties b/src/it/setup-extension/invoker.properties
similarity index 100%
rename from src/it/reactor/resolve-extension/invoker.properties
rename to src/it/setup-extension/invoker.properties
diff --git a/src/it/reactor/resolve-extension/pom.xml b/src/it/setup-extension/pom.xml
similarity index 100%
copy from src/it/reactor/resolve-extension/pom.xml
copy to src/it/setup-extension/pom.xml
diff --git a/src/it/reactor/resolve-extension/src/main/java/org/apache/maven/its/deptree/ResolveDependenciesLifecycleParticipant.java b/src/it/setup-extension/src/main/java/org/apache/maven/its/deptree/ResolveDependenciesLifecycleParticipant.java
similarity index 88%
rename from src/it/reactor/resolve-extension/src/main/java/org/apache/maven/its/deptree/ResolveDependenciesLifecycleParticipant.java
rename to src/it/setup-extension/src/main/java/org/apache/maven/its/deptree/ResolveDependenciesLifecycleParticipant.java
index fba7dfa..8ae9c42 100644
--- a/src/it/reactor/resolve-extension/src/main/java/org/apache/maven/its/deptree/ResolveDependenciesLifecycleParticipant.java
+++ b/src/it/setup-extension/src/main/java/org/apache/maven/its/deptree/ResolveDependenciesLifecycleParticipant.java
@@ -76,16 +76,6 @@ public final class ResolveDependenciesLifecycleParticipant extends AbstractMaven
log.info( "building dependency graph for project " + project.getArtifact() );
File resolved = new File( basedir, "resolved-" + project.getArtifactId() + ".txt" );
- try
- {
- log.info( "building with reactor projects" );
- // No need to filter our search. We want to resolve all artifacts.
- dependencyGraphBuilder.buildDependencyGraph( buildingRequest, null, projects );
- }
- catch ( DependencyGraphBuilderException e )
- {
- throw new MavenExecutionException( "Could not resolve dependencies for project: " + project, e );
- }
try
{
@@ -95,7 +85,7 @@ public final class ResolveDependenciesLifecycleParticipant extends AbstractMaven
}
catch ( DependencyGraphBuilderException e )
{
- log.info( "expected resolution failure: " + e.getMessage() );
+ log.info( "unexpected resolution failure: " + e.getMessage() );
try
{
diff --git a/src/it/mshared-167/invoker.properties b/src/it/setup-plugin/invoker.properties
similarity index 95%
copy from src/it/mshared-167/invoker.properties
copy to src/it/setup-plugin/invoker.properties
index 6e1a8cd..d5d6ca5 100644
--- a/src/it/mshared-167/invoker.properties
+++ b/src/it/setup-plugin/invoker.properties
@@ -15,4 +15,4 @@
# specific language governing permissions and limitations
# under the License.
-invoker.goals = clean dependency:tree
+invoker.goals = install
diff --git a/src/it/reactor/resolve-extension/pom.xml b/src/it/setup-plugin/pom.xml
similarity index 65%
rename from src/it/reactor/resolve-extension/pom.xml
rename to src/it/setup-plugin/pom.xml
index f71bd43..1a0098a 100644
--- a/src/it/reactor/resolve-extension/pom.xml
+++ b/src/it/setup-plugin/pom.xml
@@ -24,66 +24,48 @@
<modelVersion>4.0.0</modelVersion>
<groupId>org.apache.maven.its.dependency-tree</groupId>
- <artifactId>resolve-extension</artifactId>
+ <artifactId>graph-maven-plugin</artifactId>
<version>1.0-SNAPSHOT</version>
- <packaging>jar</packaging>
-
- <name>Resolve Dependency from Reactor Check Extension</name>
- <description>
- Extension to check that maven-dependency-tree resolves deps that only exist within the reactor.
- </description>
+ <packaging>maven-plugin</packaging>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
- <maven.version>3.0.4</maven.version>
</properties>
- <dependencyManagement>
- </dependencyManagement>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-plugin-plugin</artifactId>
+ <version>3.6.1</version>
+ <executions>
+ <execution>
+ <id>default-descriptor</id>
+ <phase>process-classes</phase>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
<dependencies>
<dependency>
- <groupId>org.apache.maven</groupId>
- <artifactId>maven-core</artifactId>
- <version>${maven.version}</version>
- <scope>provided</scope>
+ <groupId>org.apache.maven.shared</groupId>
+ <artifactId>maven-dependency-tree</artifactId>
+ <version>@project.version@</version>
</dependency>
<dependency>
- <groupId>org.codehaus.plexus</groupId>
- <artifactId>plexus-container-default</artifactId>
- <version>1.0-alpha-9-stable-1</version>
+ <groupId>org.apache.maven.plugin-tools</groupId>
+ <artifactId>maven-plugin-annotations</artifactId>
+ <version>3.5.2</version>
<scope>provided</scope>
</dependency>
<dependency>
- <groupId>org.apache.maven.shared</groupId>
- <artifactId>maven-dependency-tree</artifactId>
- <version>@project.version@</version>
+ <groupId>org.apache.maven</groupId>
+ <artifactId>maven-core</artifactId>
+ <version>3.0.5</version>
+ <scope>provided</scope>
</dependency>
</dependencies>
- <build>
- <pluginManagement>
- <plugins>
- <plugin>
- <groupId>org.codehaus.plexus</groupId>
- <artifactId>plexus-component-metadata</artifactId>
- <version>1.7.1</version>
- </plugin>
- </plugins>
- </pluginManagement>
-
- <plugins>
- <plugin>
- <groupId>org.codehaus.plexus</groupId>
- <artifactId>plexus-component-metadata</artifactId>
- <executions>
- <execution>
- <goals>
- <goal>generate-metadata</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
- </plugins>
- </build>
</project>
diff --git a/src/it/setup-plugin/src/main/java/graph/GraphMojo.java b/src/it/setup-plugin/src/main/java/graph/GraphMojo.java
new file mode 100644
index 0000000..6cdc0a2
--- /dev/null
+++ b/src/it/setup-plugin/src/main/java/graph/GraphMojo.java
@@ -0,0 +1,105 @@
+package graph;
+
+import java.io.File;
+import java.io.FileWriter;
+import java.io.Writer;
+
+/*
+ * 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.artifact.resolver.filter.ArtifactFilter;
+import org.apache.maven.execution.MavenSession;
+import org.apache.maven.plugin.AbstractMojo;
+import org.apache.maven.plugins.annotations.Component;
+import org.apache.maven.plugins.annotations.Mojo;
+import org.apache.maven.plugins.annotations.Parameter;
+import org.apache.maven.project.DefaultProjectBuildingRequest;
+import org.apache.maven.project.MavenProject;
+import org.apache.maven.project.ProjectBuildingRequest;
+import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.shared.dependency.graph.DependencyCollectorBuilder;
+import org.apache.maven.shared.dependency.graph.DependencyGraphBuilder;
+import org.apache.maven.shared.dependency.graph.DependencyNode;
+import org.apache.maven.shared.dependency.graph.traversal.SerializingDependencyNodeVisitor;
+
+@Mojo( name = "graph" )
+public class GraphMojo
+ extends AbstractMojo
+{
+
+ @Parameter( defaultValue = "${session}", readonly = true, required = true )
+ private MavenSession session;
+
+ @Parameter( defaultValue = "${project}", readonly = true, required = true )
+ private MavenProject project;
+
+ @Parameter
+ private ArtifactFilter artifactFilter;
+
+ @Parameter
+ private File outputFile;
+
+ @Parameter
+ private boolean verbose;
+
+ @Component
+ private DependencyGraphBuilder graphBuilder;
+
+ @Component
+ private DependencyCollectorBuilder collectorBuilder;
+
+ @Override
+ public void execute() throws MojoExecutionException
+ {
+ // Code currently assumes project has been set...
+ ProjectBuildingRequest buildingRequest = new DefaultProjectBuildingRequest( session.getProjectBuildingRequest() );
+ buildingRequest.setProject( project );
+
+ try
+ {
+ DependencyNode node;
+ if ( verbose )
+ {
+ node = collectorBuilder.collectDependencyGraph( buildingRequest, artifactFilter );
+ }
+ else
+ {
+ node = graphBuilder.buildDependencyGraph( buildingRequest, artifactFilter );
+ }
+
+ if ( outputFile != null )
+ {
+ outputFile.getParentFile().mkdirs();
+
+ try ( Writer writer = new FileWriter( outputFile ) )
+ {
+ node.accept( new SerializingDependencyNodeVisitor( writer,
+ SerializingDependencyNodeVisitor.STANDARD_TOKENS ) );
+ }
+ }
+ }
+ catch ( Exception e ) // Catch all is good enough for IT
+ {
+ throw new MojoExecutionException( "Failed to build dependency graph", e );
+ }
+ }
+
+
+
+}
\ No newline at end of file
diff --git a/src/it/verbose/pom.xml b/src/it/verbose/pom.xml
index c57704f..26a918a 100644
--- a/src/it/verbose/pom.xml
+++ b/src/it/verbose/pom.xml
@@ -81,16 +81,9 @@
<build>
<plugins>
<plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-dependency-plugin</artifactId>
- <version>2.8</version>
- <dependencies>
- <dependency>
- <groupId>@project.groupId@</groupId>
- <artifactId>@project.artifactId@</artifactId>
- <version>@project.version@</version>
- </dependency>
- </dependencies>
+ <groupId>org.apache.maven.its.dependency-tree</groupId>
+ <artifactId>graph-maven-plugin</artifactId>
+ <version>1.0-SNAPSHOT</version>
<executions>
<execution>
<id>verbose</id>
@@ -100,7 +93,7 @@
<verbose>true</verbose>
</configuration>
<goals>
- <goal>tree</goal>
+ <goal>graph</goal>
</goals>
</execution>
<execution>
@@ -110,7 +103,7 @@
<outputFile>target/tree-default.txt</outputFile>
</configuration>
<goals>
- <goal>tree</goal>
+ <goal>graph</goal>
</goals>
</execution>
</executions>
diff --git a/src/main/java/org/apache/maven/shared/dependency/graph/DependencyCollectorBuilder.java b/src/main/java/org/apache/maven/shared/dependency/graph/DependencyCollectorBuilder.java
index 43cfb40..516a6f6 100644
--- a/src/main/java/org/apache/maven/shared/dependency/graph/DependencyCollectorBuilder.java
+++ b/src/main/java/org/apache/maven/shared/dependency/graph/DependencyCollectorBuilder.java
@@ -19,7 +19,6 @@ package org.apache.maven.shared.dependency.graph;
* under the License.
*/
-import org.apache.maven.artifact.repository.ArtifactRepository;
import org.apache.maven.artifact.resolver.filter.ArtifactFilter;
import org.apache.maven.project.ProjectBuildingRequest;
@@ -43,8 +42,7 @@ public interface DependencyCollectorBuilder
* @return the raw dependency tree
* @throws DependencyGraphBuilderException if some of the dependencies could not be collected.
*/
- DependencyNode collectDependencyGraph( ArtifactRepository localRepository, ProjectBuildingRequest buildingRequest,
- ArtifactFilter filter )
+ DependencyNode collectDependencyGraph( ProjectBuildingRequest buildingRequest, ArtifactFilter filter )
throws DependencyCollectorBuilderException;
}
diff --git a/src/main/java/org/apache/maven/shared/dependency/graph/internal/ArtifactKey.java b/src/main/java/org/apache/maven/shared/dependency/graph/internal/ArtifactKey.java
index 885796f..40f9f3c 100644
--- a/src/main/java/org/apache/maven/shared/dependency/graph/internal/ArtifactKey.java
+++ b/src/main/java/org/apache/maven/shared/dependency/graph/internal/ArtifactKey.java
@@ -19,6 +19,8 @@ package org.apache.maven.shared.dependency.graph.internal;
* under the License.
*/
+import java.util.Objects;
+
import org.apache.maven.project.MavenProject;
/**
@@ -26,17 +28,17 @@ import org.apache.maven.project.MavenProject;
*/
final class ArtifactKey
{
- private static final int HASH_PRIME = 31;
-
private final String groupId;
private final String artifactId;
private final String version;
+ private final int hashCode;
ArtifactKey( String groupId, String artifactId, String version )
{
this.groupId = groupId;
this.artifactId = artifactId;
this.version = version;
+ this.hashCode = Objects.hash( groupId, artifactId, version );
}
ArtifactKey( MavenProject project )
@@ -65,9 +67,6 @@ final class ArtifactKey
@Override
public int hashCode()
{
- int result = groupId.hashCode();
- result = HASH_PRIME * result + artifactId.hashCode();
- result = HASH_PRIME * result + version.hashCode();
- return result;
+ return hashCode;
}
}
diff --git a/src/main/java/org/apache/maven/shared/dependency/graph/internal/ConflictData.java b/src/main/java/org/apache/maven/shared/dependency/graph/internal/ConflictData.java
new file mode 100644
index 0000000..4b2ac2a
--- /dev/null
+++ b/src/main/java/org/apache/maven/shared/dependency/graph/internal/ConflictData.java
@@ -0,0 +1,77 @@
+package org.apache.maven.shared.dependency.graph.internal;
+
+/*
+ * 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.
+ */
+
+/**
+ * Excplicit subset of Aethers DependencyNode.getData()
+ *
+ * @author Robert Scholte
+ *
+ */
+public class ConflictData
+{
+ private String winnerVersion;
+
+ private String originalScope;
+
+ private String ignoredScope;
+
+ private Boolean originaOptionality;
+
+ public ConflictData( String winnerVersion )
+ {
+ this.winnerVersion = winnerVersion;
+ }
+
+ public String getWinnerVersion()
+ {
+ return winnerVersion;
+ }
+
+ public String getOriginalScope()
+ {
+ return originalScope;
+ }
+
+ public void setOriginalScope( String originalScope )
+ {
+ this.originalScope = originalScope;
+ }
+
+ public Boolean getOriginaOptionality()
+ {
+ return originaOptionality;
+ }
+
+ public void setOriginaOptionality( Boolean originaOptionality )
+ {
+ this.originaOptionality = originaOptionality;
+ }
+
+ public String getIgnoredScope()
+ {
+ return ignoredScope;
+ }
+
+ public void setIgnoredScope( String ignoredScope )
+ {
+ this.ignoredScope = ignoredScope;
+ }
+}
diff --git a/src/main/java/org/apache/maven/shared/dependency/graph/internal/DefaultDependencyCollectorBuilder.java b/src/main/java/org/apache/maven/shared/dependency/graph/internal/DefaultDependencyCollectorBuilder.java
index e29cc9d..13b3a51 100644
--- a/src/main/java/org/apache/maven/shared/dependency/graph/internal/DefaultDependencyCollectorBuilder.java
+++ b/src/main/java/org/apache/maven/shared/dependency/graph/internal/DefaultDependencyCollectorBuilder.java
@@ -19,7 +19,6 @@ package org.apache.maven.shared.dependency.graph.internal;
* under the License.
*/
-import org.apache.maven.artifact.repository.ArtifactRepository;
import org.apache.maven.artifact.resolver.filter.ArtifactFilter;
import org.apache.maven.project.MavenProject;
import org.apache.maven.project.ProjectBuildingRequest;
@@ -50,8 +49,7 @@ public class DefaultDependencyCollectorBuilder
protected PlexusContainer container;
@Override
- public DependencyNode collectDependencyGraph( ArtifactRepository localRepository,
- ProjectBuildingRequest buildingRequest, ArtifactFilter filter )
+ public DependencyNode collectDependencyGraph( ProjectBuildingRequest buildingRequest, ArtifactFilter filter )
throws DependencyCollectorBuilderException
{
try
@@ -70,7 +68,7 @@ public class DefaultDependencyCollectorBuilder
+ effectiveGraphBuilder.getClass().getSimpleName() );
}
- return effectiveGraphBuilder.collectDependencyGraph( localRepository, buildingRequest, filter );
+ return effectiveGraphBuilder.collectDependencyGraph( buildingRequest, filter );
}
catch ( ComponentLookupException e )
{
diff --git a/src/main/java/org/apache/maven/shared/dependency/graph/internal/DefaultDependencyNode.java b/src/main/java/org/apache/maven/shared/dependency/graph/internal/DefaultDependencyNode.java
index 440eaea..3b4cc5a 100644
--- a/src/main/java/org/apache/maven/shared/dependency/graph/internal/DefaultDependencyNode.java
+++ b/src/main/java/org/apache/maven/shared/dependency/graph/internal/DefaultDependencyNode.java
@@ -78,6 +78,16 @@ public class DefaultDependencyNode implements DependencyNode
this.optional = optional;
this.exclusions = exclusions;
}
+
+ // user to refer to winner
+ public DefaultDependencyNode( Artifact artifact )
+ {
+ this.artifact = artifact;
+ this.parent = null;
+ this.premanagedScope = null;
+ this.premanagedVersion = null;
+ this.versionConstraint = null;
+ }
/**
* Applies the specified dependency node visitor to this dependency node and its children.
@@ -179,29 +189,29 @@ public class DefaultDependencyNode implements DependencyNode
buffer.append( artifact );
- ItemAppender appender = new ItemAppender( buffer, " (", "; ", ")" );
-
- if ( getPremanagedVersion() != null )
- {
- appender.append( "version managed from ", getPremanagedVersion() );
- }
-
- if ( getPremanagedScope() != null )
- {
- appender.append( "scope managed from ", getPremanagedScope() );
- }
-
- if ( getVersionConstraint() != null )
- {
- appender.append( "version selected from constraint ", getVersionConstraint() );
- }
-
-
- appender.flush();
- if ( optional != null && optional )
- {
- buffer.append( " (optional) " );
- }
+// ItemAppender appender = new ItemAppender( buffer, " (", "; ", ")" );
+//
+// if ( getPremanagedVersion() != null )
+// {
+// appender.append( "version managed from ", getPremanagedVersion() );
+// }
+//
+// if ( getPremanagedScope() != null )
+// {
+// appender.append( "scope managed from ", getPremanagedScope() );
+// }
+//
+// if ( getVersionConstraint() != null )
+// {
+// appender.append( "version selected from constraint ", getVersionConstraint() );
+// }
+//
+//
+// appender.flush();
+// if ( optional != null && optional )
+// {
+// buffer.append( " (optional) " );
+// }
return buffer.toString();
}
@@ -209,7 +219,7 @@ public class DefaultDependencyNode implements DependencyNode
/**
* Utility class to concatenate a number of parameters with separator tokens.
*/
- private static class ItemAppender
+ static class ItemAppender
{
private StringBuilder buffer;
@@ -231,6 +241,15 @@ public class DefaultDependencyNode implements DependencyNode
appended = false;
}
+ public ItemAppender append( String item1 )
+ {
+ appendToken();
+
+ buffer.append( item1 );
+
+ return this;
+ }
+
public ItemAppender append( String item1, String item2 )
{
appendToken();
diff --git a/src/main/java/org/apache/maven/shared/dependency/graph/internal/Maven31DependencyCollectorBuilder.java b/src/main/java/org/apache/maven/shared/dependency/graph/internal/Maven31DependencyCollectorBuilder.java
index 15c173d..a09da7b 100644
--- a/src/main/java/org/apache/maven/shared/dependency/graph/internal/Maven31DependencyCollectorBuilder.java
+++ b/src/main/java/org/apache/maven/shared/dependency/graph/internal/Maven31DependencyCollectorBuilder.java
@@ -89,8 +89,7 @@ public class Maven31DependencyCollectorBuilder
}
@Override
- public DependencyNode collectDependencyGraph( ArtifactRepository localRepository,
- ProjectBuildingRequest buildingRequest, ArtifactFilter filter )
+ public DependencyNode collectDependencyGraph( ProjectBuildingRequest buildingRequest, ArtifactFilter filter )
throws DependencyCollectorBuilderException
{
DefaultRepositorySystemSession session = null;
@@ -276,10 +275,20 @@ public class Maven31DependencyCollectorBuilder
}
}
- DefaultDependencyNode current =
- new DefaultDependencyNode( parent, artifact, premanagedVersion, premanagedScope,
+ org.eclipse.aether.graph.DependencyNode winner =
+ (org.eclipse.aether.graph.DependencyNode) node.getData().get( ConflictResolver.NODE_DATA_WINNER );
+ String winnerNode = null;
+ if ( winner != null )
+ {
+ winnerNode = winner.getArtifact().getBaseVersion();
+ }
+
+ ConflictData data = new ConflictData( winnerNode );
+
+ VerboseDependencyNode current =
+ new VerboseDependencyNode( parent, artifact, premanagedVersion, premanagedScope,
getVersionSelectedFromRange( node.getVersionConstraint() ), optional,
- exclusions );
+ exclusions, data );
List<DependencyNode> nodes = new ArrayList<DependencyNode>( node.getChildren().size() );
for ( org.eclipse.aether.graph.DependencyNode child : node.getChildren() )
diff --git a/src/main/java/org/apache/maven/shared/dependency/graph/internal/Maven3DependencyCollectorBuilder.java b/src/main/java/org/apache/maven/shared/dependency/graph/internal/Maven3DependencyCollectorBuilder.java
index 24c0d65..272fa08 100644
--- a/src/main/java/org/apache/maven/shared/dependency/graph/internal/Maven3DependencyCollectorBuilder.java
+++ b/src/main/java/org/apache/maven/shared/dependency/graph/internal/Maven3DependencyCollectorBuilder.java
@@ -89,8 +89,7 @@ public class Maven3DependencyCollectorBuilder
}
@Override
- public DependencyNode collectDependencyGraph( ArtifactRepository localRepository,
- ProjectBuildingRequest buildingRequest, ArtifactFilter filter )
+ public DependencyNode collectDependencyGraph( ProjectBuildingRequest buildingRequest, ArtifactFilter filter )
throws DependencyCollectorBuilderException
{
try
diff --git a/src/main/java/org/apache/maven/shared/dependency/graph/internal/VerboseDependencyNode.java b/src/main/java/org/apache/maven/shared/dependency/graph/internal/VerboseDependencyNode.java
new file mode 100644
index 0000000..79b7723
--- /dev/null
+++ b/src/main/java/org/apache/maven/shared/dependency/graph/internal/VerboseDependencyNode.java
@@ -0,0 +1,129 @@
+package org.apache.maven.shared.dependency.graph.internal;
+
+/*
+ * 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.List;
+
+import org.apache.maven.artifact.Artifact;
+import org.apache.maven.model.Exclusion;
+import org.apache.maven.shared.dependency.graph.DependencyNode;
+
+class VerboseDependencyNode
+ extends DefaultDependencyNode
+{
+
+ private final ConflictData data;
+
+ VerboseDependencyNode( DependencyNode parent, Artifact artifact, String premanagedVersion,
+ String premanagedScope, String versionConstraint, Boolean optional,
+ List<Exclusion> exclusions, ConflictData data )
+ {
+ super( parent, artifact, premanagedVersion, premanagedScope, versionConstraint, optional, exclusions );
+
+ this.data = data;
+ }
+
+ @Override
+ public String toNodeString()
+ {
+ StringBuilder buffer = new StringBuilder();
+
+ boolean included = ( data.getWinnerVersion() == null );
+
+ if ( !included )
+ {
+ buffer.append( '(' );
+ }
+
+ buffer.append( getArtifact() );
+
+ ItemAppender appender = new ItemAppender( buffer, included ? " (" : " - ", "; ", included ? ")" : "" );
+
+ if ( getPremanagedVersion() != null )
+ {
+ appender.append( "version managed from ", getPremanagedVersion() );
+ }
+
+ if ( getPremanagedScope() != null )
+ {
+ appender.append( "scope managed from ", getPremanagedScope() );
+ }
+
+ if ( data.getOriginalScope() != null )
+ {
+ appender.append( "scope updated from ", data.getOriginalScope() );
+ }
+
+ if ( data.getIgnoredScope() != null )
+ {
+ appender.append( "scope not updated to ", data.getIgnoredScope() );
+ }
+
+// if ( getVersionSelectedFromRange() != null )
+// {
+// appender.append( "version selected from range ", getVersionSelectedFromRange().toString() );
+// appender.append( "available versions ", getAvailableVersions().toString() );
+// }
+
+ if ( data.getWinnerVersion() != null )
+ {
+ String winnerVersion = data.getWinnerVersion();
+ if ( winnerVersion.equals( getArtifact().getVersion() ) )
+ {
+ appender.append( "omitted for duplicate" );
+ }
+ else
+ {
+ appender.append( "omitted for conflict with ", winnerVersion );
+ }
+ }
+
+// switch ( data.getState() )
+// {
+// case ConflictData.INCLUDED:
+// break;
+//
+// case ConflictData.OMITTED_FOR_DUPLICATE:
+// appender.append( "omitted for duplicate" );
+// break;
+//
+//// case ConflictData.OMITTED_FOR_CONFLICT:
+//// appender.append( "omitted for conflict with ", relatedArtifact.getVersion() );
+//// break;
+//
+// case ConflictData.OMITTED_FOR_CYCLE:
+// appender.append( "omitted for cycle" );
+// break;
+//
+// default:
+// break;
+// }
+
+ appender.flush();
+
+ if ( !included )
+ {
+ buffer.append( ')' );
+ }
+
+ return buffer.toString();
+ }
+
+}