From 4f49a5c76e41795d07dac8ee8f99c5f068b16f7d Mon Sep 17 00:00:00 2001 From: Benjamin Bentmann Date: Fri, 21 Aug 2009 16:53:53 +0000 Subject: [PATCH] o Improved logging git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@806639 13f79535-47bb-0310-9956-ffa450edef68 --- .../legacy/DefaultWagonManager.java | 19 +++++++++-------- .../maven/project/DefaultProjectBuilder.java | 5 +++-- .../project/artifact/MavenMetadataSource.java | 21 +++++++++++++++++-- 3 files changed, 32 insertions(+), 13 deletions(-) diff --git a/maven-compat/src/main/java/org/apache/maven/repository/legacy/DefaultWagonManager.java b/maven-compat/src/main/java/org/apache/maven/repository/legacy/DefaultWagonManager.java index cb66a634a1..b9196c4308 100644 --- a/maven-compat/src/main/java/org/apache/maven/repository/legacy/DefaultWagonManager.java +++ b/maven-compat/src/main/java/org/apache/maven/repository/legacy/DefaultWagonManager.java @@ -87,7 +87,8 @@ public class DefaultWagonManager if ( !policy.isEnabled() ) { - logger.debug( "Skipping disabled repository " + repository.getId() ); + logger.debug( "Skipping disabled repository " + repository.getId() + " for resolution of " + + artifact.getId() ); } // If the artifact is a snapshot, we need to determine whether it's time to check this repository for an update: @@ -95,7 +96,7 @@ public class DefaultWagonManager // 2. If the updateInterval has been exceeded since the last check for this artifact on this repository, then check. else if ( artifact.isSnapshot() && updateCheckIsRequired ) { - logger.debug( "Trying repository " + repository.getId() ); + logger.debug( "Trying repository " + repository.getId() + " for resolution of " + artifact.getId() ); try { @@ -106,7 +107,7 @@ public class DefaultWagonManager updateCheckManager.touch( artifact, repository ); } - logger.debug( " Artifact resolved" ); + logger.debug( " Artifact " + artifact.getId() + " resolved" ); artifact.setResolved( true ); } @@ -120,7 +121,7 @@ public class DefaultWagonManager // if POM is not present locally, try and get it if it's forced, out of date, or has not been attempted yet if ( updateCheckManager.isPomUpdateRequired( artifact, repository ) ) { - logger.debug( "Trying repository " + repository.getId() ); + logger.debug( "Trying repository " + repository.getId() + " for resolution of " + artifact.getId() ); try { @@ -134,7 +135,7 @@ public class DefaultWagonManager throw e; } - logger.debug( " Artifact resolved" ); + logger.debug( " Artifact " + artifact.getId() + " resolved" ); artifact.setResolved( true ); } @@ -154,11 +155,11 @@ public class DefaultWagonManager // don't write touch-file for release artifacts. else if ( !artifact.isSnapshot() ) { - logger.debug( "Trying repository " + repository.getId() ); + logger.debug( "Trying repository " + repository.getId() + " for resolution of " + artifact.getId() ); getRemoteFile( repository, artifact.getFile(), remotePath, downloadMonitor, policy.getChecksumPolicy(), false ); - logger.debug( " Artifact resolved" ); + logger.debug( " Artifact " + artifact.getId() + " resolved" ); artifact.setResolved( true ); } @@ -183,7 +184,7 @@ public class DefaultWagonManager // This one we will eat when looking through remote repositories // because we want to cycle through them all before squawking. - logger.debug( "Unable to get resource '" + artifact.getId() + "' from repository " + repository.getId() + " (" + repository.getUrl() + ")", e ); + logger.debug( "Unable to find resource '" + artifact.getId() + "' in repository " + repository.getId() + " (" + repository.getUrl() + ")", e ); } catch ( TransferFailedException e ) { @@ -385,7 +386,7 @@ public class DefaultWagonManager } catch ( ResourceDoesNotExistException sha1TryException ) { - logger.debug( "SHA1 not found, trying MD5", sha1TryException ); + logger.debug( "SHA1 not found, trying MD5: " + sha1TryException.getMessage() ); // if this IS NOT a ChecksumFailedException, it was a problem with transfer/read of the checksum // file...we'll try again with the MD5 checksum. diff --git a/maven-core/src/main/java/org/apache/maven/project/DefaultProjectBuilder.java b/maven-core/src/main/java/org/apache/maven/project/DefaultProjectBuilder.java index 6c3c64d949..ae608222c4 100644 --- a/maven-core/src/main/java/org/apache/maven/project/DefaultProjectBuilder.java +++ b/maven-core/src/main/java/org/apache/maven/project/DefaultProjectBuilder.java @@ -119,7 +119,7 @@ public class DefaultProjectBuilder } catch ( ModelBuildingException e ) { - throw new ProjectBuildingException( e.getModelId(), "Encountered POM errors", pomFile, e ); + throw new ProjectBuildingException( e.getModelId(), e.getMessage(), pomFile, e ); } modelProblems = result.getProblems(); @@ -237,7 +237,8 @@ public class DefaultProjectBuilder } catch ( ArtifactResolutionException e ) { - throw new ProjectBuildingException( artifact.getId(), "Error resolving project artifact.", e ); + throw new ProjectBuildingException( artifact.getId(), + "Error resolving project artifact: " + e.getMessage(), e ); } return build( artifact.getFile(), false, configuration ); diff --git a/maven-core/src/main/java/org/apache/maven/project/artifact/MavenMetadataSource.java b/maven-core/src/main/java/org/apache/maven/project/artifact/MavenMetadataSource.java index 12123d9964..d2e27f96eb 100644 --- a/maven-core/src/main/java/org/apache/maven/project/artifact/MavenMetadataSource.java +++ b/maven-core/src/main/java/org/apache/maven/project/artifact/MavenMetadataSource.java @@ -38,6 +38,7 @@ import org.apache.maven.artifact.repository.metadata.Metadata; import org.apache.maven.artifact.repository.metadata.RepositoryMetadata; import org.apache.maven.artifact.repository.metadata.RepositoryMetadataManager; import org.apache.maven.artifact.repository.metadata.RepositoryMetadataResolutionException; +import org.apache.maven.artifact.resolver.ArtifactResolutionException; import org.apache.maven.artifact.resolver.filter.AndArtifactFilter; import org.apache.maven.artifact.resolver.filter.ArtifactFilter; import org.apache.maven.artifact.resolver.filter.ExcludesArtifactFilter; @@ -478,8 +479,24 @@ public class MavenMetadataSource } catch ( ProjectBuildingException e ) { - // bad/incompatible POM - logger.debug( "Invalid artifact metadata for " + artifact.getId() + ": " + e.getMessage() ); + String message; + + // missing/incompatible POM (e.g. a Maven 1 POM) + if ( e.getCause() instanceof ArtifactResolutionException ) + { + message = "Missing artifact metadata for " + artifact.getId(); + } + else + { + message = "Invalid artifact metadata for " + artifact.getId(); + } + + if ( logger.isDebugEnabled() ) + { + message += ": " + e.getMessage(); + } + + logger.warn( message ); } if ( project != null )