You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by jd...@apache.org on 2005/10/05 21:52:39 UTC

svn commit: r295096 - in /maven/components/trunk: maven-core-it/ maven-core-it/it1018/ maven-core/src/main/java/org/apache/maven/usability/ maven-core/src/main/resources/META-INF/plexus/

Author: jdcasey
Date: Wed Oct  5 12:52:30 2005
New Revision: 295096

URL: http://svn.apache.org/viewcvs?rev=295096&view=rev
Log:
Resolving: MNG-1055

o Adding error diagnoser for ProfileActivationException, and an IT to test the formatting.


Added:
    maven/components/trunk/maven-core-it/it1018/
    maven/components/trunk/maven-core-it/it1018/goals.txt   (with props)
    maven/components/trunk/maven-core-it/it1018/pom.xml   (with props)
    maven/components/trunk/maven-core-it/it1018/profiles.xml   (with props)
    maven/components/trunk/maven-core/src/main/java/org/apache/maven/usability/ProfileActivationDiagnoser.java   (with props)
Modified:
    maven/components/trunk/maven-core-it/README.txt
    maven/components/trunk/maven-core/src/main/resources/META-INF/plexus/components.xml

Modified: maven/components/trunk/maven-core-it/README.txt
URL: http://svn.apache.org/viewcvs/maven/components/trunk/maven-core-it/README.txt?rev=295096&r1=295095&r2=295096&view=diff
==============================================================================
--- maven/components/trunk/maven-core-it/README.txt (original)
+++ maven/components/trunk/maven-core-it/README.txt Wed Oct  5 12:52:30 2005
@@ -289,6 +289,10 @@
 -------------------------------------------------------------------------------
 
 -------------------------------------------------------------------------------
+it1018: Test formatting of error caused by invalid profiles.xml syntax.
+-------------------------------------------------------------------------------
+
+-------------------------------------------------------------------------------
 These are a set of builds that are more complex than single-project or reactor
 invocations. They follow a process external to maven itself, invoking
 different lifecycle phases and/or goals on multiple projects within each test

Added: maven/components/trunk/maven-core-it/it1018/goals.txt
URL: http://svn.apache.org/viewcvs/maven/components/trunk/maven-core-it/it1018/goals.txt?rev=295096&view=auto
==============================================================================
--- maven/components/trunk/maven-core-it/it1018/goals.txt (added)
+++ maven/components/trunk/maven-core-it/it1018/goals.txt Wed Oct  5 12:52:30 2005
@@ -0,0 +1 @@
+initialize

Propchange: maven/components/trunk/maven-core-it/it1018/goals.txt
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/components/trunk/maven-core-it/it1018/goals.txt
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Added: maven/components/trunk/maven-core-it/it1018/pom.xml
URL: http://svn.apache.org/viewcvs/maven/components/trunk/maven-core-it/it1018/pom.xml?rev=295096&view=auto
==============================================================================
--- maven/components/trunk/maven-core-it/it1018/pom.xml (added)
+++ maven/components/trunk/maven-core-it/it1018/pom.xml Wed Oct  5 12:52:30 2005
@@ -0,0 +1,6 @@
+<project>
+  <modelVersion>4.0.0</modelVersion>
+  <groupId>org.apache.maven.it</groupId>
+  <artifactId>maven-core-it1018</artifactId>
+  <version>1.0-SNAPSHOT</version>
+</project>

Propchange: maven/components/trunk/maven-core-it/it1018/pom.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/components/trunk/maven-core-it/it1018/pom.xml
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Added: maven/components/trunk/maven-core-it/it1018/profiles.xml
URL: http://svn.apache.org/viewcvs/maven/components/trunk/maven-core-it/it1018/profiles.xml?rev=295096&view=auto
==============================================================================
--- maven/components/trunk/maven-core-it/it1018/profiles.xml (added)
+++ maven/components/trunk/maven-core-it/it1018/profiles.xml Wed Oct  5 12:52:30 2005
@@ -0,0 +1,11 @@
+<profilesXml>
+  <!-- activeProfiles>
+    <activeProfile>test</activeProfile>
+  </activeProfiles -->
+  <profiles>
+    <profile>
+      <id>test</id>
+      <junk/>
+    </profile>
+  </profiles>
+</profilesXml>

