You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by br...@apache.org on 2005/10/12 20:49:26 UTC

svn commit: r314994 - in /maven/components/trunk: maven-artifact-manager/src/main/java/org/apache/maven/artifact/manager/ maven-artifact/src/main/java/org/apache/maven/artifact/ maven-core/src/main/java/org/apache/maven/usability/plugin/ maven-plugin-t...

Author: brett
Date: Wed Oct 12 11:49:01 2005
New Revision: 314994

URL: http://svn.apache.org/viewcvs?rev=314994&view=rev
Log:
clean up project exception handling

Added:
    maven/components/trunk/maven-artifact/src/main/java/org/apache/maven/artifact/InvalidRepositoryException.java   (with props)
Modified:
    maven/components/trunk/maven-artifact-manager/src/main/java/org/apache/maven/artifact/manager/DefaultWagonManager.java
    maven/components/trunk/maven-core/src/main/java/org/apache/maven/usability/plugin/ExpressionDocumentationException.java
    maven/components/trunk/maven-plugin-tools/maven-plugin-tools-api/src/main/java/org/apache/maven/tools/plugin/extractor/AbstractScriptedMojoDescriptorExtractor.java
    maven/components/trunk/maven-project/src/main/java/org/apache/maven/profiles/activation/ProfileActivationException.java
    maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/DefaultMavenProjectBuilder.java
    maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/InvalidProjectModelException.java
    maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/ProjectUtils.java
    maven/components/trunk/maven-project/src/test/java/org/apache/maven/project/TestArtifactResolver.java

Modified: maven/components/trunk/maven-artifact-manager/src/main/java/org/apache/maven/artifact/manager/DefaultWagonManager.java
URL: http://svn.apache.org/viewcvs/maven/components/trunk/maven-artifact-manager/src/main/java/org/apache/maven/artifact/manager/DefaultWagonManager.java?rev=314994&r1=314993&r2=314994&view=diff
==============================================================================
--- maven/components/trunk/maven-artifact-manager/src/main/java/org/apache/maven/artifact/manager/DefaultWagonManager.java (original)
+++ maven/components/trunk/maven-artifact-manager/src/main/java/org/apache/maven/artifact/manager/DefaultWagonManager.java Wed Oct 12 11:49:01 2005
@@ -536,7 +536,7 @@
         }
         catch ( IOException e )
         {
-            throw new TransferFailedException( "Invalid checksum file", e );
+            throw new ChecksumFailedException( "Invalid checksum file", e );
         }
     }
 

Added: maven/components/trunk/maven-artifact/src/main/java/org/apache/maven/artifact/InvalidRepositoryException.java
URL: http://svn.apache.org/viewcvs/maven/components/trunk/maven-artifact/src/main/java/org/apache/maven/artifact/InvalidRepositoryException.java?rev=314994&view=auto
==============================================================================
--- maven/components/trunk/maven-artifact/src/main/java/org/apache/maven/artifact/InvalidRepositoryException.java (added)
+++ maven/components/trunk/maven-artifact/src/main/java/org/apache/maven/artifact/InvalidRepositoryException.java Wed Oct 12 11:49:01 2005
@@ -0,0 +1,32 @@
+package org.apache.maven.artifact;
+
+/*
+ * Copyright 2001-2005 The Apache Software Foundation.
+ *
+ * Licensed 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.
+ */
+
+/**
+ * Error constructing an artifact repository.
+ *
+ * @author <a href="mailto:brett@apache.org">Brett Porter</a>
+ * @version $Id$
+ */
+public class InvalidRepositoryException
+    extends Exception
+{
+    public InvalidRepositoryException( String message, Throwable throwable )
+    {
+        super( message, throwable );
+    }
+}

