maven-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bentm...@apache.org
Subject svn commit: r778514 - /maven/components/branches/MNG-2766/maven-core/src/main/java/org/apache/maven/project/DefaultMavenProjectBuilder.java
Date Mon, 25 May 2009 21:21:10 GMT
Author: bentmann
Date: Mon May 25 21:21:10 2009
New Revision: 778514

URL: http://svn.apache.org/viewvc?rev=778514&view=rev
Log:
o Added utility method

Modified:
    maven/components/branches/MNG-2766/maven-core/src/main/java/org/apache/maven/project/DefaultMavenProjectBuilder.java

Modified: maven/components/branches/MNG-2766/maven-core/src/main/java/org/apache/maven/project/DefaultMavenProjectBuilder.java
URL: http://svn.apache.org/viewvc/maven/components/branches/MNG-2766/maven-core/src/main/java/org/apache/maven/project/DefaultMavenProjectBuilder.java?rev=778514&r1=778513&r2=778514&view=diff
==============================================================================
--- maven/components/branches/MNG-2766/maven-core/src/main/java/org/apache/maven/project/DefaultMavenProjectBuilder.java
(original)
+++ maven/components/branches/MNG-2766/maven-core/src/main/java/org/apache/maven/project/DefaultMavenProjectBuilder.java
Mon May 25 21:21:10 2009
@@ -21,6 +21,7 @@
 import java.util.Collection;
 import java.util.Collections;
 import java.util.List;
+import java.util.Map;
 
 import org.apache.maven.artifact.Artifact;
 import org.apache.maven.artifact.ArtifactUtils;
@@ -393,7 +394,7 @@
     private List<Model> build( String projectId, File pomFile, ProjectBuilderConfiguration
projectBuilderConfiguration )
         throws ProjectBuildingException, IOException
     {
-        Model mainModel = modelReader.read( pomFile, null );
+        Model mainModel = readModel( projectId, pomFile, true );
         mainModel.setProjectDirectory( pomFile.getParentFile() );
 
         List<Model> domainModels = new ArrayList<Model>();
@@ -559,7 +560,7 @@
     }
 
     private List<Model> getDomainModelParentsFromRepository( Model model, ArtifactRepository
localRepository, List<ArtifactRepository> remoteRepositories )
-        throws IOException
+        throws IOException, ProjectBuildingException
     {
         List<Model> models = new ArrayList<Model>();
 
@@ -599,7 +600,7 @@
             throw (IOException) new IOException( "The parent POM " + artifactParent + " could
not be retrieved from any repository" ).initCause( e );
         }
         
-        Model parentModel = modelReader.read( artifactParent.getFile(), null );
+        Model parentModel = readModel( parent.getId(), artifactParent.getFile(), true );
 
         if ( !isMatchingParent( parentModel, parent ) )
         {
@@ -624,10 +625,11 @@
      * @param projectDirectory
      * @return
      * @throws IOException
+     * @throws ProjectBuildingException 
      */
     private List<Model> getDomainModelParentsFromLocalPath( Model model, ArtifactRepository
localRepository, List<ArtifactRepository> remoteRepositories, File projectDirectory,
                                                                   ProjectBuilderConfiguration
projectBuilderConfiguration )
-        throws IOException
+        throws IOException, ProjectBuildingException
     {
         List<Model> models = new ArrayList<Model>();
 
@@ -649,7 +651,7 @@
             throw new IOException( "File does not exist: File = " + parentFile.getAbsolutePath()
);
         }
         
-        Model parentModel = modelReader.read( parentFile, null );
+        Model parentModel = readModel( parent.getId(), parentFile, true );
         parentModel.setProjectDirectory( parentFile.getParentFile() );
 
         if ( !isMatchingParent( parentModel, parent ) )
@@ -718,6 +720,22 @@
         return true;
     }
 
+    private Model readModel( String projectId, File pomFile, boolean strict )
+        throws ProjectBuildingException
+    {
+        Map<String, Object> options =
+            Collections.<String, Object> singletonMap( ModelReader.IS_STRICT, Boolean.valueOf(
strict ) );
+        try
+        {
+            return modelReader.read( pomFile, options );
+        }
+        catch ( IOException e )
+        {
+            throw new ProjectBuildingException( projectId, "Failed to read POM for " + projectId
+ " from " + pomFile
+                + ": " + e.getMessage(), pomFile, e );
+        }
+    }
+
     // Super Model Handling
 
     private static final String MAVEN_MODEL_VERSION = "4.0.0";



Mime
View raw message