maven-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bentm...@apache.org
Subject svn commit: r998850 - in /maven/maven-3/trunk: maven-aether-provider/src/main/java/org/apache/maven/repository/internal/ maven-core/src/main/java/org/apache/maven/project/ maven-model-builder/src/main/java/org/apache/maven/model/building/
Date Mon, 20 Sep 2010 09:40:52 GMT
Author: bentmann
Date: Mon Sep 20 09:40:51 2010
New Revision: 998850

URL: http://svn.apache.org/viewvc?rev=998850&view=rev
Log:
[MNG-4825] Relative path errors could be more explicit

Modified:
    maven/maven-3/trunk/maven-aether-provider/src/main/java/org/apache/maven/repository/internal/DefaultModelResolver.java
    maven/maven-3/trunk/maven-core/src/main/java/org/apache/maven/project/ReactorModelResolver.java
    maven/maven-3/trunk/maven-model-builder/src/main/java/org/apache/maven/model/building/DefaultModelBuilder.java

Modified: maven/maven-3/trunk/maven-aether-provider/src/main/java/org/apache/maven/repository/internal/DefaultModelResolver.java
URL: http://svn.apache.org/viewvc/maven/maven-3/trunk/maven-aether-provider/src/main/java/org/apache/maven/repository/internal/DefaultModelResolver.java?rev=998850&r1=998849&r2=998850&view=diff
==============================================================================
--- maven/maven-3/trunk/maven-aether-provider/src/main/java/org/apache/maven/repository/internal/DefaultModelResolver.java
(original)
+++ maven/maven-3/trunk/maven-aether-provider/src/main/java/org/apache/maven/repository/internal/DefaultModelResolver.java
Mon Sep 20 09:40:51 2010
@@ -116,8 +116,7 @@ class DefaultModelResolver
         }
         catch ( ArtifactResolutionException e )
         {
-            throw new UnresolvableModelException( "Failed to resolve POM for " + groupId
+ ":" + artifactId + ":"
-                + version + " due to " + e.getMessage(), groupId, artifactId, version, e
);
+            throw new UnresolvableModelException( e.getMessage(), groupId, artifactId, version,
e );
         }
 
         File pomFile = pomArtifact.getFile();

Modified: maven/maven-3/trunk/maven-core/src/main/java/org/apache/maven/project/ReactorModelResolver.java
URL: http://svn.apache.org/viewvc/maven/maven-3/trunk/maven-core/src/main/java/org/apache/maven/project/ReactorModelResolver.java?rev=998850&r1=998849&r2=998850&view=diff
==============================================================================
--- maven/maven-3/trunk/maven-core/src/main/java/org/apache/maven/project/ReactorModelResolver.java
(original)
+++ maven/maven-3/trunk/maven-core/src/main/java/org/apache/maven/project/ReactorModelResolver.java
Mon Sep 20 09:40:51 2010
@@ -169,8 +169,7 @@ class ReactorModelResolver
             }
             catch ( ArtifactResolutionException e )
             {
-                throw new UnresolvableModelException( "Failed to resolve POM for " + groupId
+ ":" + artifactId + ":"
-                    + version + " due to " + e.getMessage(), groupId, artifactId, version,
e );
+                throw new UnresolvableModelException( e.getMessage(), groupId, artifactId,
version, e );
             }
 
             pomFile = pomArtifact.getFile();