Propchange: maven/components/trunk/maven-artifact/src/main/java/org/apache/maven/artifact/InvalidRepositoryException.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/components/trunk/maven-artifact/src/main/java/org/apache/maven/artifact/InvalidRepositoryException.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Modified: maven/components/trunk/maven-core/src/main/java/org/apache/maven/usability/plugin/ExpressionDocumentationException.java
URL: http://svn.apache.org/viewcvs/maven/components/trunk/maven-core/src/main/java/org/apache/maven/usability/plugin/ExpressionDocumentationException.java?rev=314994&r1=314993&r2=314994&view=diff
==============================================================================
--- maven/components/trunk/maven-core/src/main/java/org/apache/maven/usability/plugin/ExpressionDocumentationException.java (original)
+++ maven/components/trunk/maven-core/src/main/java/org/apache/maven/usability/plugin/ExpressionDocumentationException.java Wed Oct 12 11:49:01 2005
@@ -1,4 +1,18 @@
-package org.apache.maven.usability.plugin;
+package org.apache.maven.usability.plugin;/*
+ * Copyright 2001-2005 The Apache Software Foundation.
+ *
+ * Licensed 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.
+ */
 
 public class ExpressionDocumentationException
     extends Exception

Modified: maven/components/trunk/maven-plugin-tools/maven-plugin-tools-api/src/main/java/org/apache/maven/tools/plugin/extractor/AbstractScriptedMojoDescriptorExtractor.java
URL: http://svn.apache.org/viewcvs/maven/components/trunk/maven-plugin-tools/maven-plugin-tools-api/src/main/java/org/apache/maven/tools/plugin/extractor/AbstractScriptedMojoDescriptorExtractor.java?rev=314994&r1=314993&r2=314994&view=diff
==============================================================================
--- maven/components/trunk/maven-plugin-tools/maven-plugin-tools-api/src/main/java/org/apache/maven/tools/plugin/extractor/AbstractScriptedMojoDescriptorExtractor.java (original)
+++ maven/components/trunk/maven-plugin-tools/maven-plugin-tools-api/src/main/java/org/apache/maven/tools/plugin/extractor/AbstractScriptedMojoDescriptorExtractor.java Wed Oct 12 11:49:01 2005
@@ -5,11 +5,9 @@
 import org.apache.maven.project.MavenProject;
 import org.codehaus.plexus.logging.AbstractLogEnabled;
 import org.codehaus.plexus.util.DirectoryScanner;
-import org.codehaus.plexus.util.IOUtil;
+import org.codehaus.plexus.util.FileUtils;
 
 import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
 import java.io.IOException;
 import java.util.HashSet;
 import java.util.Iterator;
@@ -28,8 +26,8 @@
     public List execute( MavenProject project, PluginDescriptor pluginDescriptor )
         throws ExtractionException, InvalidPluginDescriptorException
     {
-        Map scriptFilesKeyedByBasedir = gatherScriptSourcesByBasedir( project.getScriptSourceRoots(),
-                                                                      getScriptFileExtension() );
+        Map scriptFilesKeyedByBasedir =
+            gatherScriptSourcesByBasedir( project.getScriptSourceRoots(), getScriptFileExtension() );
 
         List mojoDescriptors = extractMojoDescriptors( scriptFilesKeyedByBasedir, pluginDescriptor );
 
@@ -74,32 +72,14 @@
                     outputFile.getParentFile().mkdirs();
                 }
 
-                FileInputStream in = null;
-                FileOutputStream out = null;
-
                 try
                 {
-                    in = new FileInputStream( scriptFile );
-                    out = new FileOutputStream( outputFile );
-
-                    byte[] buffer = new byte[16];
-                    int read = -1;
-
-                    while ( ( read = in.read( buffer ) ) > -1 )
-                    {
-                        out.write( buffer, 0, read );
-                    }
-
-                    out.flush();
+                    FileUtils.copyFile( scriptFile, outputFile );
                 }
                 catch ( IOException e )
                 {
-                    throw new ExtractionException( "Cannot copy script file: " + scriptFile + " to output: " + outputFile, e );
-                }
-                finally
-                {
-                    IOUtil.close( in );
-                    IOUtil.close( out );
+                    throw new ExtractionException(
+                        "Cannot copy script file: " + scriptFile + " to output: " + outputFile, e );
                 }
             }
         }

