continuum-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From eveni...@apache.org
Subject svn commit: r478588 - in /maven/continuum/trunk: continuum-api/src/main/java/org/apache/maven/continuum/project/builder/ continuum-core/src/main/java/org/apache/maven/continuum/execution/maven/m2/ continuum-core/src/main/java/org/apache/maven/continuum...
Date Thu, 23 Nov 2006 14:23:49 GMT
Author: evenisse
Date: Thu Nov 23 06:23:48 2006
New Revision: 478588

URL: http://svn.apache.org/viewvc?view=rev&rev=478588
Log:
[CONTINUUM-1011] Fix NPE in DefaultMavenBuilderHelper and remove some deprecated methods

Modified:
    maven/continuum/trunk/continuum-api/src/main/java/org/apache/maven/continuum/project/builder/ContinuumProjectBuildingResult.java
    maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/execution/maven/m2/DefaultMavenBuilderHelper.java
    maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/execution/maven/m2/MavenBuilderHelper.java
    maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/execution/maven/m2/MavenTwoBuildExecutor.java
    maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/project/builder/maven/MavenTwoContinuumProjectBuilder.java

Modified: maven/continuum/trunk/continuum-api/src/main/java/org/apache/maven/continuum/project/builder/ContinuumProjectBuildingResult.java
URL: http://svn.apache.org/viewvc/maven/continuum/trunk/continuum-api/src/main/java/org/apache/maven/continuum/project/builder/ContinuumProjectBuildingResult.java?view=diff&rev=478588&r1=478587&r2=478588
==============================================================================
--- maven/continuum/trunk/continuum-api/src/main/java/org/apache/maven/continuum/project/builder/ContinuumProjectBuildingResult.java
(original)
+++ maven/continuum/trunk/continuum-api/src/main/java/org/apache/maven/continuum/project/builder/ContinuumProjectBuildingResult.java
Thu Nov 23 06:23:48 2006
@@ -20,12 +20,13 @@
 import org.apache.maven.continuum.model.project.ProjectGroup;
 
 import java.util.ArrayList;
+import java.util.Iterator;
 import java.util.List;
 
 /**
  * Holder for results of adding projects to Continuum. Contains added projects, project groups
  * and errors that happened during the add.
- * 
+ *
  * @author <a href="mailto:trygvis@inamo.no">Trygve Laugst&oslash;l</a>
  * @author <a href="mailto:carlos@apache.org">Carlos Sanchez</a>
  * @version $Id$
@@ -60,7 +61,8 @@
 
     public static final String ERROR_MISSING_NOTIFIER_TYPE = "add.project.missing.notifier.type.error";
 
-    public static final String ERROR_MISSING_NOTIFIER_CONFIGURATION = "add.project.missing.notifier.configuration.error";
+    public static final String ERROR_MISSING_NOTIFIER_CONFIGURATION =
+        "add.project.missing.notifier.configuration.error";
 
     public static final String ERROR_METADATA_TRANSFER = "add.project.metadata.transfer.error";
 
@@ -109,7 +111,7 @@
 
     /**
      * Add a warning that happened during adding the project to Continuum.
-     * 
+     *
      * @param warningKey warning id (so it can be internationalized later)
      * @deprecated Use {@link #addError(String)} instead
      */
@@ -120,7 +122,7 @@
 
     /**
      * Add an error that happened during adding the project to Continuum.
-     * 
+     *
      * @param errorKey error id (so it can be internationalized later)
      */
     public void addError( String errorKey )
@@ -130,7 +132,7 @@
 
     /**
      * Add an error that happened during adding the project to Continuum.
-     * 
+     *
      * @param errorKey error id (so it can be internationalized later)
      */
     public void addError( String errorKey, Object param )
@@ -141,7 +143,7 @@
 
     /**
      * Add an error that happened during adding the project to Continuum.
-     * 
+     *
      * @param errorKey error id (so it can be internationalized later)
      */
     public void addError( String errorKey, Object params[] )
