You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by sl...@apache.org on 2019/07/12 16:43:10 UTC
[maven] 01/10: [MNG-6675] Make Resolver debug log messages for
projects and plugins consistent
This is an automated email from the ASF dual-hosted git repository.
slachiewicz pushed a commit to branch jenkins-buld-error-wip
in repository https://gitbox.apache.org/repos/asf/maven.git
commit 4eeb21e68dc20e17a56d3e49dbd924555153ff98
Author: Christian Schulte <cs...@schulte.it>
AuthorDate: Thu Jun 22 02:31:30 2017 +0200
[MNG-6675] Make Resolver debug log messages for projects and plugins consistent
This closes #124 and closes #253
---
.../DefaultPluginDependenciesResolver.java | 65 +++++++++++++++++++++-
.../DefaultProjectDependenciesResolver.java | 38 ++++++++-----
2 files changed, 87 insertions(+), 16 deletions(-)
diff --git a/maven-core/src/main/java/org/apache/maven/plugin/internal/DefaultPluginDependenciesResolver.java b/maven-core/src/main/java/org/apache/maven/plugin/internal/DefaultPluginDependenciesResolver.java
index b79b15f..808c09d 100644
--- a/maven-core/src/main/java/org/apache/maven/plugin/internal/DefaultPluginDependenciesResolver.java
+++ b/maven-core/src/main/java/org/apache/maven/plugin/internal/DefaultPluginDependenciesResolver.java
@@ -19,6 +19,7 @@ package org.apache.maven.plugin.internal;
* under the License.
*/
+import java.util.Collection;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
@@ -30,6 +31,7 @@ import org.apache.maven.plugin.PluginResolutionException;
import org.codehaus.plexus.component.annotations.Component;
import org.codehaus.plexus.component.annotations.Requirement;
import org.codehaus.plexus.logging.Logger;
+import org.codehaus.plexus.util.StringUtils;
import org.eclipse.aether.DefaultRepositorySystemSession;
import org.eclipse.aether.RepositorySystem;
import org.eclipse.aether.RepositorySystemSession;
@@ -54,6 +56,7 @@ import org.eclipse.aether.resolution.DependencyResolutionException;
import org.eclipse.aether.util.artifact.JavaScopes;
import org.eclipse.aether.util.filter.AndDependencyFilter;
import org.eclipse.aether.util.filter.ScopeDependencyFilter;
+import org.eclipse.aether.util.graph.manager.DependencyManagerUtils;
import org.eclipse.aether.util.graph.selector.AndDependencySelector;
import org.eclipse.aether.util.graph.transformer.ChainedDependencyGraphTransformer;
import org.eclipse.aether.util.repository.SimpleArtifactDescriptorPolicy;
@@ -221,6 +224,7 @@ public class DefaultPluginDependenciesResolver
return node;
}
+ // Keep this class in sync with org.apache.maven.project.DefaultProjectDependenciesResolver.GraphLogger
class GraphLogger
implements DependencyVisitor
{
@@ -234,10 +238,67 @@ public class DefaultPluginDependenciesResolver
org.eclipse.aether.graph.Dependency dep = node.getDependency();
if ( dep != null )
{
- Artifact art = dep.getArtifact();
+ org.eclipse.aether.artifact.Artifact art = dep.getArtifact();
buffer.append( art );
- buffer.append( ':' ).append( dep.getScope() );
+ if ( StringUtils.isNotEmpty( dep.getScope() ) )
+ {
+ buffer.append( ':' ).append( dep.getScope() );
+ }
+
+ if ( dep.isOptional() )
+ {
+ buffer.append( " (optional)" );
+ }
+
+ // TODO We currently cannot tell which <dependencyManagement> section contained the management
+ // information. When the resolver provides this information, these log messages should be updated
+ // to contain it.
+ if ( ( node.getManagedBits() & DependencyNode.MANAGED_SCOPE ) == DependencyNode.MANAGED_SCOPE )
+ {
+ final String premanagedScope = DependencyManagerUtils.getPremanagedScope( node );
+ buffer.append( " (scope managed from " );
+ buffer.append( StringUtils.defaultString( premanagedScope, "default" ) );
+ buffer.append( ')' );
+ }
+
+ if ( ( node.getManagedBits() & DependencyNode.MANAGED_VERSION ) == DependencyNode.MANAGED_VERSION )
+ {
+ final String premanagedVersion = DependencyManagerUtils.getPremanagedVersion( node );
+ buffer.append( " (version managed from " );
+ buffer.append( StringUtils.defaultString( premanagedVersion, "default" ) );
+ buffer.append( ')' );
+ }
+
+ if ( ( node.getManagedBits() & DependencyNode.MANAGED_OPTIONAL ) == DependencyNode.MANAGED_OPTIONAL )
+ {
+ final Boolean premanagedOptional = DependencyManagerUtils.getPremanagedOptional( node );
+ buffer.append( " (optionality managed from " );
+ buffer.append( StringUtils.defaultString( premanagedOptional, "default" ) );
+ buffer.append( ')' );
+ }
+
+ if ( ( node.getManagedBits() & DependencyNode.MANAGED_EXCLUSIONS )
+ == DependencyNode.MANAGED_EXCLUSIONS )
+ {
+ final Collection<org.eclipse.aether.graph.Exclusion> premanagedExclusions =
+ DependencyManagerUtils.getPremanagedExclusions( node );
+
+ buffer.append( " (exclusions managed from " );
+ buffer.append( StringUtils.defaultString( premanagedExclusions, "default" ) );
+ buffer.append( ')' );
+ }
+
+ if ( ( node.getManagedBits() & DependencyNode.MANAGED_PROPERTIES )
+ == DependencyNode.MANAGED_PROPERTIES )
+ {
+ final Map<String, String> premanagedProperties =
+ DependencyManagerUtils.getPremanagedProperties( node );
+
+ buffer.append( " (properties managed from " );
+ buffer.append( StringUtils.defaultString( premanagedProperties, "default" ) );
+ buffer.append( ')' );
+ }
}
logger.debug( buffer.toString() );
diff --git a/maven-core/src/main/java/org/apache/maven/project/DefaultProjectDependenciesResolver.java b/maven-core/src/main/java/org/apache/maven/project/DefaultProjectDependenciesResolver.java
index 4bb9609..0409fb8 100644
--- a/maven-core/src/main/java/org/apache/maven/project/DefaultProjectDependenciesResolver.java
+++ b/maven-core/src/main/java/org/apache/maven/project/DefaultProjectDependenciesResolver.java
@@ -228,6 +228,7 @@ public class DefaultProjectDependenciesResolver
}
}
+ // Keep this class in sync with org.apache.maven.plugin.internal.DefaultPluginDependenciesResolver.GraphLogger
class GraphLogger
implements DependencyVisitor
{
@@ -251,10 +252,18 @@ public class DefaultProjectDependenciesResolver
org.eclipse.aether.artifact.Artifact art = dep.getArtifact();
buffer.append( art );
- buffer.append( ':' ).append( dep.getScope() );
+ if ( StringUtils.isNotEmpty( dep.getScope() ) )
+ {
+ buffer.append( ':' ).append( dep.getScope() );
+ }
+
+ if ( dep.isOptional() )
+ {
+ buffer.append( " (optional)" );
+ }
// TODO We currently cannot tell which <dependencyManagement> section contained the management
- // information. When resolver 1.1 provides this information, these log messages should be updated
+ // information. When the resolver provides this information, these log messages should be updated
// to contain it.
if ( ( node.getManagedBits() & DependencyNode.MANAGED_SCOPE ) == DependencyNode.MANAGED_SCOPE )
{
@@ -281,24 +290,25 @@ public class DefaultProjectDependenciesResolver
}
if ( ( node.getManagedBits() & DependencyNode.MANAGED_EXCLUSIONS )
- == DependencyNode.MANAGED_EXCLUSIONS )
+ == DependencyNode.MANAGED_EXCLUSIONS )
{
- // TODO As of resolver 1.1, use DependencyManagerUtils.getPremanagedExclusions( node ).
- // The resolver 1.0.x releases do not record premanaged state of exclusions.
- buffer.append( " (exclusions managed)" );
+ final Collection<org.eclipse.aether.graph.Exclusion> premanagedExclusions =
+ DependencyManagerUtils.getPremanagedExclusions( node );
+
+ buffer.append( " (exclusions managed from " );
+ buffer.append( StringUtils.defaultString( premanagedExclusions, "default" ) );
+ buffer.append( ')' );
}
if ( ( node.getManagedBits() & DependencyNode.MANAGED_PROPERTIES )
- == DependencyNode.MANAGED_PROPERTIES )
+ == DependencyNode.MANAGED_PROPERTIES )
{
- // TODO As of resolver 1.1, use DependencyManagerUtils.getPremanagedProperties( node ).
- // The resolver 1.0.x releases do not record premanaged state of properties.
- buffer.append( " (properties managed)" );
- }
+ final Map<String, String> premanagedProperties =
+ DependencyManagerUtils.getPremanagedProperties( node );
- if ( dep.isOptional() )
- {
- buffer.append( " (optional)" );
+ buffer.append( " (properties managed from " );
+ buffer.append( StringUtils.defaultString( premanagedProperties, "default" ) );
+ buffer.append( ')' );
}
}
else