Modified: maven/maven-3/trunk/maven-model-builder/src/main/java/org/apache/maven/model/building/DefaultModelBuilder.java
URL: http://svn.apache.org/viewvc/maven/maven-3/trunk/maven-model-builder/src/main/java/org/apache/maven/model/building/DefaultModelBuilder.java?rev=998850&r1=998849&r2=998850&view=diff
==============================================================================
--- maven/maven-3/trunk/maven-model-builder/src/main/java/org/apache/maven/model/building/DefaultModelBuilder.java
(original)
+++ maven/maven-3/trunk/maven-model-builder/src/main/java/org/apache/maven/model/building/DefaultModelBuilder.java
Mon Sep 20 09:40:51 2010
@@ -740,11 +740,18 @@ public class DefaultModelBuilder
         if ( groupId == null || !groupId.equals( parent.getGroupId() ) || artifactId == null
             || !artifactId.equals( parent.getArtifactId() ) )
         {
+            StringBuilder buffer = new StringBuilder( 256 );
+            buffer.append( "'parent.relativePath'" );
+            if ( childModel != problems.getRootModel() )
+            {
+                buffer.append( " of POM " ).append( ModelProblemUtils.toSourceHint( childModel
) );
+            }
+            buffer.append( " points at " ).append( groupId ).append( ":" ).append( artifactId
);
+            buffer.append( " instead of " ).append( parent.getGroupId() ).append( ":" ).append(
parent.getArtifactId() );
+            buffer.append( ", please verify your project structure" );
+
             problems.setSource( childModel );
-            problems.add( Severity.WARNING, "'parent.relativePath' of POM "
-                + ModelProblemUtils.toSourceHint( childModel ) + " points at " + groupId
+ ":" + artifactId
-                + " instead of " + parent.getGroupId() + ":" + parent.getArtifactId()
-                + ", please verify your project structure", childModel.getLocation( "parent"
), null );
+            problems.add( Severity.WARNING, buffer.toString(), parent.getLocation( "" ),
null );
             return null;
         }
         if ( version == null || !version.equals( parent.getVersion() ) )
@@ -813,9 +820,20 @@ public class DefaultModelBuilder
         }
         catch ( UnresolvableModelException e )
         {
-            problems.add( Severity.FATAL, "Non-resolvable parent POM "
-                + ModelProblemUtils.toId( groupId, artifactId, version ) + " for "
-                + ModelProblemUtils.toId( childModel ) + ": " + e.getMessage(), childModel.getLocation(
"parent" ), e );
+            StringBuilder buffer = new StringBuilder( 256 );
+            buffer.append( "Non-resolvable parent POM" );
+            if ( !containsCoordinates( e.getMessage(), groupId, artifactId, version ) )
+            {
+                buffer.append( " " ).append( ModelProblemUtils.toId( groupId, artifactId,
version ) );
+            }
+            if ( childModel != problems.getRootModel() )
+            {
+                buffer.append( " for " ).append( ModelProblemUtils.toId( childModel ) );
+            }
+            buffer.append( ": " ).append( e.getMessage() );
+            buffer.append( " and 'parent.relativePath' points at wrong local POM" );
+
+            problems.add( Severity.FATAL, buffer.toString(), parent.getLocation( "" ), e
);
             throw new ModelBuildingException( problems.getRootModel(), problems.getRootModelId(),
                                               problems.getProblems() );
         }
@@ -915,9 +933,15 @@ public class DefaultModelBuilder
                 }
                 catch ( UnresolvableModelException e )
                 {
-                    problems.add( Severity.ERROR, "Non-resolvable import POM "
-                        + ModelProblemUtils.toId( groupId, artifactId, version ) + ": " +
e.getMessage(),
-                                  dependency.getLocation( "" ), e );
+                    StringBuilder buffer = new StringBuilder( 256 );
+                    buffer.append( "Non-resolvable import POM" );
+                    if ( !containsCoordinates( e.getMessage(), groupId, artifactId, version
) )
+                    {
+                        buffer.append( " " ).append( ModelProblemUtils.toId( groupId, artifactId,
version ) );
+                    }
+                    buffer.append( ": " ).append( e.getMessage() );
+
+                    problems.add( Severity.ERROR, buffer.toString(), dependency.getLocation(
"" ), e );
                     continue;
                 }
 
@@ -1008,4 +1032,10 @@ public class DefaultModelBuilder
         }
     }
 
+    private boolean containsCoordinates( String message, String groupId, String artifactId,
String version )
+    {
+        return message != null && message.contains( groupId ) && message.contains(
artifactId )
+            && message.contains( version );
+    }
+
 }



Mime
View raw message