Modified: maven/components/trunk/maven-project/src/main/java/org/apache/maven/profiles/activation/ProfileActivationException.java
URL: http://svn.apache.org/viewcvs/maven/components/trunk/maven-project/src/main/java/org/apache/maven/profiles/activation/ProfileActivationException.java?rev=314994&r1=314993&r2=314994&view=diff
==============================================================================
--- maven/components/trunk/maven-project/src/main/java/org/apache/maven/profiles/activation/ProfileActivationException.java (original)
+++ maven/components/trunk/maven-project/src/main/java/org/apache/maven/profiles/activation/ProfileActivationException.java Wed Oct 12 11:49:01 2005
@@ -1,5 +1,21 @@
 package org.apache.maven.profiles.activation;
 
+/*
+ * Copyright 2001-2005 The Apache Software Foundation.
+ *
+ * Licensed 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.
+ */
+
 public class ProfileActivationException
     extends Exception
 {

Modified: maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/DefaultMavenProjectBuilder.java
URL: http://svn.apache.org/viewcvs/maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/DefaultMavenProjectBuilder.java?rev=314994&r1=314993&r2=314994&view=diff
==============================================================================
--- maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/DefaultMavenProjectBuilder.java (original)
+++ maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/DefaultMavenProjectBuilder.java Wed Oct 12 11:49:01 2005
@@ -19,6 +19,7 @@
 import org.apache.maven.artifact.Artifact;
 import org.apache.maven.artifact.ArtifactStatus;
 import org.apache.maven.artifact.ArtifactUtils;
+import org.apache.maven.artifact.InvalidRepositoryException;
 import org.apache.maven.artifact.factory.ArtifactFactory;
 import org.apache.maven.artifact.manager.WagonManager;
 import org.apache.maven.artifact.metadata.ArtifactMetadataSource;
@@ -184,7 +185,9 @@
         // TODO: such a call in MavenMetadataSource too - packaging not really the intention of type
         Artifact projectArtifact = project.getArtifact();
 
-        Map managedVersions = createManagedVersionMap( project.getId(), project.getDependencyManagement() );
+        String projectId = safeVersionlessKey( project.getGroupId(), project.getArtifactId() );
+
+        Map managedVersions = createManagedVersionMap( projectId, project.getDependencyManagement() );
 
         ensureMetadataSourceIsInitialized();
 
@@ -194,7 +197,7 @@
         }
         catch ( InvalidVersionSpecificationException e )
         {
-            throw new ProjectBuildingException( project.getId(), "Error in dependency version", e );
+            throw new ProjectBuildingException( projectId, "Error in dependency version", e );
         }
 
         if ( transferListener != null )
@@ -224,7 +227,8 @@
             }
             catch ( ComponentLookupException e )
             {
-                throw new ProjectBuildingException( "all", "Cannot lookup metadata source for building the project.", e );
+                throw new ProjectBuildingException( "all", "Cannot lookup metadata source for building the project.",
+                                                    e );
             }
         }
     }
