You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@continuum.apache.org by ol...@apache.org on 2008/06/06 22:51:30 UTC

svn commit: r664117 - in /continuum/trunk: ./ continuum-api/src/main/java/org/apache/maven/continuum/project/builder/ continuum-core/src/main/java/org/apache/maven/continuum/ continuum-core/src/test-poms/ continuum-core/src/test-projects/project2/ cont...

Author: olamy
Date: Fri Jun  6 13:51:29 2008
New Revision: 664117

URL: http://svn.apache.org/viewvc?rev=664117&view=rev
Log:
[CONTINUUM-1511] Improve error handling when not able to resolv artifacts


Added:
    continuum/trunk/continuum-core/src/test-poms/
    continuum/trunk/continuum-core/src/test-poms/pom-unknown-dependency.xml   (with props)
    continuum/trunk/continuum-core/src/test-poms/pom.xml   (with props)
    continuum/trunk/continuum-core/src/test/java/org/apache/maven/continuum/execution/maven/m2/
    continuum/trunk/continuum-core/src/test/java/org/apache/maven/continuum/execution/maven/m2/TestMavenBuilderHelper.java   (with props)
Modified:
    continuum/trunk/continuum-api/src/main/java/org/apache/maven/continuum/project/builder/ContinuumProjectBuildingResult.java
    continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/DefaultContinuum.java
    continuum/trunk/continuum-core/src/test-projects/project2/pom.xml
    continuum/trunk/continuum-core/src/test/resources/log4j.xml
    continuum/trunk/pom.xml

Modified: continuum/trunk/continuum-api/src/main/java/org/apache/maven/continuum/project/builder/ContinuumProjectBuildingResult.java
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-api/src/main/java/org/apache/maven/continuum/project/builder/ContinuumProjectBuildingResult.java?rev=664117&r1=664116&r2=664117&view=diff
==============================================================================
--- continuum/trunk/continuum-api/src/main/java/org/apache/maven/continuum/project/builder/ContinuumProjectBuildingResult.java (original)
+++ continuum/trunk/continuum-api/src/main/java/org/apache/maven/continuum/project/builder/ContinuumProjectBuildingResult.java Fri Jun  6 13:51:29 2008
@@ -19,12 +19,14 @@
  * under the License.
  */
 
-import org.apache.maven.continuum.model.project.Project;
-import org.apache.maven.continuum.model.project.ProjectGroup;
-
 import java.util.ArrayList;
-import java.util.Iterator;
+import java.util.Arrays;
+import java.util.HashMap;
 import java.util.List;
+import java.util.Map;
+
+import org.apache.maven.continuum.model.project.Project;
+import org.apache.maven.continuum.model.project.ProjectGroup;
 
 /**
  * Holder for results of adding projects to Continuum. Contains added projects, project groups
@@ -81,11 +83,13 @@
 
     public static final String ERROR_UNKNOWN = "add.project.unknown.error";
 
-    private List projects = new ArrayList();
+    private List<Project> projects = new ArrayList<Project>();
 
-    private List projectGroups = new ArrayList();
+    private List<ProjectGroup> projectGroups = new ArrayList<ProjectGroup>();
 
-    private List errors = new ArrayList();
+    private Map<String, String> errors = new HashMap<String, String>();
+    
+    public static final String LS = System.getProperty( "line.separator" );
 
     public void addProject( Project project )
     {
@@ -104,12 +108,12 @@
         projects.add( project );
     }
 
-    public List getProjects()
+    public List<Project> getProjects()
     {
         return projects;
     }
 
-    public List getProjectGroups()
+    public List<ProjectGroup> getProjectGroups()
     {
         return projectGroups;
     }
@@ -132,7 +136,7 @@
      */
     public void addError( String errorKey )
     {
-        errors.add( errorKey );
+        errors.put( errorKey, "" );
     }
 
     /**
@@ -142,8 +146,7 @@
      */
     public void addError( String errorKey, Object param )
     {
-        // TODO: store the parameters.
-        errors.add( errorKey );
+        errors.put( errorKey, param == null ? "" : param.toString() );
     }
 
     /**
@@ -153,8 +156,10 @@
      */
     public void addError( String errorKey, Object params[] )
     {
-        // TODO: store the parameters.
-        errors.add( errorKey );
+        if ( params != null )
+        {
+            errors.put( errorKey, Arrays.asList( params ).toString() );
+        }
     }
 
     /**
@@ -164,7 +169,7 @@
      * @return {@link List} &lt; {@link String} >
      * @deprecated Use {@link #getErrors()} instead
      */