@@ -153,7 +155,7 @@
     /**
      * Get the warnings that happened during adding the project to Continuum.
      * There is an entry with the warning key (so it can be internationalized later) for
each warning.
-     * 
+     *
      * @return {@link List} &lt; {@link String} >
      * @deprecated Use {@link #getErrors()} instead
      */
@@ -165,7 +167,7 @@
     /**
      * Get the errors that happened during adding the project to Continuum.
      * There is an entry with the error key (so it can be internationalized later) for each
error.
-     * 
+     *
      * @return {@link List} &lt; {@link String} >
      */
     public List getErrors()
@@ -175,11 +177,33 @@
 
     /**
      * Quick check to see if there are any errors.
-     * 
+     *
      * @return boolean indicating if there are any errors.
      */
     public boolean hasErrors()
     {
         return ( errors != null ) && ( !errors.isEmpty() );
+    }
+
+    /**
+     * Returns a string representation of the errors.
+     *
+     * @return a string representation of the errors.
+     */
+    public String getErrorsAsString()
+    {
+        if ( !hasErrors() )
+        {
+            return null;
+        }
+
+        StringBuffer message = new StringBuffer();
+        for ( Iterator i = errors.iterator(); i.hasNext(); )
+        {
+            String error = (String) i.next();
+            message.append( error );
+            message.append( "\n" );
+        }
+        return message.toString();
     }
 }

Modified: maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/execution/maven/m2/DefaultMavenBuilderHelper.java
URL: http://svn.apache.org/viewvc/maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/execution/maven/m2/DefaultMavenBuilderHelper.java?view=diff&rev=478588&r1=478587&r2=478588
==============================================================================
--- maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/execution/maven/m2/DefaultMavenBuilderHelper.java
(original)
+++ maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/execution/maven/m2/DefaultMavenBuilderHelper.java
Thu Nov 23 06:23:48 2006
@@ -72,10 +72,8 @@
  * @author <a href="mailto:trygvis@inamo.no">Trygve Laugst&oslash;l</a>
  * @author <a href="mailto:evenisse@apache.org">Emmanuel Venisse</a>
  * @version $Id$
- *
- * @plexus.component
- *   role="org.apache.maven.continuum.execution.maven.m2.MavenBuilderHelper"
- *   role-hint="default"
+ * @plexus.component role="org.apache.maven.continuum.execution.maven.m2.MavenBuilderHelper"
+ * role-hint="default"
  */
 public class DefaultMavenBuilderHelper
     extends AbstractLogEnabled
@@ -118,29 +116,29 @@
     // ----------------------------------------------------------------------
     // MavenBuilderHelper Implementation
     // ----------------------------------------------------------------------
-    /**
-     * @deprecated use {@link #mapMavenProjectToContinuumProject(ContinuumProjectBuildingResult,
MavenProject, Project, boolean)} instead.
-     */
-    public void mapMetadataToProject( File metadata, Project continuumProject )
-        throws MavenBuilderHelperException
-    {
-        // todo this is deprecated so it shouldn't be used anyway so just set false for groupPom
boolean and clean up later
-        mapMavenProjectToContinuumProject( getMavenProject( metadata ), continuumProject,
false );
-    }
 
-    /**
-     * @deprecated use {@link #mapMavenProjectToContinuumProject(ContinuumProjectBuildingResult,
MavenProject, Project, boolean)} instead.
-     */
-    public void mapMavenProjectToContinuumProject( MavenProject mavenProject, Project continuumProject,
boolean groupPom )
-        throws MavenBuilderHelperException
+    public void mapMetadataToProject( ContinuumProjectBuildingResult result, File metadata,
Project continuumProject )
     {
-        mapMavenProjectToContinuumProject( new ContinuumProjectBuildingResult(), mavenProject,
continuumProject, groupPom );
+        MavenProject mavenProject = getMavenProject( result, metadata );
+
+        if ( mavenProject == null )
+        {
+            //result is already populated
+            return;
+        }
+
+        mapMavenProjectToContinuumProject( result, mavenProject, continuumProject, false
);
     }