@@ -277,8 +281,7 @@
     }
 
     private MavenProject buildFromSourceFile( File projectDescriptor, ArtifactRepository localRepository,
-                                              ProfileManager profileManager,
-                                              boolean checkDistributionManagementStatus )
+                                              ProfileManager profileManager, boolean checkDistributionManagementStatus )
         throws ProjectBuildingException
     {
         Model model = readModel( "unknown", projectDescriptor );
@@ -294,10 +297,13 @@
 
         if ( checkDistributionManagementStatus )
         {
-            if ( project.getDistributionManagement() != null && project.getDistributionManagement().getStatus() != null )
+            if ( project.getDistributionManagement() != null &&
+                project.getDistributionManagement().getStatus() != null )
             {
-                throw new ProjectBuildingException( project.getId(), 
-                    "Invalid project file: distribution status must not be specified for a project outside of the repository" );
+                String projectId = safeVersionlessKey( project.getGroupId(), project.getArtifactId() );
+
+                throw new ProjectBuildingException( projectId,
+                                                    "Invalid project file: distribution status must not be specified for a project outside of the repository" );
             }
         }
 
@@ -364,7 +370,7 @@
         if ( project == null )
         {
             String projectId = ArtifactUtils.versionlessKey( projectArtifact );
-            
+
             try
             {
                 artifactResolver.resolve( projectArtifact, remoteArtifactRepositories, localRepository );
@@ -530,7 +536,7 @@
         Set aggregatedRemoteWagonRepositories = new LinkedHashSet();
 
         String projectId = safeVersionlessKey( model.getGroupId(), model.getArtifactId() );
-        
+
         List activeExternalProfiles;
         try
         {
@@ -556,9 +562,16 @@
             {
                 Repository mavenRepo = (Repository) repoIterator.next();
 
-                ArtifactRepository artifactRepo = ProjectUtils.buildArtifactRepository( mavenRepo,
-                                                                                        artifactRepositoryFactory,
-                                                                                        container );
+                ArtifactRepository artifactRepo = null;
+                try
+                {
+                    artifactRepo =
+                        ProjectUtils.buildArtifactRepository( mavenRepo, artifactRepositoryFactory, container );
+                }
+                catch ( InvalidRepositoryException e )
+                {
+                    throw new ProjectBuildingException( projectId, e.getMessage(), e );
+                }
 
                 aggregatedRemoteWagonRepositories.add( artifactRepo );
             }
@@ -566,8 +579,16 @@
 
         Model originalModel = ModelUtils.cloneModel( model );
 
-        MavenProject project = assembleLineage( model, lineage, localRepository, projectDir, parentSearchRepositories,
-                                                aggregatedRemoteWagonRepositories, externalProfileManager );
+        MavenProject project = null;
+        try
+        {
+            project = assembleLineage( model, lineage, localRepository, projectDir, parentSearchRepositories,
+                                       aggregatedRemoteWagonRepositories, externalProfileManager );
+        }
+        catch ( InvalidRepositoryException e )
+        {
+            throw new ProjectBuildingException( projectId, e.getMessage(), e );
+        }
 
         project.setOriginalModel( originalModel );
 
@@ -603,8 +624,11 @@
         }
         catch ( ModelInterpolationException e )
         {
-            throw new ProjectBuildingException( project.getId(), "Error building project from \'" + pomLocation + "\': " + model.getId(),
-                                                e );
+            throw new InvalidProjectModelException( projectId, pomLocation, e.getMessage(), e );
+        }
+        catch ( InvalidRepositoryException e )
+        {
+            throw new InvalidProjectModelException( projectId, pomLocation, e.getMessage(), e );
         }
         projectCache.put( createCacheKey( project.getGroupId(), project.getArtifactId(), project.getVersion() ),
                           project );
@@ -614,26 +638,36 @@
     private String safeVersionlessKey( String groupId, String artifactId )
     {
         String gid = groupId;
-        
+
         if ( StringUtils.isEmpty( gid ) )
         {
             gid = "unknown";
         }
-        
+
         String aid = artifactId;
-        
+
         if ( StringUtils.isEmpty( aid ) )
         {
             aid = "unknown";
         }
-        
+
         return ArtifactUtils.versionlessKey( gid, aid );
     }
 
     private List buildArtifactRepositories( Model model )
         throws ProjectBuildingException
     {
-        return ProjectUtils.buildArtifactRepositories( model.getRepositories(), artifactRepositoryFactory, container );
+        try
+        {
+            return ProjectUtils.buildArtifactRepositories( model.getRepositories(), artifactRepositoryFactory,
+                                                           container );
+        }
+        catch ( InvalidRepositoryException e )
+        {
+            String projectId = safeVersionlessKey( model.getGroupId(), model.getArtifactId() );
+
+            throw new ProjectBuildingException( projectId, e.getMessage(), e );
+        }
     }
 
     /**
@@ -645,7 +679,7 @@
      */
     private MavenProject processProjectLogic( String pomLocation, MavenProject project, List remoteRepositories,
                                               ProfileManager profileMgr, File projectDir )
-        throws ProjectBuildingException, ModelInterpolationException
+        throws ProjectBuildingException, ModelInterpolationException, InvalidRepositoryException
     {
         Model model = project.getModel();
         String key = createCacheKey( model.getGroupId(), model.getArtifactId(), model.getVersion() );
@@ -732,18 +766,21 @@
         // Must validate before artifact construction to make sure dependencies are good
         ModelValidationResult validationResult = validator.validate( model );
 
+        String projectId = safeVersionlessKey( model.getGroupId(), model.getArtifactId() );
+
         if ( validationResult.getMessageCount() > 0 )
         {
-            throw new InvalidProjectModelException( project.getId(), pomLocation, "Failed to validate POM", validationResult );
+            throw new InvalidProjectModelException( projectId, pomLocation, "Failed to validate POM",
+                                                    validationResult );
         }
 
         project.setRemoteArtifactRepositories(
             ProjectUtils.buildArtifactRepositories( model.getRepositories(), artifactRepositoryFactory, container ) );
 
         // TODO: these aren't taking active project artifacts into consideration in the reactor
-        project.setPluginArtifacts( createPluginArtifacts( project.getId(), project.getBuildPlugins() ) );
-        project.setReportArtifacts( createReportArtifacts( project.getId(), project.getReportPlugins() ) );
-        project.setExtensionArtifacts( createExtensionArtifacts( project.getId(), project.getBuildExtensions() ) );
+        project.setPluginArtifacts( createPluginArtifacts( projectId, project.getBuildPlugins() ) );
+        project.setReportArtifacts( createReportArtifacts( projectId, project.getReportPlugins() ) );
+        project.setExtensionArtifacts( createExtensionArtifacts( projectId, project.getBuildExtensions() ) );
 
         return project;
     }
@@ -754,7 +791,7 @@
     private MavenProject assembleLineage( Model model, LinkedList lineage, ArtifactRepository localRepository,
                                           File projectDir, List parentSearchRepositories,
                                           Set aggregatedRemoteWagonRepositories, ProfileManager externalProfileManager )
-        throws ProjectBuildingException
+        throws ProjectBuildingException, InvalidRepositoryException
     {
         if ( !model.getRepositories().isEmpty() )
         {
@@ -792,8 +829,9 @@
         catch ( ProfileActivationException e )
         {
             String projectId = safeVersionlessKey( model.getGroupId(), model.getArtifactId() );
-            
-            throw new ProjectBuildingException( projectId, "Failed to activate local (project-level) build profiles.", e );
+
+            throw new ProjectBuildingException( projectId, "Failed to activate local (project-level) build profiles: " +
+                e.getMessage(), e );
         }
 
         MavenProject project = new MavenProject( model );
@@ -807,7 +845,7 @@
         if ( parentModel != null )
         {
             String projectId = safeVersionlessKey( model.getGroupId(), model.getArtifactId() );
-            
+
             if ( StringUtils.isEmpty( parentModel.getGroupId() ) )
             {
                 throw new ProjectBuildingException( projectId, "Missing groupId element from parent element" );
@@ -824,8 +862,8 @@
             // the only way this will have a value is if we find the parent on disk...
             File parentDescriptor = null;
 
-            MavenProject p = getCachedProject( parentModel.getGroupId(), parentModel.getArtifactId(),
-                                               parentModel.getVersion() );
+            MavenProject p =
+                getCachedProject( parentModel.getGroupId(), parentModel.getArtifactId(), parentModel.getVersion() );
             if ( p != null )
             {
                 model = p.getModel();
@@ -948,8 +986,8 @@
             catch ( ProfileActivationException e )
             {
                 String projectId = safeVersionlessKey( model.getGroupId(), model.getArtifactId() );
-                
-                throw new ProjectBuildingException( projectId, "Failed to calculate active build profiles.", e );
+
+                throw new ProjectBuildingException( projectId, e.getMessage(), e );
             }
 
             for ( Iterator it = activeProfiles.iterator(); it.hasNext(); )
@@ -1019,17 +1057,13 @@
         }
         catch ( FileNotFoundException e )
         {
-            throw new ProjectBuildingException( projectId, "Could not find the model file '" + file.getAbsolutePath() + "'.", e );
+            throw new ProjectBuildingException( projectId,
+                                                "Could not find the model file '" + file.getAbsolutePath() + "'.", e );
         }
         catch ( IOException e )
         {
-            throw new ProjectBuildingException( projectId, "Failed to build model from file '" + file.getAbsolutePath() +
-                "'.\nError: \'" + e.getLocalizedMessage() + "\'", e );
-        }
-        catch ( XmlPullParserException e )
-        {
-            throw new ProjectBuildingException( projectId, "Failed to parse model from file '" + file.getAbsolutePath() +
-                "'.\nError: \'" + e.getLocalizedMessage() + "\'", e );
+            throw new ProjectBuildingException( projectId, "Failed to build model from file '" +
+                file.getAbsolutePath() + "'.\nError: \'" + e.getLocalizedMessage() + "\'", e );
         }
         finally
         {
@@ -1038,7 +1072,7 @@
     }
 
     private Model readModel( String projectId, String pomLocation, Reader reader )
-        throws IOException, XmlPullParserException, InvalidProjectModelException
+        throws IOException, InvalidProjectModelException
     {
         StringWriter sw = new StringWriter();
 
@@ -1053,7 +1087,14 @@
 
         StringReader sReader = new StringReader( modelSource );
 
-        return modelReader.read( sReader );
+        try
+        {
+            return modelReader.read( sReader );
+        }
+        catch ( XmlPullParserException e )
+        {
+            throw new InvalidProjectModelException( projectId, pomLocation, "Parse error reading POM", e );
+        }
     }
 
     private Model readModel( String projectId, URL url )
@@ -1070,11 +1111,6 @@
             throw new ProjectBuildingException( projectId, "Failed build model from URL \'" + url.toExternalForm() +
                 "\'\nError: \'" + e.getLocalizedMessage() + "\'", e );
         }
-        catch ( XmlPullParserException e )
-        {
-            throw new ProjectBuildingException( projectId, "Failed to parse model from URL \'" + url.toExternalForm() +
-                "\'\nError: \'" + e.getLocalizedMessage() + "\'", e );
-        }
         finally
         {
             IOUtil.close( reader );
@@ -1233,6 +1269,8 @@
 
         profileManager.addProfiles( superModel.getProfiles() );
 
+        String projectId = safeVersionlessKey( STANDALONE_SUPERPOM_GROUPID, STANDALONE_SUPERPOM_ARTIFACTID );
+
         activeProfiles = injectActiveProfiles( profileManager, superModel );
 
         MavenProject project = new MavenProject( superModel );
@@ -1243,9 +1281,6 @@
 
         try
         {
-            // TODO: remove - confirm this was a correct decision
-//            project.setFile( new File( ".", "pom.xml" ) );
-
             List remoteRepositories = buildArtifactRepositories( superModel );
 
             project = processProjectLogic( "<Super-POM>", project, remoteRepositories, null, null );
@@ -1256,9 +1291,11 @@
         }
         catch ( ModelInterpolationException e )
         {
-            String projectId = safeVersionlessKey( STANDALONE_SUPERPOM_GROUPID, STANDALONE_SUPERPOM_ARTIFACTID );
-            
-            throw new ProjectBuildingException( projectId, "Error building super-project", e );
+            throw new ProjectBuildingException( projectId, e.getMessage(), e );
+        }
+        catch ( InvalidRepositoryException e )
+        {
+            throw new ProjectBuildingException( projectId, e.getMessage(), e );
         }
     }
 
@@ -1272,7 +1309,7 @@
         URL url = DefaultMavenProjectBuilder.class.getResource( "pom-" + MAVEN_MODEL_VERSION + ".xml" );
 
         String projectId = safeVersionlessKey( STANDALONE_SUPERPOM_GROUPID, STANDALONE_SUPERPOM_ARTIFACTID );
-        
+
         return readModel( projectId, url );
     }
 

Modified: maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/InvalidProjectModelException.java
URL: http://svn.apache.org/viewcvs/maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/InvalidProjectModelException.java?rev=314994&r1=314993&r2=314994&view=diff
==============================================================================
--- maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/InvalidProjectModelException.java (original)
+++ maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/InvalidProjectModelException.java Wed Oct 12 11:49:01 2005
@@ -1,18 +1,41 @@
 package org.apache.maven.project;
 
+/*
+ * Copyright 2001-2005 The Apache Software Foundation.
+ *
+ * Licensed 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.project.validation.ModelValidationResult;
 
 public class InvalidProjectModelException
     extends ProjectBuildingException
 {
-
     private final String pomLocation;
+
     private ModelValidationResult validationResult;
 
-    public InvalidProjectModelException( String projectId, String pomLocation, String message, ModelValidationResult validationResult )
+    public InvalidProjectModelException( String projectId, String pomLocation, String message, Throwable cause )
+    {
+        super( projectId, message, cause );
+        this.pomLocation = pomLocation;
+    }
+
+    public InvalidProjectModelException( String projectId, String pomLocation, String message,
+                                         ModelValidationResult validationResult )
     {
         super( projectId, message );
-        
+
         this.pomLocation = pomLocation;
         this.validationResult = validationResult;
     }
@@ -20,7 +43,7 @@
     public InvalidProjectModelException( String projectId, String pomLocation, String message )
     {
         super( projectId, message );
-        
+
         this.pomLocation = pomLocation;
     }
 

Modified: maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/ProjectUtils.java
URL: http://svn.apache.org/viewcvs/maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/ProjectUtils.java?rev=314994&r1=314993&r2=314994&view=diff
==============================================================================
--- maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/ProjectUtils.java (original)
+++ maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/ProjectUtils.java Wed Oct 12 11:49:01 2005
@@ -16,14 +16,15 @@
  * limitations under the License.
  */
 
+import org.apache.maven.artifact.InvalidRepositoryException;
 import org.apache.maven.artifact.repository.ArtifactRepository;
 import org.apache.maven.artifact.repository.ArtifactRepositoryFactory;
 import org.apache.maven.artifact.repository.ArtifactRepositoryPolicy;
 import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout;
+import org.apache.maven.model.DeploymentRepository;
 import org.apache.maven.model.Repository;
 import org.apache.maven.model.RepositoryBase;
 import org.apache.maven.model.RepositoryPolicy;
-import org.apache.maven.model.DeploymentRepository;
 import org.codehaus.plexus.PlexusContainer;
 import org.codehaus.plexus.component.repository.exception.ComponentLookupException;
 
@@ -40,7 +41,7 @@
     public static List buildArtifactRepositories( List repositories,
                                                   ArtifactRepositoryFactory artifactRepositoryFactory,
                                                   PlexusContainer container )
-        throws ProjectBuildingException
+        throws InvalidRepositoryException
     {
 
         List repos = new ArrayList();
@@ -49,8 +50,8 @@
         {
             Repository mavenRepo = (Repository) i.next();
 
-            ArtifactRepository artifactRepo = buildArtifactRepository( mavenRepo, artifactRepositoryFactory,
-                                                                       container );
+            ArtifactRepository artifactRepo =
+                buildArtifactRepository( mavenRepo, artifactRepositoryFactory, container );
 
             if ( !repos.contains( artifactRepo ) )
             {
@@ -63,7 +64,7 @@
     public static ArtifactRepository buildDeploymentArtifactRepository( DeploymentRepository repo,
                                                                         ArtifactRepositoryFactory artifactRepositoryFactory,
                                                                         PlexusContainer container )
-        throws ProjectBuildingException
+        throws InvalidRepositoryException
     {
         if ( repo != null )
         {
@@ -73,7 +74,8 @@
             // TODO: make this a map inside the factory instead, so no lookup needed
             ArtifactRepositoryLayout layout = getRepositoryLayout( repo, container );
 
-            return artifactRepositoryFactory.createDeploymentArtifactRepository( id, url, layout, repo.isUniqueVersion() );
+            return artifactRepositoryFactory.createDeploymentArtifactRepository( id, url, layout,
+                                                                                 repo.isUniqueVersion() );
         }
         else
         {
@@ -84,7 +86,7 @@
     public static ArtifactRepository buildArtifactRepository( Repository repo,
                                                               ArtifactRepositoryFactory artifactRepositoryFactory,
                                                               PlexusContainer container )
-        throws ProjectBuildingException
+        throws InvalidRepositoryException
     {
         if ( repo != null )
         {
@@ -128,7 +130,7 @@
     }
 
     private static ArtifactRepositoryLayout getRepositoryLayout( RepositoryBase mavenRepo, PlexusContainer container )
-        throws ProjectBuildingException
+        throws InvalidRepositoryException
     {
         String layout = mavenRepo.getLayout();
 
@@ -139,7 +141,7 @@
         }
         catch ( ComponentLookupException e )
         {
-            throw new ProjectBuildingException( "all", "Cannot find layout implementation corresponding to: \'" + layout +
+            throw new InvalidRepositoryException( "Cannot find layout implementation corresponding to: \'" + layout +
                 "\' for remote repository with id: \'" + mavenRepo.getId() + "\'.", e );
         }
         return repositoryLayout;

Modified: maven/components/trunk/maven-project/src/test/java/org/apache/maven/project/TestArtifactResolver.java
URL: http://svn.apache.org/viewcvs/maven/components/trunk/maven-project/src/test/java/org/apache/maven/project/TestArtifactResolver.java?rev=314994&r1=314993&r2=314994&view=diff
==============================================================================
--- maven/components/trunk/maven-project/src/test/java/org/apache/maven/project/TestArtifactResolver.java (original)
+++ maven/components/trunk/maven-project/src/test/java/org/apache/maven/project/TestArtifactResolver.java Wed Oct 12 11:49:01 2005
@@ -17,6 +17,7 @@
  */
 
 import org.apache.maven.artifact.Artifact;
+import org.apache.maven.artifact.InvalidRepositoryException;
 import org.apache.maven.artifact.factory.ArtifactFactory;
 import org.apache.maven.artifact.metadata.ArtifactMetadataRetrievalException;
 import org.apache.maven.artifact.metadata.ArtifactMetadataSource;
@@ -126,10 +127,10 @@
             List artifactRepositories;
             try
             {
-                artifactRepositories = ProjectUtils.buildArtifactRepositories( model.getRepositories(),
-                                                                               repositoryFactory, container );
+                artifactRepositories =
+                    ProjectUtils.buildArtifactRepositories( model.getRepositories(), repositoryFactory, container );
             }
-            catch ( ProjectBuildingException e )
+            catch ( InvalidRepositoryException e )
             {
                 throw new ArtifactMetadataRetrievalException( e );
             }