maven-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sisb...@apache.org
Subject svn commit: r676674 - in /maven/sandbox/branches/SI_MAVEN_2_1/maven-project/src: main/java/org/apache/maven/project/ main/java/org/apache/maven/project/builder/impl/ test/resources/org/apache/maven/project/ test/resources/org/apache/maven/project/canon...
Date Mon, 14 Jul 2008 18:37:34 GMT
Author: sisbell
Date: Mon Jul 14 11:37:33 2008
New Revision: 676674

URL: http://svn.apache.org/viewvc?rev=676674&view=rev
Log:
Fixed bugs 1) which allowed old builder code to execute; 2) not finding parent pom on local
path.

Modified:
    maven/sandbox/branches/SI_MAVEN_2_1/maven-project/src/main/java/org/apache/maven/project/DefaultMavenProjectBuilder.java
    maven/sandbox/branches/SI_MAVEN_2_1/maven-project/src/main/java/org/apache/maven/project/builder/impl/DefaultProjectBuilder.java
    maven/sandbox/branches/SI_MAVEN_2_1/maven-project/src/test/resources/org/apache/maven/project/ProjectClasspathTest.xml
    maven/sandbox/branches/SI_MAVEN_2_1/maven-project/src/test/resources/org/apache/maven/project/canonical/CanonicalProjectBuilderTest.xml

Modified: maven/sandbox/branches/SI_MAVEN_2_1/maven-project/src/main/java/org/apache/maven/project/DefaultMavenProjectBuilder.java
URL: http://svn.apache.org/viewvc/maven/sandbox/branches/SI_MAVEN_2_1/maven-project/src/main/java/org/apache/maven/project/DefaultMavenProjectBuilder.java?rev=676674&r1=676673&r2=676674&view=diff
==============================================================================
--- maven/sandbox/branches/SI_MAVEN_2_1/maven-project/src/main/java/org/apache/maven/project/DefaultMavenProjectBuilder.java
(original)
+++ maven/sandbox/branches/SI_MAVEN_2_1/maven-project/src/main/java/org/apache/maven/project/DefaultMavenProjectBuilder.java
Mon Jul 14 11:37:33 2008
@@ -11,7 +11,7 @@
  *
  *  http://www.apache.org/licenses/LICENSE-2.0
  *
- * Unless required by applicable law or agreed to in writing,
+ * Unless required by applicable law or agreed to in writing,                      r
  * 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
@@ -502,7 +502,11 @@
         {
 //            getLogger().debug( "Allowing project-build to proceed for: " + projectDescriptor
);
 
-            Model model = readModel( "unknown", projectDescriptor, STRICT_MODEL_PARSING );
+            //Model model = readModel( "unknown", projectDescriptor, STRICT_MODEL_PARSING
);
+
+            Model model = readModel( "unknown", projectDescriptor, new PomArtifactResolver(config.getLocalRepository(),
+                    buildArtifactRepositories( getSuperModel() ), artifactResolver) );
+
 
             project = buildInternal( model,
                 config,
@@ -511,6 +515,7 @@
                 STRICT_MODEL_PARSING,
                 true,
                 true );
+                
         }
 //        else
 //        {
@@ -1796,48 +1801,6 @@
         }
     }
 
-    private Model readModel( String projectId,
-                             File file,
-                             boolean strict )
-        throws ProjectBuildingException
-    {
-        Reader reader = null;
-        try
-        {
-            reader = ReaderFactory.newXmlReader( file );
-
-            String modelSource = IOUtil.toString( reader );
-
-            checkModelVersion( modelSource, projectId, file );
-
-            StringReader sReader = new StringReader( modelSource );
-
-            try
-            {
-                return modelReader.read( sReader, strict );
-            }
-            catch ( XmlPullParserException e )
-            {
-                throw new InvalidProjectModelException( projectId, "Parse error reading POM.
Reason: " + e.getMessage(),
-                                                        file, e );
-            }
-        }
-        catch ( FileNotFoundException e )
-        {
-            throw new ProjectBuildingException( projectId,
-                "Could not find the model file '" + file.getAbsolutePath() + "'.", file,
e );
-        }
-        catch ( IOException e )
-        {
-            throw new ProjectBuildingException( projectId, "Failed to build model from file
'" +
-                file.getAbsolutePath() + "'.\nError: \'" + e.getLocalizedMessage() + "\'",
file, e );
-        }
-        finally
-        {
-            IOUtil.close( reader );
-        }
-    }
-
     private void checkModelVersion( String modelSource,
                                     String projectId,
                                     File file )
