From e227f55c1d1cc4a772b281f47c49452c4c19cb54 Mon Sep 17 00:00:00 2001 From: Brett Leslie Porter Date: Sun, 6 Jul 2008 18:43:17 +0000 Subject: [PATCH] [MARTIFACT-25] cache failed POM downloads in the local repository, obeying the policy for checking for updates on them git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@674333 13f79535-47bb-0310-9956-ffa450edef68 --- .../project/artifact/MavenMetadataSource.java | 34 ++++++++++++------- 1 file changed, 21 insertions(+), 13 deletions(-) diff --git a/maven-project/src/main/java/org/apache/maven/project/artifact/MavenMetadataSource.java b/maven-project/src/main/java/org/apache/maven/project/artifact/MavenMetadataSource.java index 4baa016cf3..aed494b92c 100644 --- a/maven-project/src/main/java/org/apache/maven/project/artifact/MavenMetadataSource.java +++ b/maven-project/src/main/java/org/apache/maven/project/artifact/MavenMetadataSource.java @@ -133,14 +133,7 @@ public class MavenMetadataSource } catch ( InvalidProjectModelException e ) { - if ( strictlyEnforceThePresenceOfAValidMavenPOM ) - { - throw new ArtifactMetadataRetrievalException( "Invalid POM file for artifact: '" + - artifact.getDependencyConflictId() + "' Reason: " + e.getMessage(), e, artifact ); - } - - getLogger().warn( "POM for \'" + pomArtifact + - "\' is invalid. It will be ignored for artifact resolution. Reason: " + e.getMessage() ); + handleInvalidOrMissingMavenPOM( artifact, e ); if ( getLogger().isDebugEnabled() ) { @@ -167,11 +160,7 @@ public class MavenMetadataSource } catch ( ProjectBuildingException e ) { - if ( strictlyEnforceThePresenceOfAValidMavenPOM ) - { - throw new ArtifactMetadataRetrievalException( "Unable to read the metadata file for artifact '" + - artifact.getDependencyConflictId() + "': " + e.getMessage(), e, artifact ); - } + handleInvalidOrMissingMavenPOM( artifact, e ); } if ( project != null ) @@ -293,6 +282,25 @@ public class MavenMetadataSource return result; } + private void handleInvalidOrMissingMavenPOM( Artifact artifact, ProjectBuildingException e ) + throws ArtifactMetadataRetrievalException + { + if ( strictlyEnforceThePresenceOfAValidMavenPOM ) + { + throw new ArtifactMetadataRetrievalException( "Invalid POM file for artifact: '" + + artifact.getDependencyConflictId() + "': " + e.getMessage(), e, artifact ); + } + else + { + getLogger().warn( + "\n\tDEPRECATION: The POM for the artifact '" + + artifact.getDependencyConflictId() + + "' was invalid or not found on any repositories.\n" + + "\tThis may not be supported by future versions of Maven and should be corrected as soon as possible.\n" + + "\tError given: " + e.getMessage() + "\n" ); + } + } + private void loadProjectBuilder() throws ComponentLookupException {