Cleaning up error reporting some for project building, and attempting to make the error reporter instances propagate to the aspects binding them to the error sources.

git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@599503 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
John Dennis Casey 2007-11-29 16:33:57 +00:00
parent 9732014c53
commit b61bb393a8
13 changed files with 246 additions and 203 deletions

View File

@ -3,21 +3,9 @@ package org.apache.maven.errors;
public abstract aspect AbstractCoreReporterManagerAspect public abstract aspect AbstractCoreReporterManagerAspect
{ {
private CoreErrorReporter reporter;
public void setCoreErrorReporter( CoreErrorReporter reporter )
{
this.reporter = reporter;
}
protected CoreErrorReporter getReporter() protected CoreErrorReporter getReporter()
{ {
if ( reporter == null ) return CoreReporterManager.getReporter();
{
reporter = new DefaultCoreErrorReporter();
}
return reporter;
} }
} }

View File

@ -1,14 +0,0 @@
package org.apache.maven.errors;
import org.aspectj.lang.Aspects;
public aspect CoreReporterManagerAspect
{
public void setReporter( CoreErrorReporter reporter )
{
BuildFailureReporterAspect buildFailureReporterAspect = (BuildFailureReporterAspect) Aspects.aspectOf( BuildFailureReporterAspect.class );
buildFailureReporterAspect.setCoreErrorReporter( reporter );
}
}

View File

@ -0,0 +1,32 @@
package org.apache.maven.errors;
public final class CoreReporterManager
{
private static CoreErrorReporter reporter;
private CoreReporterManager()
{
}
public static CoreErrorReporter getReporter()
{
if ( reporter == null )
{
reporter = new DefaultCoreErrorReporter();
}
return reporter;
}
public static void setReporter( CoreErrorReporter instance )
{
reporter = instance;
}
public static void clearReporter()
{
reporter = null;
}
}

View File