-    public List getWarnings()
+    public List<String> getWarnings()
     {
         return getErrors();
     }
@@ -175,10 +180,15 @@
      *
      * @return {@link List} &lt; {@link String} >
      */
-    public List getErrors()
+    public List<String> getErrors()
     {
-        return errors;
+        return new ArrayList<String>( errors.keySet() );
     }
+    
+    public Map<String,String> getErrorsWithCause()
+    {
+        return errors;
+    }    
 
     /**
      * Quick check to see if there are any errors.
@@ -202,12 +212,11 @@
             return null;
         }
 
-        StringBuffer message = new StringBuffer();
-        for ( Iterator i = errors.iterator(); i.hasNext(); )
+        StringBuilder message = new StringBuilder();
+        for ( String key : errors.keySet() )
         {
-            String error = (String) i.next();
-            message.append( error );
-            message.append( "\n" );
+            message.append( errors.get( key ) );
+            message.append( LS );
         }
         return message.toString();
     }

Modified: continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/DefaultContinuum.java
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/DefaultContinuum.java?rev=664117&r1=664116&r2=664117&view=diff
==============================================================================
--- continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/DefaultContinuum.java (original)
+++ continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/DefaultContinuum.java Fri Jun  6 13:51:29 2008
@@ -1744,12 +1744,7 @@
             if ( result.hasErrors() )
             {
                 getLogger().info( result.getErrors().size() + " errors during project add: " );
-
-                for ( Iterator i = result.getErrors().iterator(); i.hasNext(); )
-                {
-                    getLogger().info( (String) i.next() );
-                }
-
+                getLogger().info( result.getErrorsAsString() );
                 return result;
             }
         }

Added: continuum/trunk/continuum-core/src/test-poms/pom-unknown-dependency.xml
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-core/src/test-poms/pom-unknown-dependency.xml?rev=664117&view=auto
==============================================================================
--- continuum/trunk/continuum-core/src/test-poms/pom-unknown-dependency.xml (added)
+++ continuum/trunk/continuum-core/src/test-poms/pom-unknown-dependency.xml Fri Jun  6 13:51:29 2008
@@ -0,0 +1,45 @@
+<!--
+  ~ Licensed to the Apache Software Foundation (ASF) under one
+  ~ or more contributor license agreements.  See the NOTICE file
+  ~ distributed with this work for additional information
+  ~ regarding copyright ownership.  The ASF licenses this file
+  ~ to you 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.
+  -->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+  <modelVersion>4.0.0</modelVersion>
+  <groupId>plexus</groupId>
+  <artifactId>continuum-project2</artifactId>
+  <packaging>jar</packaging>
+  <name>Continuum Test Project 2</name>
+  <version>1.0</version>
+  <parent>
+    <groupId>ghd</groupId>
+    <artifactId>non-exists</artifactId>
+    <version>2.6.267676-beta-754-alpha-95</version>
+  </parent>
+  
+  <scm>
+    <connection>scm:cvs:local:ignores:/cvs/root:project2</connection>
+    <url>http://cvs.plexus.codehaus.org/plexus-components/native/continuum/src/test-projects/project2</url>
+  </scm>
+  
+  <dependencies>
+    <dependency>
+      <groupId>foo</groupId>
+      <artifactId>not-exist</artifactId>
+      <version>alpha-1666-beta-89-SNAPSHOT</version>
+    </dependency>
+  </dependencies>
+</project>
\ No newline at end of file

Propchange: continuum/trunk/continuum-core/src/test-poms/pom-unknown-dependency.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: continuum/trunk/continuum-core/src/test-poms/pom-unknown-dependency.xml
------------------------------------------------------------------------------
    svn:executable = *

Propchange: continuum/trunk/continuum-core/src/test-poms/pom-unknown-dependency.xml
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Added: continuum/trunk/continuum-core/src/test-poms/pom.xml
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-core/src/test-poms/pom.xml?rev=664117&view=auto
==============================================================================
--- continuum/trunk/continuum-core/src/test-poms/pom.xml (added)
+++ continuum/trunk/continuum-core/src/test-poms/pom.xml Fri Jun  6 13:51:29 2008
@@ -0,0 +1,33 @@
+<!--
+  ~ Licensed to the Apache Software Foundation (ASF) under one
+  ~ or more contributor license agreements.  See the NOTICE file
+  ~ distributed with this work for additional information
+  ~ regarding copyright ownership.  The ASF licenses this file
+  ~ to you 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.
+  -->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+  <modelVersion>4.0.0</modelVersion>
+  <groupId>plexus</groupId>
+  <artifactId>continuum-project2</artifactId>
+  <packaging>jar</packaging>
+  <name>Continuum Test Project 2</name>
+  <version>1.0</version>
+  
+  <scm>
+    <connection>scm:cvs:local:ignores:/cvs/root:project2</connection>
+    <url>http://cvs.plexus.codehaus.org/plexus-components/native/continuum/src/test-projects/project2</url>
+  </scm>
+  
+</project>
\ No newline at end of file

Propchange: continuum/trunk/continuum-core/src/test-poms/pom.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: continuum/trunk/continuum-core/src/test-poms/pom.xml
------------------------------------------------------------------------------
    svn:executable = *

Propchange: continuum/trunk/continuum-core/src/test-poms/pom.xml
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Modified: continuum/trunk/continuum-core/src/test-projects/project2/pom.xml
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-core/src/test-projects/project2/pom.xml?rev=664117&r1=664116&r2=664117&view=diff
==============================================================================
--- continuum/trunk/continuum-core/src/test-projects/project2/pom.xml (original)
+++ continuum/trunk/continuum-core/src/test-projects/project2/pom.xml Fri Jun  6 13:51:29 2008
@@ -17,7 +17,7 @@
   ~ under the License.
   -->
 
-<model>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
   <modelVersion>4.0.0</modelVersion>
   <groupId>plexus</groupId>
   <artifactId>continuum-project2</artifactId>
@@ -28,4 +28,4 @@
     <connection>scm:cvs:local:ignores:/cvs/root:project2</connection>
     <url>http://cvs.plexus.codehaus.org/plexus-components/native/continuum/src/test-projects/project2</url>
   </scm>
-</model>
\ No newline at end of file
+</project>
\ No newline at end of file

Added: continuum/trunk/continuum-core/src/test/java/org/apache/maven/continuum/execution/maven/m2/TestMavenBuilderHelper.java
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-core/src/test/java/org/apache/maven/continuum/execution/maven/m2/TestMavenBuilderHelper.java?rev=664117&view=auto
==============================================================================
--- continuum/trunk/continuum-core/src/test/java/org/apache/maven/continuum/execution/maven/m2/TestMavenBuilderHelper.java (added)
+++ continuum/trunk/continuum-core/src/test/java/org/apache/maven/continuum/execution/maven/m2/TestMavenBuilderHelper.java Fri Jun  6 13:51:29 2008
@@ -0,0 +1,73 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+package org.apache.maven.continuum.execution.maven.m2;
+
+import java.io.File;
+
+import org.apache.maven.continuum.AbstractContinuumTest;
+import org.apache.maven.continuum.project.builder.ContinuumProjectBuildingResult;
+import org.apache.maven.project.MavenProject;
+import org.codehaus.plexus.util.StringUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * @author <a href="mailto:olamy@apache.org">olamy</a>
+ * @since 6 juin 2008
+ * @version $Id$
+ */
+public class TestMavenBuilderHelper
+    extends AbstractContinuumTest
+{
+    
+    private Logger log = LoggerFactory.getLogger( getClass() );
+
+    public void testgetMavenProject()
+        throws Exception
+    {
+        MavenBuilderHelper mavenBuilderHelper = (MavenBuilderHelper) lookup( MavenBuilderHelper.ROLE, "default" );
+        ContinuumProjectBuildingResult result = new ContinuumProjectBuildingResult();
+        File file = new File( getBasedir(), "src/test-poms/pom.xml" );
+        MavenProject project = mavenBuilderHelper.getMavenProject( result, file );
+        assertNotNull( project );
+
+        assertEquals( "plexus", project.getGroupId() );
+        assertEquals( "continuum-project2", project.getArtifactId() );
+        assertNotNull( project.getScm() );
+        assertTrue( project.getDependencies().isEmpty() );
+        assertTrue( result.getErrors().isEmpty() );
+    }
+    
+    public void testgetMavenProjectMissingDeps()
+        throws Exception
+    {
+        MavenBuilderHelper mavenBuilderHelper = (MavenBuilderHelper) lookup( MavenBuilderHelper.ROLE, "default" );
+        ContinuumProjectBuildingResult result = new ContinuumProjectBuildingResult();
+        File file = new File( getBasedir(), "src/test-poms/pom-unknown-dependency.xml" );
+        mavenBuilderHelper.getMavenProject( result, file );
+        assertFalse( result.getErrors().isEmpty() );
+        String errorsAsString = result.getErrorsAsString();
+        assertFalse( StringUtils.isEmpty( errorsAsString ) );
+        log.info( "errorAsString " + errorsAsString );
+        assertTrue( errorsAsString.contains( "ghd:non-exists:pom:2.6.267676-beta-754-alpha-95" ) );
+        log.info( "errors " + result.getErrors() );
+
+    }    
+    
+}