@@ -2107,8 +2070,14 @@
                             PomArtifactResolver resolver )
        throws ProjectBuildingException
    {
-       //System.out.println(projectDescriptor.getAbsolutePath());
+       if(projectDescriptor == null) {
+           throw new IllegalArgumentException("projectDescriptor: null, Project Id =" + projectId);
+       }
 
+       if(projectBuilder == null) {
+           throw new IllegalArgumentException("projectBuilder: not initialized");
+       }
+       
        MavenProject mavenProject;
        try {
            mavenProject = projectBuilder.buildFromStream(new FileInputStream(projectDescriptor),
null, resolver,

Modified: maven/sandbox/branches/SI_MAVEN_2_1/maven-project/src/main/java/org/apache/maven/project/builder/impl/DefaultProjectBuilder.java
URL: http://svn.apache.org/viewvc/maven/sandbox/branches/SI_MAVEN_2_1/maven-project/src/main/java/org/apache/maven/project/builder/impl/DefaultProjectBuilder.java?rev=676674&r1=676673&r2=676674&view=diff
==============================================================================
--- maven/sandbox/branches/SI_MAVEN_2_1/maven-project/src/main/java/org/apache/maven/project/builder/impl/DefaultProjectBuilder.java
(original)
+++ maven/sandbox/branches/SI_MAVEN_2_1/maven-project/src/main/java/org/apache/maven/project/builder/impl/DefaultProjectBuilder.java
Mon Jul 14 11:37:33 2008
@@ -101,34 +101,38 @@
         List<DomainModel> domainModels = new ArrayList<DomainModel>();
 
         Parent parent = domainModel.getModel().getParent();
+     
         if (parent == null) {
             return domainModels;
         }
-
+         logger.info("Parent: " + parent.getArtifactId());
         Artifact artifactParent =
                 artifactFactory.createParentArtifact(parent.getGroupId(), parent.getArtifactId(),
parent.getVersion());
 
         try {
             artifactResolver.resolve(artifactParent);
         } catch (IOException e) {
-            e.printStackTrace();
-            throw new IOException("getDomainModelFromRepository");
+           // throw new IOException("getDomainModelFromRepository");
         }
 
         if (!artifactParent.getFile().exists()) {
             logger.info("Parent pom does not exist in repository: File = " + artifactParent.getFile().getAbsolutePath());
             Model model = domainModel.getModel();
-           // System.out.println("PATH = " + projectDirectory.getAbsolutePath() + ":" + model.getParent().getRelativePath());
-           // System.out.println(new File(projectDirectory, model.getParent().getRelativePath()).getCanonicalFile());
+
             File parentFile = new File(projectDirectory, model.getParent().getRelativePath()).getCanonicalFile();
             if( parentFile.isDirectory()) {
                 parentFile = new File(parentFile, "pom.xml");
             }
+
+            //logger.info("Project Directory = " + projectDirectory.getAbsolutePath()) ;
+            //logger.info("Relative PATH = " + model.getParent().getRelativePath());
+            //logger.info("File:" + new File(projectDirectory, model.getParent().getRelativePath()).getAbsolutePath());
+            //logger.info("Canonical Parent File: = " + parentFile.getAbsolutePath());
+
             if (!parentFile.exists()) {
                 logger.warn("Parent pom does not exist on local path: File = " + parentFile.getAbsolutePath());
-                return domainModels;
-                //  throw new IOException("Parent pom does not exist: File = " + artifactParent.getFile()
+ ", Child Id = " +
-                //          model.getGroupId() + ":" + model.getArtifactId() + ":" + model.getVersion());
+                  throw new IOException("Parent pom does not exist: File = " + artifactParent.getFile()
+ ", Child Id = " +
+                          model.getGroupId() + ":" + model.getArtifactId() + ":" + model.getVersion());
             }
             artifactParent.setFile(parentFile);
         }
@@ -138,7 +142,7 @@
         }
 
         domainModels.add(parentDomainModel);
-        domainModels.addAll(getDomainModelParentsFromRepository(parentDomainModel, artifactResolver,
projectDirectory));
+        domainModels.addAll(getDomainModelParentsFromRepository(parentDomainModel, artifactResolver,
artifactParent.getFile().getParentFile()));
         return domainModels;
     }
 

Modified: maven/sandbox/branches/SI_MAVEN_2_1/maven-project/src/test/resources/org/apache/maven/project/ProjectClasspathTest.xml
URL: http://svn.apache.org/viewvc/maven/sandbox/branches/SI_MAVEN_2_1/maven-project/src/test/resources/org/apache/maven/project/ProjectClasspathTest.xml?rev=676674&r1=676673&r2=676674&view=diff
==============================================================================
--- maven/sandbox/branches/SI_MAVEN_2_1/maven-project/src/test/resources/org/apache/maven/project/ProjectClasspathTest.xml
(original)
+++ maven/sandbox/branches/SI_MAVEN_2_1/maven-project/src/test/resources/org/apache/maven/project/ProjectClasspathTest.xml
Mon Jul 14 11:37:33 2008
@@ -75,12 +75,25 @@
         </requirement>
       </requirements>
     </component>
+        <component>
+            <role>org.apache.maven.project.builder.ProjectBuilder</role>
+            <role-hint>default</role-hint>
+            <implementation>org.apache.maven.project.builder.impl.DefaultProjectBuilder</implementation>
+            <requirements>
+                <requirement>
+                    <role>org.apache.maven.artifact.factory.ArtifactFactory</role>
+                </requirement>
+            </requirements>
+        </component>
     <component>
       <role>org.apache.maven.project.MavenProjectBuilder</role>
       <role-hint>test</role-hint>
       <implementation>org.apache.maven.project.TestProjectBuilder</implementation>
       <requirements>
         <requirement>
+             <role>org.apache.maven.project.builder.ProjectBuilder</role>
+        </requirement>          
+        <requirement>
           <role>org.apache.maven.project.workspace.ProjectWorkspace</role>
         </requirement>
         <requirement>

Modified: maven/sandbox/branches/SI_MAVEN_2_1/maven-project/src/test/resources/org/apache/maven/project/canonical/CanonicalProjectBuilderTest.xml
URL: http://svn.apache.org/viewvc/maven/sandbox/branches/SI_MAVEN_2_1/maven-project/src/test/resources/org/apache/maven/project/canonical/CanonicalProjectBuilderTest.xml?rev=676674&r1=676673&r2=676674&view=diff
==============================================================================
--- maven/sandbox/branches/SI_MAVEN_2_1/maven-project/src/test/resources/org/apache/maven/project/canonical/CanonicalProjectBuilderTest.xml
(original)
+++ maven/sandbox/branches/SI_MAVEN_2_1/maven-project/src/test/resources/org/apache/maven/project/canonical/CanonicalProjectBuilderTest.xml
Mon Jul 14 11:37:33 2008
@@ -73,12 +73,26 @@
         </requirement>
       </requirements>
     </component>
+      <component>
+            <role>org.apache.maven.project.builder.ProjectBuilder</role>
+            <role-hint>default</role-hint>
+            <implementation>org.apache.maven.project.builder.impl.DefaultProjectBuilder</implementation>
+            <requirements>
+                <requirement>
+                    <role>org.apache.maven.artifact.factory.ArtifactFactory</role>
+                </requirement>
+            </requirements>
+        </component>
+
     <component>
       <role>org.apache.maven.project.MavenProjectBuilder</role>
       <role-hint>test</role-hint>
       <implementation>org.apache.maven.project.TestProjectBuilder</implementation>
       <requirements>
         <requirement>
+             <role>org.apache.maven.project.builder.ProjectBuilder</role>
+        </requirement>
+        <requirement>
           <role>org.apache.maven.project.workspace.ProjectWorkspace</role>
         </requirement>
         <requirement>



Mime
View raw message