@ -12,14 +12,6 @@ import org.codehaus.plexus.component.repository.exception.ComponentLookupExcepti
public privileged aspect CacheCleanerAspect public privileged aspect CacheCleanerAspect
{ {
private pointcut executeMethod():
execution( * MavenEmbedder.execute( .. ) );
before(): executeMethod()
{
System.out.println( "Executing with cache-cleanup enabled." );
}
private ModelLineageBuilder MavenEmbedder.modelLineageBuilder; private ModelLineageBuilder MavenEmbedder.modelLineageBuilder;
private pointcut embedderStarted( MavenEmbedder embedder ): private pointcut embedderStarted( MavenEmbedder embedder ):

View File

@ -9,43 +9,39 @@ import org.apache.maven.BuildFailureException;
import org.apache.maven.cli.CLIReportingUtils; import org.apache.maven.cli.CLIReportingUtils;
import org.apache.maven.embedder.MavenEmbedder; import org.apache.maven.embedder.MavenEmbedder;
import org.apache.maven.errors.CoreErrorReporter; import org.apache.maven.errors.CoreErrorReporter;
import org.apache.maven.errors.CoreReporterManagerAspect; import org.apache.maven.errors.CoreReporterManager;
import org.apache.maven.errors.DefaultCoreErrorReporter; import org.apache.maven.errors.DefaultCoreErrorReporter;
import org.apache.maven.execution.MavenExecutionResult; import org.apache.maven.project.error.ProjectReporterManager;
import org.apache.maven.project.aspect.ProjectReporterManagerAspect;
import org.apache.maven.project.error.DefaultProjectErrorReporter;
import org.apache.maven.project.error.ProjectErrorReporter; import org.apache.maven.project.error.ProjectErrorReporter;
import org.apache.maven.project.ProjectBuildingException; import org.apache.maven.project.ProjectBuildingException;
public privileged aspect ErrorReportingAspect public privileged aspect ErrorReportingAspect
{ {
private ProjectErrorReporter projectErrorReporter;
private CoreErrorReporter coreErrorReporter;
private pointcut embedderCalls(): private pointcut embedderCalls():
execution( public MavenExecutionResult MavenEmbedder.*( .. ) ); execution( public * MavenEmbedder.*( .. ) );
// TODO: Use MavenExecutionRequest to allow configuration of the reporters to be used. // TODO: Use MavenExecutionRequest to allow configuration of the reporters to be used.
before(): Object around():
embedderCalls() && !cflow( embedderCalls() ) embedderCalls() && !cflow( embedderCalls() )
{ {
projectErrorReporter = new DefaultProjectErrorReporter(); try
{
ProjectReporterManagerAspect prma = (ProjectReporterManagerAspect) Aspects.aspectOf( ProjectReporterManagerAspect.class ); return proceed();
prma.setReporter( projectErrorReporter ); }
finally
coreErrorReporter = new DefaultCoreErrorReporter(); {
ProjectReporterManager.clearReporter();
CoreReporterManagerAspect crma = (CoreReporterManagerAspect) Aspects.aspectOf( CoreReporterManagerAspect.class ); CoreReporterManager.clearReporter();
crma.setReporter( coreErrorReporter ); }
} }
boolean around( ProjectBuildingException e, boolean showStackTraces, StringWriter writer ): boolean around( ProjectBuildingException e, boolean showStackTraces, StringWriter writer ):
execution( private static boolean CLIReportingUtils.handleProjectBuildingException( ProjectBuildingException, boolean, StringWriter ) ) execution( private static boolean CLIReportingUtils.handleProjectBuildingException( ProjectBuildingException, boolean, StringWriter ) )
&& args( e, showStackTraces, writer ) && args( e, showStackTraces, writer )
{ {
ProjectErrorReporter projectErrorReporter = ProjectReporterManager.getReporter();
if ( projectErrorReporter == null ) if ( projectErrorReporter == null )
{ {
return proceed( e, showStackTraces, writer ); return proceed( e, showStackTraces, writer );
@ -65,7 +61,10 @@ public privileged aspect ErrorReportingAspect
writer.write( CLIReportingUtils.NEWLINE ); writer.write( CLIReportingUtils.NEWLINE );
writer.write( CLIReportingUtils.NEWLINE ); writer.write( CLIReportingUtils.NEWLINE );
Throwable cause = projectErrorReporter.getRealCause( reportingError ); Throwable cause = projectErrorReporter.getRealCause( reportingError );
cause.printStackTrace( new PrintWriter( writer ) ); if ( cause != null )
{
cause.printStackTrace( new PrintWriter( writer ) );
}
} }
writer.write( CLIReportingUtils.NEWLINE ); writer.write( CLIReportingUtils.NEWLINE );
@ -86,12 +85,16 @@ public privileged aspect ErrorReportingAspect
execution( private static boolean CLIReportingUtils.handleBuildFailureException( BuildFailureException, boolean, StringWriter ) ) execution( private static boolean CLIReportingUtils.handleBuildFailureException( BuildFailureException, boolean, StringWriter ) )
&& args( e, showStackTraces, writer ) && args( e, showStackTraces, writer )
{ {
CoreErrorReporter coreErrorReporter = CoreReporterManager.getReporter();
if ( coreErrorReporter == null ) if ( coreErrorReporter == null )
{ {
return proceed( e, showStackTraces, writer ); return proceed( e, showStackTraces, writer );
} }
else else
{ {
System.out.println( "Checking core error reporter for help." );
Throwable reportingError = coreErrorReporter.findReportedException( e ); Throwable reportingError = coreErrorReporter.findReportedException( e );
boolean result = false; boolean result = false;
@ -105,7 +108,10 @@ public privileged aspect ErrorReportingAspect
writer.write( CLIReportingUtils.NEWLINE ); writer.write( CLIReportingUtils.NEWLINE );
writer.write( CLIReportingUtils.NEWLINE ); writer.write( CLIReportingUtils.NEWLINE );
Throwable cause = coreErrorReporter.getRealCause( reportingError ); Throwable cause = coreErrorReporter.getRealCause( reportingError );
cause.printStackTrace( new PrintWriter( writer ) ); if ( cause != null )
{
cause.printStackTrace( new PrintWriter( writer ) );
}
} }
writer.write( CLIReportingUtils.NEWLINE ); writer.write( CLIReportingUtils.NEWLINE );

View File

@ -1,26 +1,17 @@
package org.apache.maven.project.aspect; package org.apache.maven.project.aspect;
import org.apache.maven.project.error.DefaultProjectErrorReporter;
import org.apache.maven.project.error.ProjectErrorReporter; import org.apache.maven.project.error.ProjectErrorReporter;
import org.apache.maven.project.error.ProjectReporterManager;
public abstract aspect AbstractProjectErrorReporterAspect public abstract aspect AbstractProjectErrorReporterAspect issingleton()
{ {
private ProjectErrorReporter reporter; protected pointcut notWithinAspect():
!within( org.apache.maven.project.aspect.*+ );
public void setProjectErrorReporter( ProjectErrorReporter reporter )
{
this.reporter = reporter;
}
protected ProjectErrorReporter getReporter() protected ProjectErrorReporter getReporter()
{ {
if ( reporter == null ) return ProjectReporterManager.getReporter();
{
reporter = new DefaultProjectErrorReporter();
}
return reporter;
} }
} }

View File

@ -27,11 +27,13 @@ public privileged aspect PBEDerivativeReporterAspect
private pointcut mavenTools_buildDeploymentArtifactRepository( DeploymentRepository repo ): private pointcut mavenTools_buildDeploymentArtifactRepository( DeploymentRepository repo ):
call( ArtifactRepository MavenTools+.buildDeploymentArtifactRepository( DeploymentRepository ) ) call( ArtifactRepository MavenTools+.buildDeploymentArtifactRepository( DeploymentRepository ) )
&& args( repo ); && args( repo )
&& notWithinAspect();
private pointcut pbldr_processProjectLogic( MavenProject project, File pomFile ): private pointcut pbldr_processProjectLogic( MavenProject project, File pomFile ):
execution( private MavenProject DefaultMavenProjectBuilder.processProjectLogic( MavenProject, File, .. ) ) execution( private MavenProject DefaultMavenProjectBuilder.processProjectLogic( MavenProject, File, .. ) )
&& args( project, pomFile, .. ); && args( project, pomFile, .. )
&& notWithinAspect();
// ========================================================================= // =========================================================================
// Call Stack: // Call Stack:
@ -55,7 +57,8 @@ public privileged aspect PBEDerivativeReporterAspect
private pointcut mavenTools_buildArtifactRepository( Repository repo ): private pointcut mavenTools_buildArtifactRepository( Repository repo ):
call( ArtifactRepository MavenTools+.buildArtifactRepository( Repository ) ) call( ArtifactRepository MavenTools+.buildArtifactRepository( Repository ) )
&& args( repo ); && args( repo )
&& notWithinAspect();
private boolean processingPluginRepositories = false; private boolean processingPluginRepositories = false;
@ -120,9 +123,10 @@ public privileged aspect PBEDerivativeReporterAspect
// InvalidProjectVersionException // InvalidProjectVersionException
private pointcut pbldr_createNonDependencyArtifacts(): private pointcut pbldr_createNonDependencyArtifacts():
call( protected * DefaultMavenProjectBuilder.createPluginArtifacts( .. ) ) ( call( protected * DefaultMavenProjectBuilder.createPluginArtifacts( .. ) )
|| call( protected * DefaultMavenProjectBuilder.createReportArtifacts( .. ) ) || call( protected * DefaultMavenProjectBuilder.createReportArtifacts( .. ) )
|| call( protected * DefaultMavenProjectBuilder.createExtensionArtifacts( .. ) ); || call( protected * DefaultMavenProjectBuilder.createExtensionArtifacts( .. ) ) )
&& notWithinAspect();
// ========================================================================= // =========================================================================
// Call Stack: // Call Stack:
@ -173,7 +177,8 @@ public privileged aspect PBEDerivativeReporterAspect
// InvalidDependencyVersionException // InvalidDependencyVersionException
private pointcut pbldr_buildInternal(): private pointcut pbldr_buildInternal():
execution( * DefaultMavenProjectBuilder.buildInternal( .. ) ); execution( * DefaultMavenProjectBuilder.buildInternal( .. ) )
&& notWithinAspect();
private MavenProject projectBeingBuilt; private MavenProject projectBeingBuilt;
@ -216,7 +221,8 @@ public privileged aspect PBEDerivativeReporterAspect
protected pointcut mms_createArtifacts( MavenProject project ): protected pointcut mms_createArtifacts( MavenProject project ):
call( public static Set MavenMetadataSource.createArtifacts( .., MavenProject ) ) call( public static Set MavenMetadataSource.createArtifacts( .., MavenProject ) )
&& args( .., project ); && args( .., project )
&& notWithinAspect();
// ========================================================================= // =========================================================================
// Call Stack: // Call Stack:

View File

@ -34,22 +34,26 @@ public privileged aspect ProfileErrorReporterAspect
protected pointcut componentLookupException( ComponentLookupException cause ): protected pointcut componentLookupException( ComponentLookupException cause ):
handler( ComponentLookupException ) handler( ComponentLookupException )
&& args( cause ); && args( cause )
&& notWithinAspect();
private pointcut pMgr_isActiveExec( Profile profile, ProfileActivationContext context ): private pointcut pMgr_isActiveExec( Profile profile, ProfileActivationContext context ):
execution( boolean DefaultProfileManager.isActive( Profile, ProfileActivationContext ) ) execution( boolean DefaultProfileManager.isActive( Profile, ProfileActivationContext ) )
&& args( profile, context ); && args( profile, context )
&& notWithinAspect();
private pointcut pAdv_applyActivatedProfiles( Model model, File pomFile ): private pointcut pAdv_applyActivatedProfiles( Model model, File pomFile ):
execution( private List DefaultProfileAdvisor.applyActivatedProfiles( Model, File, .. ) ) execution( private List DefaultProfileAdvisor.applyActivatedProfiles( Model, File, .. ) )
&& args( model, pomFile, .. ); && args( model, pomFile, .. )
&& notWithinAspect();
private pointcut applyActivatedProfiles_ComponentLookupException( Model model, private pointcut applyActivatedProfiles_ComponentLookupException( Model model,
File pomFile, File pomFile,
Profile profile ): Profile profile ):
call( List PlexusContainer+.lookupList( .. ) ) call( List PlexusContainer+.lookupList( .. ) )
&& cflow( pAdv_applyActivatedProfiles( model, pomFile ) ) && cflow( pAdv_applyActivatedProfiles( model, pomFile ) )
&& cflow( pMgr_isActiveExec( profile, ProfileActivationContext ) ); && cflow( pMgr_isActiveExec( profile, ProfileActivationContext ) )
&& notWithinAspect();
// ========================================================================= // =========================================================================
// Call Stack: // Call Stack:
@ -73,7 +77,8 @@ public privileged aspect ProfileErrorReporterAspect
protected pointcut profileActivatorCall( ProfileActivator activator ): protected pointcut profileActivatorCall( ProfileActivator activator ):
call( * ProfileActivator+.*( .. ) ) call( * ProfileActivator+.*( .. ) )
&& target( activator ); && target( activator )
&& notWithinAspect();
private pointcut applyActivatedProfiles_ActivatorThrown( ProfileActivator activator, private pointcut applyActivatedProfiles_ActivatorThrown( ProfileActivator activator,
Model model, Model model,
@ -82,7 +87,8 @@ public privileged aspect ProfileErrorReporterAspect
ProfileActivationContext context ): ProfileActivationContext context ):
profileActivatorCall( activator ) profileActivatorCall( activator )
&& cflow( pAdv_applyActivatedProfiles( model, pomFile ) ) && cflow( pAdv_applyActivatedProfiles( model, pomFile ) )
&& cflow( pMgr_isActiveExec( profile, context ) ); && cflow( pMgr_isActiveExec( profile, context ) )
&& notWithinAspect();
// ========================================================================= // =========================================================================
// Call Stack: // Call Stack:
@ -106,14 +112,16 @@ public privileged aspect ProfileErrorReporterAspect
private pointcut pAdv_loadExternalProjectProfiles( Model model, File pomFile ): private pointcut pAdv_loadExternalProjectProfiles( Model model, File pomFile ):
execution( private void DefaultProfileAdvisor.loadExternalProjectProfiles( *, Model, File ) ) execution( private void DefaultProfileAdvisor.loadExternalProjectProfiles( *, Model, File ) )
&& args( *, model, pomFile ); && args( *, model, pomFile )
&& notWithinAspect();
private pointcut loadExternalProfiles_profileBuilding( Model model, private pointcut loadExternalProfiles_profileBuilding( Model model,
File pomFile, File pomFile,
File projectDir ): File projectDir ):
call( ProfilesRoot MavenProfilesBuilder+.buildProfiles( File ) ) call( ProfilesRoot MavenProfilesBuilder+.buildProfiles( File ) )
&& cflow( pAdv_loadExternalProjectProfiles( model, pomFile ) ) && cflow( pAdv_loadExternalProjectProfiles( model, pomFile ) )
&& args( projectDir ); && args( projectDir )
&& notWithinAspect();
// ========================================================================= // =========================================================================
// Call Stack: // Call Stack:
@ -153,14 +161,16 @@ public privileged aspect ProfileErrorReporterAspect
private pointcut pAdv_getArtifactRepositoriesFromActiveProfiles( String projectId, File pomFile ): private pointcut pAdv_getArtifactRepositoriesFromActiveProfiles( String projectId, File pomFile ):
execution( LinkedHashSet DefaultProfileAdvisor.getArtifactRepositoriesFromActiveProfiles( *, File, String ) ) execution( LinkedHashSet DefaultProfileAdvisor.getArtifactRepositoriesFromActiveProfiles( *, File, String ) )
&& args( *, pomFile, projectId ); && args( *, pomFile, projectId )
&& notWithinAspect();
private pointcut getArtifactRepositoriesFromActiveProfiles_ComponentLookupException( String projectId, private pointcut getArtifactRepositoriesFromActiveProfiles_ComponentLookupException( String projectId,
File pomFile, File pomFile,
Profile profile ): Profile profile ):
call( List PlexusContainer+.lookupList( .. ) ) call( List PlexusContainer+.lookupList( .. ) )
&& cflow( pAdv_getArtifactRepositoriesFromActiveProfiles( projectId, pomFile ) ) && cflow( pAdv_getArtifactRepositoriesFromActiveProfiles( projectId, pomFile ) )
&& cflow( pMgr_isActiveExec( profile, ProfileActivationContext ) ); && cflow( pMgr_isActiveExec( profile, ProfileActivationContext ) )
&& notWithinAspect();
// ========================================================================= // =========================================================================
// Call Stack: // Call Stack:
@ -189,7 +199,8 @@ public privileged aspect ProfileErrorReporterAspect
ProfileActivationContext context ): ProfileActivationContext context ):
profileActivatorCall( activator ) profileActivatorCall( activator )
&& cflow( pAdv_getArtifactRepositoriesFromActiveProfiles( projectId, pomFile ) ) && cflow( pAdv_getArtifactRepositoriesFromActiveProfiles( projectId, pomFile ) )
&& cflow( pMgr_isActiveExec( profile, context ) ); && cflow( pMgr_isActiveExec( profile, context ) )
&& notWithinAspect();
// ========================================================================= // =========================================================================
// Call Stack: // Call Stack:
@ -216,7 +227,8 @@ public privileged aspect ProfileErrorReporterAspect
File pomFile ): File pomFile ):
call( ArtifactRepository MavenTools+.buildArtifactRepository( Repository ) ) call( ArtifactRepository MavenTools+.buildArtifactRepository( Repository ) )
&& args( repo ) && args( repo )
&& cflow( pAdv_getArtifactRepositoriesFromActiveProfiles( projectId, pomFile ) ); && cflow( pAdv_getArtifactRepositoriesFromActiveProfiles( projectId, pomFile ) )
&& notWithinAspect();
// ========================================================================= // =========================================================================
// Call Stack: // Call Stack:

View File

@ -16,15 +16,18 @@ public privileged aspect ProjectArtifactErrorReporterAspect
private pointcut mlbldr_resolveParentFromRepositories( Parent parentRef, ArtifactRepository localRepo, private pointcut mlbldr_resolveParentFromRepositories( Parent parentRef, ArtifactRepository localRepo,
List remoteRepos, String childId, File childPomFile ): List remoteRepos, String childId, File childPomFile ):
execution( File DefaultModelLineageBuilder.resolveParentFromRepository( Parent, ArtifactRepository, List, String, File ) ) execution( File DefaultModelLineageBuilder.resolveParentFromRepository( Parent, ArtifactRepository, List, String, File ) )
&& args( parentRef, localRepo, remoteRepos, childId, childPomFile ); && args( parentRef, localRepo, remoteRepos, childId, childPomFile )
&& notWithinAspect();
private pointcut anfe_handler( ArtifactNotFoundException cause ): private pointcut anfe_handler( ArtifactNotFoundException cause ):
handler( ArtifactNotFoundException ) handler( ArtifactNotFoundException )
&& args( cause ); && args( cause )
&& notWithinAspect();
private pointcut are_handler( ArtifactResolutionException cause ): private pointcut are_handler( ArtifactResolutionException cause ):
handler( ArtifactResolutionException ) handler( ArtifactResolutionException )
&& args( cause ); && args( cause )
&& notWithinAspect();
// ========================================================================= // =========================================================================
// Call Stack: // Call Stack:

View File

@ -1,5 +1,7 @@
package org.apache.maven.project.aspect; package org.apache.maven.project.aspect;
import org.apache.maven.project.ProjectBuildingException;
import org.apache.maven.model.Model;
import org.apache.maven.project.DefaultMavenProjectBuilder; import org.apache.maven.project.DefaultMavenProjectBuilder;
import org.apache.maven.project.build.model.ModelAndFile; import org.apache.maven.project.build.model.ModelAndFile;
import org.apache.maven.project.build.model.DefaultModelLineageBuilder; import org.apache.maven.project.build.model.DefaultModelLineageBuilder;
@ -12,17 +14,15 @@ public privileged aspect ProjectIOErrorReporterAspect
extends AbstractProjectErrorReporterAspect extends AbstractProjectErrorReporterAspect
{ {
private pointcut pbldr_readProject( String projectId, File pomFile ): private pointcut pbldr_readModel( String projectId, File pomFile ):
execution( * DefaultMavenProjectBuilder.readModel( String, File, .. ) ) execution( Model DefaultMavenProjectBuilder.readModel( String, File, boolean ) )
&& args( projectId, pomFile, .. ); && args( projectId, pomFile, * );
private pointcut xppEx_handler( XmlPullParserException cause ): private pointcut within_pbldr_readModel( String projectId, File pomFile ):
handler( XmlPullParserException ) within( DefaultMavenProjectBuilder )
&& args( cause ); && cflow( pbldr_readModel( projectId, pomFile ) )
&& !cflowbelow( pbldr_readModel( String, File ) )
private pointcut ioEx_handler( IOException cause ): && notWithinAspect();
handler( IOException )
&& args( cause );
// ========================================================================= // =========================================================================
// Call Stack: // Call Stack:
@ -37,8 +37,9 @@ public privileged aspect ProjectIOErrorReporterAspect
// <------ InvalidProjectModelException // <------ InvalidProjectModelException
// ========================================================================= // =========================================================================
before( String projectId, File pomFile, XmlPullParserException cause ): before( String projectId, File pomFile, XmlPullParserException cause ):
cflow( pbldr_readProject( projectId, pomFile ) ) within_pbldr_readModel( projectId, pomFile )
&& xppEx_handler( cause ) && call( ProjectBuildingException.new( .., XmlPullParserException ))
&& args( .., cause )
{ {
getReporter().reportErrorParsingProjectModel( projectId, pomFile, cause ); getReporter().reportErrorParsingProjectModel( projectId, pomFile, cause );
} }
@ -56,8 +57,9 @@ public privileged aspect ProjectIOErrorReporterAspect
// <------ InvalidProjectModelException // <------ InvalidProjectModelException
// ========================================================================= // =========================================================================
before( String projectId, File pomFile, IOException cause ): before( String projectId, File pomFile, IOException cause ):
cflow( pbldr_readProject( projectId, pomFile ) ) within_pbldr_readModel( projectId, pomFile )
&& ioEx_handler( cause ) && call( ProjectBuildingException.new( .., IOException ))
&& args( .., cause )
{ {
getReporter().reportErrorParsingProjectModel( projectId, pomFile, cause ); getReporter().reportErrorParsingProjectModel( projectId, pomFile, cause );
} }
@ -70,6 +72,17 @@ public privileged aspect ProjectIOErrorReporterAspect
execution( * DefaultModelLineageBuilder.readModel( File ) ) execution( * DefaultModelLineageBuilder.readModel( File ) )
&& args( pomFile ); && args( pomFile );
private pointcut within_mlbldr_readModel( File pomFile ):
cflow( mlbldr_readModel( pomFile ) )
&& within( DefaultModelLineageBuilder )
&& notWithinAspect();
private pointcut mlbldr_errorParsingParentPom( ModelAndFile childInfo, File parentPomFile, XmlPullParserException cause ):
cflowbelow( mlbldr_resolveParentPom( childInfo ) )
&& within_mlbldr_readModel( parentPomFile )
&& call( ProjectBuildingException.new( .., XmlPullParserException ) )
&& args( .., cause );
// ========================================================================= // =========================================================================
// Call Stack: // Call Stack:
// ========================================================================= // =========================================================================
@ -83,13 +96,17 @@ public privileged aspect ProjectIOErrorReporterAspect
// <---------- ProjectBuildingException // <---------- ProjectBuildingException
// ========================================================================= // =========================================================================
before( ModelAndFile childInfo, File parentPomFile, XmlPullParserException cause ): before( ModelAndFile childInfo, File parentPomFile, XmlPullParserException cause ):
cflow( mlbldr_resolveParentPom( childInfo ) ) mlbldr_errorParsingParentPom( childInfo, parentPomFile, cause )
&& cflow( mlbldr_readModel( parentPomFile ) )
&& xppEx_handler( cause )
{ {
getReporter().reportErrorParsingParentProjectModel( childInfo, parentPomFile, cause ); getReporter().reportErrorParsingParentProjectModel( childInfo, parentPomFile, cause );
} }
private pointcut mlbldr_errorReadingParentPom( ModelAndFile childInfo, File parentPomFile, IOException cause ):
cflow( mlbldr_resolveParentPom( childInfo ) )
&& within_mlbldr_readModel( parentPomFile )
&& call( ProjectBuildingException.new( .., IOException ))
&& args( .., cause );
// ========================================================================= // =========================================================================
// Call Stack: // Call Stack:
// ========================================================================= // =========================================================================
@ -103,15 +120,17 @@ public privileged aspect ProjectIOErrorReporterAspect
// <---------- ProjectBuildingException // <---------- ProjectBuildingException
// ========================================================================= // =========================================================================
before( ModelAndFile childInfo, File parentPomFile, IOException cause ): before( ModelAndFile childInfo, File parentPomFile, IOException cause ):
cflow( mlbldr_resolveParentPom( childInfo ) ) mlbldr_errorReadingParentPom( childInfo, parentPomFile, cause )
&& cflow( mlbldr_readModel( parentPomFile ) )
&& ioEx_handler( cause )
{ {
getReporter().reportErrorParsingParentProjectModel( childInfo, parentPomFile, cause ); getReporter().reportErrorParsingParentProjectModel( childInfo, parentPomFile, cause );
} }
private pointcut mlbldr_buildModelLineage(): private pointcut mlbldr_errorParsingNonParentPom( File pomFile, XmlPullParserException cause ):
execution( * DefaultModelLineageBuilder.buildModelLineage( .. ) ); !cflow( mlbldr_resolveParentPom( ModelAndFile ) )
&& cflow( mlbldr_readModel( pomFile ) )
&& call( ProjectBuildingException.new( .., XmlPullParserException ))
&& args( .., cause )
&& notWithinAspect();
// ========================================================================= // =========================================================================
// Call Stack: // Call Stack:
@ -123,14 +142,18 @@ public privileged aspect ProjectIOErrorReporterAspect
// <------ ProjectBuildingException // <------ ProjectBuildingException
// ========================================================================= // =========================================================================
before( File pomFile, XmlPullParserException cause ): before( File pomFile, XmlPullParserException cause ):
cflow( mlbldr_buildModelLineage() ) mlbldr_errorParsingNonParentPom( pomFile, cause )
&& !cflowbelow( mlbldr_buildModelLineage() )
&& cflow( mlbldr_readModel( pomFile ) )
&& xppEx_handler( cause )
{ {
getReporter().reportErrorParsingProjectModel( "unknown", pomFile, cause ); getReporter().reportErrorParsingProjectModel( "unknown", pomFile, cause );
} }
private pointcut mlbldr_errorReadingNonParentPom( File pomFile, IOException cause ):
!cflow( mlbldr_resolveParentPom( ModelAndFile ) )
&& cflow( mlbldr_readModel( pomFile ) )
&& call( ProjectBuildingException.new( .., IOException ))
&& args( .., cause )
&& notWithinAspect();
// ========================================================================= // =========================================================================
// Call Stack: // Call Stack:
// ========================================================================= // =========================================================================
@ -141,10 +164,7 @@ public privileged aspect ProjectIOErrorReporterAspect
// <------ ProjectBuildingException // <------ ProjectBuildingException
// ========================================================================= // =========================================================================
before( File pomFile, IOException cause ): before( File pomFile, IOException cause ):
cflow( mlbldr_buildModelLineage() ) mlbldr_errorReadingNonParentPom( pomFile, cause )
&& !cflowbelow( mlbldr_buildModelLineage() )
&& cflow( mlbldr_readModel( pomFile ) )
&& ioEx_handler( cause )
{ {
getReporter().reportErrorParsingProjectModel( "unknown", pomFile, cause ); getReporter().reportErrorParsingProjectModel( "unknown", pomFile, cause );
} }

View File

@ -1,25 +0,0 @@
package org.apache.maven.project.aspect;
import org.aspectj.lang.Aspects;
import org.apache.maven.project.error.ProjectErrorReporter;
public aspect ProjectReporterManagerAspect
{
public void setReporter( ProjectErrorReporter reporter )
{
PBEDerivativeReporterAspect pbeDerivativeReporterAspect = (PBEDerivativeReporterAspect) Aspects.aspectOf( PBEDerivativeReporterAspect.class );
pbeDerivativeReporterAspect.setProjectErrorReporter( reporter );
ProfileErrorReporterAspect profileErrorReporterAspect = (ProfileErrorReporterAspect) Aspects.aspectOf( ProfileErrorReporterAspect.class );
profileErrorReporterAspect.setProjectErrorReporter( reporter );
ProjectIOErrorReporterAspect projectIOErrorReporterAspect = (ProjectIOErrorReporterAspect) Aspects.aspectOf( ProjectIOErrorReporterAspect.class );
projectIOErrorReporterAspect.setProjectErrorReporter( reporter );
ProjectArtifactErrorReporterAspect projectArtifactErrorReporterAspect = (ProjectArtifactErrorReporterAspect) Aspects.aspectOf( ProjectArtifactErrorReporterAspect.class );
projectArtifactErrorReporterAspect.setProjectErrorReporter( reporter );
}
}

View File

@ -76,7 +76,7 @@ public final class ModelUtils
public static void mergePluginLists( PluginContainer childContainer, PluginContainer parentContainer, public static void mergePluginLists( PluginContainer childContainer, PluginContainer parentContainer,
boolean handleAsInheritance ) boolean handleAsInheritance )
{ {
if ( childContainer == null || parentContainer == null ) if ( ( childContainer == null ) || ( parentContainer == null ) )
{ {
// nothing to do. // nothing to do.
return; return;
@ -84,7 +84,7 @@ public final class ModelUtils
List parentPlugins = parentContainer.getPlugins(); List parentPlugins = parentContainer.getPlugins();
if ( parentPlugins != null && !parentPlugins.isEmpty() ) if ( ( parentPlugins != null ) && !parentPlugins.isEmpty() )
{ {
parentPlugins = new ArrayList( parentPlugins ); parentPlugins = new ArrayList( parentPlugins );
@ -98,7 +98,7 @@ public final class ModelUtils
String inherited = plugin.getInherited(); String inherited = plugin.getInherited();
if ( inherited != null && !Boolean.valueOf( inherited ).booleanValue() ) if ( ( inherited != null ) && !Boolean.valueOf( inherited ).booleanValue() )
{ {
it.remove(); it.remove();
} }
@ -120,12 +120,12 @@ public final class ModelUtils
// 1. we're not processing the plugins in an inheritance-based merge // 1. we're not processing the plugins in an inheritance-based merge
// 2. the parent's <inherited/> flag is not set // 2. the parent's <inherited/> flag is not set
// 3. the parent's <inherited/> flag is set to true // 3. the parent's <inherited/> flag is set to true
if ( !handleAsInheritance || parentInherited == null || if ( !handleAsInheritance || ( parentInherited == null ) ||
Boolean.valueOf( parentInherited ).booleanValue() ) Boolean.valueOf( parentInherited ).booleanValue() )
{ {
Plugin childPlugin = (Plugin) childPlugins.get( parentPlugin.getKey() ); Plugin childPlugin = (Plugin) childPlugins.get( parentPlugin.getKey() );
if ( childPlugin != null && !assembledPlugins.contains( childPlugin ) ) if ( ( childPlugin != null ) && !assembledPlugins.contains( childPlugin ) )
{ {
Plugin assembledPlugin = childPlugin; Plugin assembledPlugin = childPlugin;
@ -138,7 +138,7 @@ public final class ModelUtils
// if we're processing this as an inheritance-based merge, and // if we're processing this as an inheritance-based merge, and
// the parent's <inherited/> flag is not set, then we need to // the parent's <inherited/> flag is not set, then we need to
// clear the inherited flag in the merge result. // clear the inherited flag in the merge result.
if ( handleAsInheritance && parentInherited == null ) if ( handleAsInheritance && ( parentInherited == null ) )
{ {
parentPlugin.unsetInheritanceApplied(); parentPlugin.unsetInheritanceApplied();
} }
@ -216,7 +216,7 @@ public final class ModelUtils
public static void mergeReportPluginLists( Reporting child, Reporting parent, boolean handleAsInheritance ) public static void mergeReportPluginLists( Reporting child, Reporting parent, boolean handleAsInheritance )
{ {
if ( child == null || parent == null ) if ( ( child == null ) || ( parent == null ) )
{ {
// nothing to do. // nothing to do.
return; return;
@ -224,7 +224,7 @@ public final class ModelUtils
List parentPlugins = parent.getPlugins(); List parentPlugins = parent.getPlugins();
if ( parentPlugins != null && !parentPlugins.isEmpty() ) if ( ( parentPlugins != null ) && !parentPlugins.isEmpty() )
{ {
Map assembledPlugins = new TreeMap(); Map assembledPlugins = new TreeMap();
@ -236,7 +236,7 @@ public final class ModelUtils
String parentInherited = parentPlugin.getInherited(); String parentInherited = parentPlugin.getInherited();
if ( !handleAsInheritance || parentInherited == null || if ( !handleAsInheritance || ( parentInherited == null ) ||
Boolean.valueOf( parentInherited ).booleanValue() ) Boolean.valueOf( parentInherited ).booleanValue() )
{ {
@ -251,7 +251,7 @@ public final class ModelUtils
mergeReportPluginDefinitions( childPlugin, parentPlugin, handleAsInheritance ); mergeReportPluginDefinitions( childPlugin, parentPlugin, handleAsInheritance );
} }
if ( handleAsInheritance && parentInherited == null ) if ( handleAsInheritance && ( parentInherited == null ) )
{ {
assembledPlugin.unsetInheritanceApplied(); assembledPlugin.unsetInheritanceApplied();
} }
@ -278,7 +278,7 @@ public final class ModelUtils
public static void mergePluginDefinitions( Plugin child, Plugin parent, boolean handleAsInheritance ) public static void mergePluginDefinitions( Plugin child, Plugin parent, boolean handleAsInheritance )
{ {
if ( child == null || parent == null ) if ( ( child == null ) || ( parent == null ) )
{ {
// nothing to do. // nothing to do.
return; return;
@ -289,7 +289,7 @@ public final class ModelUtils
child.setExtensions( true ); child.setExtensions( true );
} }
if ( child.getVersion() == null && parent.getVersion() != null ) if ( ( child.getVersion() == null ) && ( parent.getVersion() != null ) )
{ {
child.setVersion( parent.getVersion() ); child.setVersion( parent.getVersion() );
} }
@ -306,11 +306,11 @@ public final class ModelUtils
// from here to the end of the method is dealing with merging of the <executions/> section. // from here to the end of the method is dealing with merging of the <executions/> section.
String parentInherited = parent.getInherited(); String parentInherited = parent.getInherited();
boolean parentIsInherited = parentInherited == null || Boolean.valueOf( parentInherited ).booleanValue(); boolean parentIsInherited = ( parentInherited == null ) || Boolean.valueOf( parentInherited ).booleanValue();
List parentExecutions = parent.getExecutions(); List parentExecutions = parent.getExecutions();
if ( parentExecutions != null && !parentExecutions.isEmpty() ) if ( ( parentExecutions != null ) && !parentExecutions.isEmpty() )
{ {
List mergedExecutions = new ArrayList(); List mergedExecutions = new ArrayList();
@ -334,7 +334,7 @@ public final class ModelUtils
assembled = childExecution; assembled = childExecution;
} }
else if ( handleAsInheritance && parentInherited == null ) else if ( handleAsInheritance && ( parentInherited == null ) )
{ {
parentExecution.unsetInheritanceApplied(); parentExecution.unsetInheritanceApplied();
} }
@ -364,13 +364,13 @@ public final class ModelUtils
public static void mergeReportPluginDefinitions( ReportPlugin child, ReportPlugin parent, public static void mergeReportPluginDefinitions( ReportPlugin child, ReportPlugin parent,
boolean handleAsInheritance ) boolean handleAsInheritance )
{ {
if ( child == null || parent == null ) if ( ( child == null ) || ( parent == null ) )
{ {
// nothing to do. // nothing to do.
return; return;
} }
if ( child.getVersion() == null && parent.getVersion() != null ) if ( ( child.getVersion() == null ) && ( parent.getVersion() != null ) )
{ {
child.setVersion( parent.getVersion() ); child.setVersion( parent.getVersion() );
} }
@ -378,11 +378,11 @@ public final class ModelUtils
// from here to the end of the method is dealing with merging of the <executions/> section. // from here to the end of the method is dealing with merging of the <executions/> section.
String parentInherited = parent.getInherited(); String parentInherited = parent.getInherited();
boolean parentIsInherited = parentInherited == null || Boolean.valueOf( parentInherited ).booleanValue(); boolean parentIsInherited = ( parentInherited == null ) || Boolean.valueOf( parentInherited ).booleanValue();
List parentReportSets = parent.getReportSets(); List parentReportSets = parent.getReportSets();
if ( parentReportSets != null && !parentReportSets.isEmpty() ) if ( ( parentReportSets != null ) && !parentReportSets.isEmpty() )
{ {
Map assembledReportSets = new TreeMap(); Map assembledReportSets = new TreeMap();
@ -404,7 +404,7 @@ public final class ModelUtils
assembledReportSet = childReportSet; assembledReportSet = childReportSet;
} }
else if ( handleAsInheritance && parentInherited == null ) else if ( handleAsInheritance && ( parentInherited == null ) )
{ {
parentReportSet.unsetInheritanceApplied(); parentReportSet.unsetInheritanceApplied();
} }
@ -444,7 +444,7 @@ public final class ModelUtils
List goals = new ArrayList(); List goals = new ArrayList();
if ( childGoals != null && !childGoals.isEmpty() ) if ( ( childGoals != null ) && !childGoals.isEmpty() )
{ {
goals.addAll( childGoals ); goals.addAll( childGoals );
} }
@ -479,7 +479,7 @@ public final class ModelUtils
List reports = new ArrayList(); List reports = new ArrayList();
if ( childReports != null && !childReports.isEmpty() ) if ( ( childReports != null ) && !childReports.isEmpty() )
{ {
reports.addAll( childReports ); reports.addAll( childReports );
} }
@ -568,7 +568,7 @@ public final class ModelUtils
List modules = profile.getModules(); List modules = profile.getModules();
if ( modules != null && !modules.isEmpty() ) if ( ( modules != null ) && !modules.isEmpty() )
{ {
newProfile.setModules( new ArrayList( modules ) ); newProfile.setModules( new ArrayList( modules ) );
} }
@ -962,7 +962,7 @@ public final class ModelUtils
List goals = exec.getGoals(); List goals = exec.getGoals();
if ( goals != null && !goals.isEmpty() ) if ( ( goals != null ) && !goals.isEmpty() )
{ {
newExec.setGoals( new ArrayList( goals ) ); newExec.setGoals( new ArrayList( goals ) );
} }

View File

@ -0,0 +1,32 @@
package org.apache.maven.project.error;
public final class ProjectReporterManager
{
private static ProjectErrorReporter reporter;
private ProjectReporterManager()
{
}
public static ProjectErrorReporter getReporter()
{
if ( reporter == null )
{
reporter = new DefaultProjectErrorReporter();
}
return reporter;
}
public static void setReporter( ProjectErrorReporter instance )
{
reporter = instance;
}
public static void clearReporter()
{
reporter = null;
}
}