Propchange: continuum/trunk/continuum-core/src/test/java/org/apache/maven/continuum/execution/maven/m2/TestMavenBuilderHelper.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: continuum/trunk/continuum-core/src/test/java/org/apache/maven/continuum/execution/maven/m2/TestMavenBuilderHelper.java
------------------------------------------------------------------------------
    svn:executable = *

Propchange: continuum/trunk/continuum-core/src/test/java/org/apache/maven/continuum/execution/maven/m2/TestMavenBuilderHelper.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Revision Id

Modified: continuum/trunk/continuum-core/src/test/resources/log4j.xml
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-core/src/test/resources/log4j.xml?rev=664117&r1=664116&r2=664117&view=diff
==============================================================================
--- continuum/trunk/continuum-core/src/test/resources/log4j.xml (original)
+++ continuum/trunk/continuum-core/src/test/resources/log4j.xml Fri Jun  6 13:51:29 2008
@@ -7,32 +7,32 @@
 <log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/"
   debug="false">
 
-    <appender name="CONSOLE" class="org.apache.log4j.ConsoleAppender">
-        <param name="Target" value="System.out"/>
-        <layout class="org.apache.log4j.PatternLayout">
-            <param name="ConversionPattern" value="%d{ABSOLUTE} %-5p [%c{1}.%M](%L) %m%n"/>
-        </layout>
-    </appender>
+  <appender name="CONSOLE" class="org.apache.log4j.ConsoleAppender">
+    <param name="Target" value="System.out"/>
+    <layout class="org.apache.log4j.PatternLayout">
+      <param name="ConversionPattern" value="%d{ABSOLUTE} %-5p [%c{1}.%M](%L) %m%n"/>
+    </layout>
+  </appender>
 