Propchange: maven/components/trunk/maven-core-it/it1018/profiles.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/components/trunk/maven-core-it/it1018/profiles.xml
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Added: maven/components/trunk/maven-core/src/main/java/org/apache/maven/usability/ProfileActivationDiagnoser.java
URL: http://svn.apache.org/viewcvs/maven/components/trunk/maven-core/src/main/java/org/apache/maven/usability/ProfileActivationDiagnoser.java?rev=295096&view=auto
==============================================================================
--- maven/components/trunk/maven-core/src/main/java/org/apache/maven/usability/ProfileActivationDiagnoser.java (added)
+++ maven/components/trunk/maven-core/src/main/java/org/apache/maven/usability/ProfileActivationDiagnoser.java Wed Oct  5 12:52:30 2005
@@ -0,0 +1,44 @@
+package org.apache.maven.usability;
+
+import org.apache.maven.profiles.activation.ProfileActivationException;
+import org.codehaus.plexus.component.repository.exception.ComponentLookupException;
+
+public class ProfileActivationDiagnoser
+    implements ErrorDiagnoser
+{
+
+    public boolean canDiagnose( Throwable error )
+    {
+        return DiagnosisUtils.containsInCausality( error, ProfileActivationException.class );
+    }
+
+    public String diagnose( Throwable error )
+    {
+        ProfileActivationException activationException = (ProfileActivationException) DiagnosisUtils.getFromCausality( error, ProfileActivationException.class );
+        
+        StringBuffer messageBuffer = new StringBuffer();
+        
+        messageBuffer.append( "Error activating profiles." );
+        messageBuffer.append( "\n\nReason: " ).append( activationException.getMessage() );
+        
+        if ( DiagnosisUtils.containsInCausality( activationException, ComponentLookupException.class ) )
+        {
+            ComponentLookupException cle = (ComponentLookupException) DiagnosisUtils.getFromCausality( activationException, ComponentLookupException.class );
+            
+            messageBuffer.append( "\n\nThere was a problem retrieving one or more profile activators." );
+            messageBuffer.append( "\n" ).append( cle.getMessage() );
+        }
+        
+        Throwable root = DiagnosisUtils.getRootCause( error );
+        
+        if ( root != null && root != error )
+        {
+            messageBuffer.append( "\n\nRoot Cause: " ).append( root.getMessage() );
+        }
+        
+        messageBuffer.append( "\n" );
+        
+        return messageBuffer.toString();
+    }
+
+}

Propchange: maven/components/trunk/maven-core/src/main/java/org/apache/maven/usability/ProfileActivationDiagnoser.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/components/trunk/maven-core/src/main/java/org/apache/maven/usability/ProfileActivationDiagnoser.java
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Modified: maven/components/trunk/maven-core/src/main/resources/META-INF/plexus/components.xml
URL: http://svn.apache.org/viewcvs/maven/components/trunk/maven-core/src/main/resources/META-INF/plexus/components.xml?rev=295096&r1=295095&r2=295096&view=diff
==============================================================================
--- maven/components/trunk/maven-core/src/main/resources/META-INF/plexus/components.xml (original)
+++ maven/components/trunk/maven-core/src/main/resources/META-INF/plexus/components.xml Wed Oct  5 12:52:30 2005
@@ -93,6 +93,16 @@
     </component>
     <!--
     |
+    |ProfileActivationDiagnoser
+    |
+    -->
+    <component>
+      <role>org.apache.maven.usability.ErrorDiagnoser</role>
+      <role-hint>ProfileActivationDiagnoser</role-hint>
+      <implementation>org.apache.maven.usability.ProfileActivationDiagnoser</implementation>
+    </component>
+    <!--
+    |
     |PluginConfigurationDiagnoser
     |
     -->