mirror of https://github.com/apache/maven.git
Resolving: MNG-1055
o Adding error diagnoser for ProfileActivationException, and an IT to test the formatting. git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@295096 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
7dc3d20c70
commit
01e24b5473
|
@ -288,6 +288,10 @@ it1015: Test that expressions that self-reference within the POM result in an
|
|||
error during POM interpolation.
|
||||
-------------------------------------------------------------------------------
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
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
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
initialize
|
|
@ -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>
|
|
@ -0,0 +1,11 @@
|
|||
<profilesXml>
|
||||
<!-- activeProfiles>
|
||||
<activeProfile>test</activeProfile>
|
||||
</activeProfiles -->
|
||||
<profiles>
|
||||
<profile>
|
||||
<id>test</id>
|
||||
<junk/>
|
||||
</profile>
|
||||
</profiles>
|
||||
</profilesXml>
|
|
@ -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();
|
||||
}
|
||||
|
||||
}
|
|
@ -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
|
||||
|
|
||||
-->
|
||||
|
|
Loading…
Reference in New Issue