-    <!-- quiet spring loading :-) -->
-    <category name="org.springframework.beans.factory.xml.XmlBeanDefinitionReader">
-        <priority value="ERROR"/>
-    </category>
-    <category name="org.springframework.beans.factory.support.DefaultListableBeanFactory">
-        <priority value="ERROR"/>
-    </category>
+  <!-- quiet spring loading :-) -->
+  <category name="org.springframework">
+    <priority value="ERROR"/>
+  </category>
+  <category name="org.codehaus.plexus">
+    <priority value="ERROR"/>
+  </category>
 
-    <!-- JPOX -->
-    <category name="JPOX">
-        <priority value="WARN"/>
-    </category>
-    <category name="JPOX.RDBMS">
-        <priority value="ERROR"/>
-    </category>
+  <!-- JPOX -->
+  <category name="JPOX">
+    <priority value="WARN"/>
+  </category>
+  <category name="JPOX.RDBMS">
+    <priority value="ERROR"/>
+  </category>
 
-    <root>
-        <priority value="WARN"/>
-        <appender-ref ref="CONSOLE"/>
-    </root>
+  <root>
+    <priority value="INFO"/>
+    <appender-ref ref="CONSOLE"/>
+  </root>
 
 </log4j:configuration>
\ No newline at end of file

Modified: continuum/trunk/pom.xml
URL: http://svn.apache.org/viewvc/continuum/trunk/pom.xml?rev=664117&r1=664116&r2=664117&view=diff
==============================================================================
--- continuum/trunk/pom.xml (original)
+++ continuum/trunk/pom.xml Fri Jun  6 13:51:29 2008
@@ -175,7 +175,7 @@
   </modules>
   <repositories>
     <repository>
-      <id>codehaus.org</id>
+      <id>snapshots.codehaus.org</id>
       <name>Codehaus Snapshot Development Repository</name>
       <url>http://snapshots.repository.codehaus.org/</url>
       <releases>