-    
-    public void mapMavenProjectToContinuumProject( ContinuumProjectBuildingResult result,
MavenProject mavenProject, Project continuumProject, boolean groupPom )
-        throws MavenBuilderHelperException
+
+    public void mapMavenProjectToContinuumProject( ContinuumProjectBuildingResult result,
MavenProject mavenProject,
+                                                   Project continuumProject, boolean groupPom
)
     {
-    
+        if ( mavenProject == null )
+        {
+            result.addError( ContinuumProjectBuildingResult.ERROR_UNKNOWN, "The maven project
is null" );
+            return;
+        }
+
         // ----------------------------------------------------------------------
         // Name
         // ----------------------------------------------------------------------
@@ -332,20 +330,11 @@
             }
         }
     }
-    
-    /**
-     * @deprecated use {@link #getMavenProject(ContinuumProjectBuildingResult, File)} instead.
-     */
-    public MavenProject getMavenProject( File file )
-    throws MavenBuilderHelperException
-    {
-        return getMavenProject( new ContinuumProjectBuildingResult(), file );
-    }
 
     public MavenProject getMavenProject( ContinuumProjectBuildingResult result, File file
)
     {
         MavenProject project;
-        
+
         try
         {
             //   TODO: This seems like code that is shared with DefaultMaven, so it should
be moved to the project
@@ -372,8 +361,8 @@
             StringBuffer messages = new StringBuffer();
 
             Throwable cause = e.getCause();
-            
-            if( cause != null )
+
+            if ( cause != null )
             {
                 while ( ( cause.getCause() != null ) && ( cause instanceof ProjectBuildingException
) )
                 {
@@ -409,7 +398,7 @@
             result.addError( ContinuumProjectBuildingResult.ERROR_PROJECT_BUILDING, e.getMessage()
);
 
             String msg = "Cannot build maven project from " + file + " (" + e.getMessage()
+ ").\n" + messages;
-            
+
             file.delete();
 
             getLogger().error( msg );
@@ -419,12 +408,14 @@
         // TODO catch all exceptions is bad
         catch ( Exception e )
         {
+            result.addError( ContinuumProjectBuildingResult.ERROR_PROJECT_BUILDING, e.getMessage()
);
+
             String msg = "Cannot build maven project from " + file + " (" + e.getMessage()
+ ").";
 
             file.delete();
-            
+
             getLogger().error( msg );
-            
+
             return null;
         }
 
@@ -438,9 +429,9 @@
         if ( scm == null )
         {
             result.addError( ContinuumProjectBuildingResult.ERROR_MISSING_SCM, getProjectName(
project ) );
-            
+
             getLogger().error( "Missing 'scm' element in the " + getProjectName( project
) + " POM." );
-            
+
             return null;
         }
 
@@ -449,9 +440,10 @@
         if ( StringUtils.isEmpty( url ) )
         {
             result.addError( ContinuumProjectBuildingResult.ERROR_MISSING_SCM_CONNECTION,
getProjectName( project ) );
-            
-            getLogger().error( "Missing 'connection' element in the 'scm' element in the
" + getProjectName( project ) + " POM." );
-            
+
+            getLogger().error(
+                "Missing 'connection' element in the 'scm' element in the " + getProjectName(
project ) + " POM." );
+
             return null;
         }
 
@@ -484,7 +476,8 @@
         return project.getScm().getConnection();
     }
 
-    private List getNotifiers( ContinuumProjectBuildingResult result, MavenProject mavenProject,
Project continuumProject )
+    private List getNotifiers( ContinuumProjectBuildingResult result, MavenProject mavenProject,
+                               Project continuumProject )
     {
         List notifiers = new ArrayList();
 

Modified: maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/execution/maven/m2/MavenBuilderHelper.java
URL: http://svn.apache.org/viewvc/maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/execution/maven/m2/MavenBuilderHelper.java?view=diff&rev=478588&r1=478587&r2=478588
==============================================================================
--- maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/execution/maven/m2/MavenBuilderHelper.java
(original)
+++ maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/execution/maven/m2/MavenBuilderHelper.java
Thu Nov 23 06:23:48 2006
@@ -31,24 +31,11 @@
 {
     String ROLE = MavenBuilderHelper.class.getName();
 
-    void mapMetadataToProject( File metadata, Project project )
-        throws MavenBuilderHelperException;
-
-    /**
-     * @deprecated use {@link #getMavenProject(ContinuumProjectBuildingResult, File)} instead.
-     */
-    MavenProject getMavenProject( File file )
-        throws MavenBuilderHelperException;
+    void mapMetadataToProject( ContinuumProjectBuildingResult result, File metadata, Project
project );
 
     MavenProject getMavenProject( ContinuumProjectBuildingResult result, File file );
 
     /**
-     * @deprecated use {@link #mapMavenProjectToContinuumProject(ContinuumProjectBuildingResult,
MavenProject, Project, boolean)} instead.
-     */
-    void mapMavenProjectToContinuumProject( MavenProject mavenProject, Project continuumProject,
boolean groupPom )
-        throws MavenBuilderHelperException;
-
-    /**
      *
      * @param result
      * @param mavenProject
@@ -56,8 +43,7 @@
      * @param groupPom map this project as if it is being used to initialize a project group
      */
     void mapMavenProjectToContinuumProject( ContinuumProjectBuildingResult result, MavenProject
mavenProject,
-                                            Project continuumProject, boolean groupPom )
-        throws MavenBuilderHelperException;
+                                            Project continuumProject, boolean groupPom );
 
     ArtifactRepository getLocalRepository();
 }

Modified: maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/execution/maven/m2/MavenTwoBuildExecutor.java
URL: http://svn.apache.org/viewvc/maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/execution/maven/m2/MavenTwoBuildExecutor.java?view=diff&rev=478588&r1=478587&r2=478588
==============================================================================
--- maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/execution/maven/m2/MavenTwoBuildExecutor.java
(original)
+++ maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/execution/maven/m2/MavenTwoBuildExecutor.java
Thu Nov 23 06:23:48 2006
@@ -24,24 +24,25 @@
 import org.apache.maven.continuum.execution.ContinuumBuildExecutorException;
 import org.apache.maven.continuum.model.project.BuildDefinition;
 import org.apache.maven.continuum.model.project.Project;
+import org.apache.maven.continuum.model.scm.SuiteResult;
+import org.apache.maven.continuum.model.scm.TestCaseFailure;
+import org.apache.maven.continuum.model.scm.TestResult;
+import org.apache.maven.continuum.project.builder.ContinuumProjectBuildingResult;
 import org.apache.maven.project.MavenProject;
 import org.apache.maven.project.MavenProjectHelper;
 import org.apache.maven.project.artifact.ProjectArtifactMetadata;
-import org.apache.maven.continuum.model.scm.TestResult;
-import org.apache.maven.continuum.model.scm.SuiteResult;
-import org.apache.maven.continuum.model.scm.TestCaseFailure;
-import org.codehaus.plexus.util.StringUtils;
 import org.codehaus.plexus.util.DirectoryScanner;
-import org.codehaus.plexus.util.xml.pull.XmlPullParser;
+import org.codehaus.plexus.util.StringUtils;
 import org.codehaus.plexus.util.xml.pull.MXParser;
+import org.codehaus.plexus.util.xml.pull.XmlPullParser;
 import org.codehaus.plexus.util.xml.pull.XmlPullParserException;
-  
+
 import java.io.File;
+import java.io.FileNotFoundException;
 import java.io.FileReader;
+import java.io.IOException;
 import java.util.ArrayList;
 import java.util.List;
-import java.io.IOException;
-import java.io.FileNotFoundException;
 
 /**
  * @author <a href="mailto:trygvis@inamo.no">Trygve Laugst&oslash;l</a>
@@ -118,13 +119,13 @@
             throw new ContinuumBuildExecutorException( "Could not find Maven project descriptor."
);
         }
 
-        try
-        {
-            builderHelper.mapMetadataToProject( f, project );
-        }
-        catch ( MavenBuilderHelperException e )
+        ContinuumProjectBuildingResult result = new ContinuumProjectBuildingResult();
+
+        builderHelper.mapMetadataToProject( result, f, project );
+
+        if ( result.hasErrors() )
         {
-            throw new ContinuumBuildExecutorException( "Error while mapping metadata.", e
);
+            throw new ContinuumBuildExecutorException( "Error while mapping metadata:" +
result.getErrorsAsString() );
         }
     }
 
@@ -162,14 +163,14 @@
 
         MavenProject project;
 
-        try
-        {
-            project = builderHelper.getMavenProject( f );
-        }
-        catch ( MavenBuilderHelperException e )
+        ContinuumProjectBuildingResult result = new ContinuumProjectBuildingResult();
+
+        project = builderHelper.getMavenProject( result, f );
+
+        if ( result.hasErrors() )
         {
             throw new ContinuumBuildExecutorException(
-                "Unable to read the Maven project descriptor '" + f + "': " + e.getMessage(),
e );
+                "Unable to read the Maven project descriptor '" + f + "': " + result.getErrorsAsString()
);
         }
 
         List artifacts = new ArrayList( 1 );
@@ -253,19 +254,19 @@
         return artifacts;
     }
 
-    public TestResult getTestResults(Project project)
-            throws ContinuumBuildExecutorException {
-        return getTestResults(getWorkingDirectory(project));
+    public TestResult getTestResults( Project project )
+        throws ContinuumBuildExecutorException
+    {
+        return getTestResults( getWorkingDirectory( project ) );
     }
 
-    private TestResult getTestResults(File workingDir)
-            throws ContinuumBuildExecutorException {
+    private TestResult getTestResults( File workingDir )
+        throws ContinuumBuildExecutorException
+    {
         DirectoryScanner scanner = new DirectoryScanner();
-        scanner.setBasedir(workingDir);
-        scanner.setIncludes(new String[] {
-                "**/target/surefire-reports/TEST-*.xml",
-                "**/target/surefire-it-reports/TEST-*.xml"
-        });
+        scanner.setBasedir( workingDir );
+        scanner.setIncludes(
+            new String[]{"**/target/surefire-reports/TEST-*.xml", "**/target/surefire-it-reports/TEST-*.xml"}
);
         scanner.scan();
 
         TestResult testResult = new TestResult();
@@ -273,44 +274,51 @@
         int failureCount = 0;
         int totalTime = 0;
         String[] testResultFiles = scanner.getIncludedFiles();
-        for (int i = 0; i < testResultFiles.length; i++) {
-            File xmlFile = new File(workingDir, testResultFiles[i]);
+        for ( int i = 0; i < testResultFiles.length; i++ )
+        {
+            File xmlFile = new File( workingDir, testResultFiles[i] );
             SuiteResult suite = new SuiteResult();
-            try {
+            try
+            {
                 XmlPullParser parser = new MXParser();
-                parser.setInput(new FileReader(xmlFile));
-                if (parser.next() != XmlPullParser.START_TAG || !"testsuite".equals(parser.getName()))
{
+                parser.setInput( new FileReader( xmlFile ) );
+                if ( parser.next() != XmlPullParser.START_TAG || !"testsuite".equals( parser.getName()
) )
+                {
                     continue;
                 }
 
-                suite.setName(parser.getAttributeValue(null, "name"));
+                suite.setName( parser.getAttributeValue( null, "name" ) );
 
-                int suiteFailureCount =
-                        Integer.parseInt(parser.getAttributeValue(null, "errors")) +
-                        Integer.parseInt(parser.getAttributeValue(null, "failures"));
+                int suiteFailureCount = Integer.parseInt( parser.getAttributeValue( null,
"errors" ) ) +
+                    Integer.parseInt( parser.getAttributeValue( null, "failures" ) );
 
-                long suiteTotalTime =
-                        (long) (1000 * Double.parseDouble(parser.getAttributeValue(null,
"time")));
+                long suiteTotalTime = (long) ( 1000 * Double.parseDouble( parser.getAttributeValue(
null, "time" ) ) );
 
                 // TODO: add tests attribute to testsuite element so we only
                 // have to parse the rest of the file if there are failures
                 int suiteTestCount = 0;
-                while (!(parser.next() == XmlPullParser.END_TAG && "testsuite".equals(parser.getName())))
{
-                    if (parser.getEventType() == XmlPullParser.START_TAG && "testcase".equals(parser.getName()))
{
+                while ( !( parser.next() == XmlPullParser.END_TAG && "testsuite".equals(
parser.getName() ) ) )
+                {
+                    if ( parser.getEventType() == XmlPullParser.START_TAG && "testcase".equals(
parser.getName() ) )
+                    {
                         suiteTestCount++;
-                        String name = parser.getAttributeValue(null, "name");
-                        do {
+                        String name = parser.getAttributeValue( null, "name" );
+                        do
+                        {
                             parser.next();
-                        } while (parser.getEventType() != XmlPullParser.START_TAG &&
-                                 parser.getEventType() != XmlPullParser.END_TAG);
-                        if (parser.getEventType() == XmlPullParser.START_TAG &&
-                                ("error".equals(parser.getName()) || "failure".equals(parser.getName())))
{
+                        }
+                        while ( parser.getEventType() != XmlPullParser.START_TAG &&
+                            parser.getEventType() != XmlPullParser.END_TAG );
+                        if ( parser.getEventType() == XmlPullParser.START_TAG &&
+                            ( "error".equals( parser.getName() ) || "failure".equals( parser.getName()
) ) )
+                        {
                             TestCaseFailure failure = new TestCaseFailure();
-                            failure.setName(name);
-                            if (parser.next() == XmlPullParser.TEXT) {
-                                failure.setException(parser.getText());
+                            failure.setName( name );
+                            if ( parser.next() == XmlPullParser.TEXT )
+                            {
+                                failure.setException( parser.getText() );
                             }
-                            suite.addFailure(failure);
+                            suite.addFailure( failure );
                         }
                     }
                 }
@@ -319,25 +327,28 @@
                 failureCount += suiteFailureCount;
                 totalTime += suiteTotalTime;
 
-                suite.setTestCount(suiteTestCount);
-                suite.setFailureCount(suiteFailureCount);
-                suite.setTotalTime(suiteTotalTime);
-            } catch (XmlPullParserException xppex) {
-                throw new ContinuumBuildExecutorException(
-                        "Error parsing file: " + xmlFile, xppex);
-            } catch (FileNotFoundException fnfex) {
-                throw new ContinuumBuildExecutorException(
-                        "Test file not found", fnfex);
-            } catch (IOException ioex) {
-                throw new ContinuumBuildExecutorException(
-                        "Parsing error for file: " + xmlFile, ioex);
+                suite.setTestCount( suiteTestCount );
+                suite.setFailureCount( suiteFailureCount );
+                suite.setTotalTime( suiteTotalTime );
+            }
+            catch ( XmlPullParserException xppex )
+            {
+                throw new ContinuumBuildExecutorException( "Error parsing file: " + xmlFile,
xppex );
+            }
+            catch ( FileNotFoundException fnfex )
+            {
+                throw new ContinuumBuildExecutorException( "Test file not found", fnfex );
+            }
+            catch ( IOException ioex )
+            {
+                throw new ContinuumBuildExecutorException( "Parsing error for file: " + xmlFile,
ioex );
             }
-            testResult.addSuiteResult(suite);
+            testResult.addSuiteResult( suite );
         }
 
-        testResult.setTestCount(testCount);
-        testResult.setFailureCount(failureCount);
-        testResult.setTotalTime(totalTime);
+        testResult.setTestCount( testCount );
+        testResult.setFailureCount( failureCount );
+        testResult.setTotalTime( totalTime );
 
         return testResult;
     }

Modified: maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/project/builder/maven/MavenTwoContinuumProjectBuilder.java
URL: http://svn.apache.org/viewvc/maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/project/builder/maven/MavenTwoContinuumProjectBuilder.java?view=diff&rev=478588&r1=478587&r2=478588
==============================================================================
--- maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/project/builder/maven/MavenTwoContinuumProjectBuilder.java
(original)
+++ maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/project/builder/maven/MavenTwoContinuumProjectBuilder.java
Thu Nov 23 06:23:48 2006
@@ -18,21 +18,20 @@
 
 import org.apache.maven.continuum.execution.maven.m2.MavenBuilderHelper;
 import org.apache.maven.continuum.execution.maven.m2.MavenTwoBuildExecutor;
-import org.apache.maven.continuum.execution.maven.m2.MavenBuilderHelperException;
 import org.apache.maven.continuum.initialization.DefaultContinuumInitializer;
 import org.apache.maven.continuum.model.project.BuildDefinition;
 import org.apache.maven.continuum.model.project.Project;
 import org.apache.maven.continuum.model.project.ProjectGroup;
-import org.apache.maven.continuum.model.project.Schedule;
 import org.apache.maven.continuum.model.project.ProjectNotifier;
+import org.apache.maven.continuum.model.project.Schedule;
 import org.apache.maven.continuum.project.builder.AbstractContinuumProjectBuilder;
 import org.apache.maven.continuum.project.builder.ContinuumProjectBuilder;
 import org.apache.maven.continuum.project.builder.ContinuumProjectBuilderException;
 import org.apache.maven.continuum.project.builder.ContinuumProjectBuildingResult;
 import org.apache.maven.continuum.store.ContinuumStore;
 import org.apache.maven.continuum.store.ContinuumStoreException;
-import org.apache.maven.project.MavenProject;
 import org.apache.maven.model.Notifier;
+import org.apache.maven.project.MavenProject;
 import org.codehaus.plexus.util.StringUtils;
 
 import java.io.FileNotFoundException;
@@ -47,10 +46,8 @@
 /**
  * @author <a href="mailto:trygvis@inamo.no">Trygve Laugst&oslash;l</a>
  * @version $Id$
- *
- * @plexus.component
- *   role="org.apache.maven.continuum.project.builder.ContinuumProjectBuilder"
- *   role-hint="maven-two-builder"
+ * @plexus.component role="org.apache.maven.continuum.project.builder.ContinuumProjectBuilder"
+ * role-hint="maven-two-builder"
  */
 public class MavenTwoContinuumProjectBuilder
     extends AbstractContinuumProjectBuilder
@@ -196,29 +193,27 @@
             if ( username != null && StringUtils.isNotEmpty( username ) )
             {
                 continuumProject.setScmUsername( username );
-                
+
                 if ( password != null && StringUtils.isNotEmpty( password ) )
                 {
                     continuumProject.setScmPassword( password );
                 }
             }
 
-            try
-            {
-                builderHelper.mapMavenProjectToContinuumProject( result, mavenProject, continuumProject,
groupPom );
-            }
-            catch ( MavenBuilderHelperException e )
+            builderHelper.mapMavenProjectToContinuumProject( result, mavenProject, continuumProject,
groupPom );
+
+            if ( result.hasErrors() )
             {
-                getLogger().info( "Error adding project: Unknown error mapping project "
+ url, e );
-                result.addError( ContinuumProjectBuildingResult.ERROR_MISSING_SCM_CONNECTION
);
+                getLogger().info(
+                    "Error adding project: Unknown error mapping project " + url + ": " +
result.getErrorsAsString() );
                 return;
             }
 
             // Rewrite scmurl from the one found in added project due to a bug in scm url
resolution
             // for projects that doesn't have module name != artifactId
-            if ( StringUtils.isNotEmpty( scmUrl))
+            if ( StringUtils.isNotEmpty( scmUrl ) )
             {
-                continuumProject.setScmUrl( scmUrl);
+                continuumProject.setScmUrl( scmUrl );
             }
             else
             {
@@ -271,7 +266,7 @@
                 continue;
             }
 
-            readModules( moduleUrl, result, false, username, password, scmUrl+"/"+module
);
+            readModules( moduleUrl, result, false, username, password, scmUrl + "/" + module
);
         }
     }
 
@@ -311,7 +306,6 @@
 
         projectGroup.setDescription( mavenProject.getDescription() );
 
-
         //
         // group lvl notifiers
         //
@@ -356,7 +350,6 @@
 
             projectGroup.setNotifiers( notifiers );
         }
-
 
         return projectGroup;
     }



Mime
View raw message