maven-m2-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tryg...@apache.org
Subject cvs commit: maven-components/maven-core/src/main/java/org/apache/maven/project DefaultMavenProjectBuilder.java
Date Tue, 08 Mar 2005 01:55:22 GMT
trygvis     2005/03/07 17:55:22

  Modified:    maven-core/src/main/java/org/apache/maven/project
                        DefaultMavenProjectBuilder.java
  Log:
  o Improving some error reporting.
  
  Revision  Changes    Path
  1.37      +36 -27    maven-components/maven-core/src/main/java/org/apache/maven/project/DefaultMavenProjectBuilder.java
  
  Index: DefaultMavenProjectBuilder.java
  ===================================================================
  RCS file: /home/cvs/maven-components/maven-core/src/main/java/org/apache/maven/project/DefaultMavenProjectBuilder.java,v
  retrieving revision 1.36
  retrieving revision 1.37
  diff -u -r1.36 -r1.37
  --- DefaultMavenProjectBuilder.java	7 Mar 2005 22:08:23 -0000	1.36
  +++ DefaultMavenProjectBuilder.java	8 Mar 2005 01:55:22 -0000	1.37
  @@ -16,6 +16,20 @@
    * limitations under the License.
    */
   
  +import java.io.File;
  +import java.io.FileNotFoundException;
  +import java.io.FileReader;
  +import java.io.IOException;
  +import java.io.InputStreamReader;
  +import java.net.URL;
  +import java.util.ArrayList;
  +import java.util.HashMap;
  +import java.util.Iterator;
  +import java.util.LinkedList;
  +import java.util.List;
  +import java.util.Map;
  +import java.util.Set;
  +
   import org.apache.maven.MavenConstants;
   import org.apache.maven.artifact.Artifact;
   import org.apache.maven.artifact.DefaultArtifact;
  @@ -36,27 +50,17 @@
   import org.apache.maven.project.validation.ModelValidationResult;
   import org.apache.maven.project.validation.ModelValidator;
   import org.apache.maven.repository.RepositoryUtils;
  +
   import org.codehaus.plexus.logging.AbstractLogEnabled;
   import org.codehaus.plexus.personality.plexus.lifecycle.phase.Initializable;
  -import org.codehaus.plexus.util.IOUtil;
   import org.codehaus.plexus.util.StringUtils;
   import org.codehaus.plexus.util.dag.CycleDetectedException;
   import org.codehaus.plexus.util.dag.DAG;
   import org.codehaus.plexus.util.dag.TopologicalSorter;
   
  -import java.io.File;
  -import java.io.FileNotFoundException;
  -import java.io.FileReader;
  -import java.io.InputStreamReader;
  -import java.io.Reader;
  -import java.util.ArrayList;
  -import java.util.HashMap;
  -import java.util.Iterator;
  -import java.util.LinkedList;
  -import java.util.List;
  -import java.util.Map;
  -import java.util.Set;
  -
  +/**
  + * @version $Id$
  + */
   public class DefaultMavenProjectBuilder
       extends AbstractLogEnabled
       implements MavenProjectBuilder, Initializable
  @@ -225,33 +229,37 @@
           return project;
       }
   
  -    private Model readModel( File projectDescriptor )
  +    private Model readModel( File file )
           throws ProjectBuildingException
       {
           try
           {
  -            return readModel( new FileReader( projectDescriptor ) );
  +            return modelReader.read( new FileReader( file ) );
  +        }
  +        catch ( FileNotFoundException e )
  +        {
  +            throw new ProjectBuildingException( "Could not find the model file '" + file.getAbsolutePath()
+ "'." );
           }
  -        catch ( FileNotFoundException ex )
  +        catch ( Exception e )
           {
  -            throw new ProjectBuildingException( "Error while building model.", ex );
  +            throw new ProjectBuildingException( "Error while reading model from file '"
+ file.getAbsolutePath() + "'.", e );
           }
       }
   
  -    private Model readModel( Reader reader )
  +    private Model readModel( URL url )
           throws ProjectBuildingException
       {
           try
           {
  -            return modelReader.read( reader );
  +            return modelReader.read( new InputStreamReader( url.openStream() ) );
           }
  -        catch ( Exception ex )
  +        catch ( IOException e )
           {
  -            throw new ProjectBuildingException( "Error while building model.", ex );
  +            throw new ProjectBuildingException( "Error while reading model.", e );
           }
  -        finally
  +        catch ( Exception ex )
           {
  -            IOUtil.close( reader );
  +            throw new ProjectBuildingException( "Error while building model from " + url.toExternalForm(),
ex );
           }
       }
   
  @@ -342,7 +350,8 @@
       private Model getSuperModel()
           throws ProjectBuildingException
       {
  -        return readModel( new InputStreamReader( DefaultMavenProjectBuilder.class.getResourceAsStream(
  -            "pom-" + MavenConstants.MAVEN_MODEL_VERSION + ".xml" ) ) );
  +        URL url = DefaultMavenProjectBuilder.class.getResource( "pom-" + MavenConstants.MAVEN_MODEL_VERSION
+ ".xml" );
  +
  +        return readModel( url );
       }
  -}
  \ No newline at end of file
  +}
  
  
  

Mime
View raw message