mirror of https://github.com/apache/maven.git
fixing error reporting for when pom file is missing, and adding deprecated-mojo and deprecated-mojo-param warnings.
git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@604538 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
5159c0b4b6
commit
10a192dfc2
|
@ -0,0 +1,17 @@
|
||||||
|
package org.apache.maven;
|
||||||
|
|
||||||
|
import org.apache.maven.execution.MavenExecutionRequest;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public aspect CoreDebuggingAspect
|
||||||
|
{
|
||||||
|
|
||||||
|
// after( MavenExecutionRequest request ) returning( List projects ):
|
||||||
|
// call( List DefaultMaven.getProjects( MavenExecutionRequest ) )
|
||||||
|
// && args( request )
|
||||||
|
// {
|
||||||
|
// System.out.println( "Got projects-list of size " + ( projects == null ? "null" : "" + projects.size() ) + ":\n\n" + projects );
|
||||||
|
// }
|
||||||
|
|
||||||
|
}
|
|
@ -13,16 +13,7 @@ public privileged aspect CoreReporterDebugAspect
|
||||||
// && target( reporter )
|
// && target( reporter )
|
||||||
// {
|
// {
|
||||||
// SourceLocation location = thisJoinPoint.getSourceLocation();
|
// SourceLocation location = thisJoinPoint.getSourceLocation();
|
||||||
// System.out.println( "Registering: " + key.getClass().getName() + "@" + key.hashCode() + "\nfrom: " + location.getFileName() + ", line: " + location.getLine() + "\nreporter instance hashcode is: " + reporter.hashCode() );
|
// System.out.println( "Registering: " + key + "\nfrom: " + location.getFileName() + ", line: " + location.getLine() + "\nreporter is: " + reporter );
|
||||||
// }
|
|
||||||
//
|
|
||||||
// after() returning( Throwable key ):
|
|
||||||
// execution( Throwable CoreErrorReporter+.findReportedException( Throwable ) )
|
|
||||||
// {
|
|
||||||
// if ( key != null )
|
|
||||||
// {
|
|
||||||
// System.out.println( "Found reported exception: " + key.getClass().getName() + "@" + key.hashCode() );
|
|
||||||
// }
|
|
||||||
// }
|
// }
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -42,6 +42,10 @@ public privileged aspect LifecycleErrorReporterAspect
|
||||||
execution( void PluginManager+.executeMojo( MavenProject, .. ) )
|
execution( void PluginManager+.executeMojo( MavenProject, .. ) )
|
||||||
&& args( project, .. );
|
&& args( project, .. );
|
||||||
|
|
||||||
|
private pointcut within_pm_executeMojo( MavenProject project ):
|
||||||
|
withincode( void PluginManager+.executeMojo( MavenProject, .. ) )
|
||||||
|
&& args( project, .. );
|
||||||
|
|
||||||
before( MojoBinding binding, MavenProject project, LifecycleExecutionException err ):
|
before( MojoBinding binding, MavenProject project, LifecycleExecutionException err ):
|
||||||
cflow( le_executeGoalAndHandleFailures( binding ) )
|
cflow( le_executeGoalAndHandleFailures( binding ) )
|
||||||
&& execution( LifecycleExecutionException.new( String, MavenProject ) )
|
&& execution( LifecycleExecutionException.new( String, MavenProject ) )
|
||||||
|
@ -68,14 +72,15 @@ public privileged aspect LifecycleErrorReporterAspect
|
||||||
getReporter().reportMojoExecutionException( binding, project, cause );
|
getReporter().reportMojoExecutionException( binding, project, cause );
|
||||||
}
|
}
|
||||||
|
|
||||||
before( MojoBinding binding, MavenProject project, PluginExecutionException cause ):
|
PluginExecutionException around( MojoBinding binding, MavenProject project ):
|
||||||
cflow( le_executeGoalAndHandleFailures( binding ) )
|
cflow( le_executeGoalAndHandleFailures( binding ) )
|
||||||
&& cflow( pm_executeMojo( project ) )
|
&& cflow( pm_executeMojo( project ) )
|
||||||
&& !handler( MojoExecutionException )
|
&& call( PluginExecutionException.new( .., String ) )
|
||||||
&& execution( PluginExecutionException.new( .., String ) )
|
|
||||||
&& this( cause )
|
|
||||||
{
|
{
|
||||||
|
PluginExecutionException cause = proceed( binding, project );
|
||||||
getReporter().reportInvalidPluginExecutionEnvironment( binding, project, cause );
|
getReporter().reportInvalidPluginExecutionEnvironment( binding, project, cause );
|
||||||
|
|
||||||
|
return cause;
|
||||||
}
|
}
|
||||||
|
|
||||||
before( MojoBinding binding, MavenProject project, ComponentLookupException cause ):
|
before( MojoBinding binding, MavenProject project, ComponentLookupException cause ):
|
||||||
|
|
|
@ -281,18 +281,7 @@ public class DefaultMaven
|
||||||
{
|
{
|
||||||
List projects = new ArrayList( files.size() );
|
List projects = new ArrayList( files.size() );
|
||||||
|
|
||||||
if ( files.isEmpty() )
|
if ( !files.isEmpty() )
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
projects.add( projectBuilder.buildStandaloneSuperProject( globalProfileManager ) );
|
|
||||||
}
|
|
||||||
catch ( ProjectBuildingException e )
|
|
||||||
{
|
|
||||||
throw new MavenExecutionException( "Failed to build super-project instance.", e );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
for ( Iterator iterator = files.iterator(); iterator.hasNext(); )
|
for ( Iterator iterator = files.iterator(); iterator.hasNext(); )
|
||||||
{
|
{
|
||||||
|
|
|
@ -358,10 +358,14 @@ public class DefaultCoreErrorReporter
|
||||||
writer.write( NEWLINE );
|
writer.write( NEWLINE );
|
||||||
writer.write( "The following plugin cannot function in the current build environment:" );
|
writer.write( "The following plugin cannot function in the current build environment:" );
|
||||||
|
|
||||||
|
writer.write( NEWLINE );
|
||||||
writeMojoBinding( binding, writer );
|
writeMojoBinding( binding, writer );
|
||||||
writer.write( "Referenced from project:" );
|
|
||||||
|
writer.write( "While building project:" );
|
||||||
|
writer.write( NEWLINE );
|
||||||
writeProjectCoordinate( project, writer );
|
writeProjectCoordinate( project, writer );
|
||||||
|
|
||||||
|
writer.write( NEWLINE );
|
||||||
writer.write( "Reason: " );
|
writer.write( "Reason: " );
|
||||||
writer.write( cause.getMessage() );
|
writer.write( cause.getMessage() );
|
||||||
|
|
||||||
|
|
|
@ -528,6 +528,11 @@ public class DefaultPluginManager
|
||||||
+ " requires online mode for execution. Maven is currently offline." );
|
+ " requires online mode for execution. Maven is currently offline." );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ( mojoDescriptor.getDeprecated() != null )
|
||||||
|
{
|
||||||
|
getLogger().warn( "Mojo: " + mojoDescriptor.getGoal() + " is deprecated.\n" + mojoDescriptor.getDeprecated() );
|
||||||
|
}
|
||||||
|
|
||||||
if ( mojoDescriptor.isDependencyResolutionRequired() != null )
|
if ( mojoDescriptor.isDependencyResolutionRequired() != null )
|
||||||
{
|
{
|
||||||
Collection projects;
|
Collection projects;
|
||||||
|
@ -805,6 +810,8 @@ public class DefaultPluginManager
|
||||||
mergedConfiguration,
|
mergedConfiguration,
|
||||||
mojoDescriptor );
|
mojoDescriptor );
|
||||||
|
|
||||||
|
checkDeprecatedParameters( mojoDescriptor, extractedMojoConfiguration );
|
||||||
|
|
||||||
checkRequiredParameters( mojoDescriptor, extractedMojoConfiguration, expressionEvaluator );
|
checkRequiredParameters( mojoDescriptor, extractedMojoConfiguration, expressionEvaluator );
|
||||||
|
|
||||||
populatePluginFields( mojo, mojoDescriptor, extractedMojoConfiguration, expressionEvaluator );
|
populatePluginFields( mojo, mojoDescriptor, extractedMojoConfiguration, expressionEvaluator );
|
||||||
|
@ -812,6 +819,52 @@ public class DefaultPluginManager
|
||||||
return mojo;
|
return mojo;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void checkDeprecatedParameters( MojoDescriptor mojoDescriptor,
|
||||||
|
PlexusConfiguration extractedMojoConfiguration )
|
||||||
|
{
|
||||||
|
if ( ( extractedMojoConfiguration == null ) || ( extractedMojoConfiguration.getChildCount() < 1 ) )
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
List parameters = mojoDescriptor.getParameters();
|
||||||
|
if ( ( parameters != null ) && !parameters.isEmpty() )
|
||||||
|
{
|
||||||
|
for ( Iterator it = parameters.iterator(); it.hasNext(); )
|
||||||
|
{
|
||||||
|
Parameter param = (Parameter) it.next();
|
||||||
|
|
||||||
|
if ( param.getDeprecated() != null )
|
||||||
|
{
|
||||||
|
boolean warnOfDeprecation = false;
|
||||||
|
if ( extractedMojoConfiguration.getChild( param.getName() ) != null )
|
||||||
|
{
|
||||||
|
warnOfDeprecation = true;
|
||||||
|
}
|
||||||
|
else if ( ( param.getAlias() != null ) && ( extractedMojoConfiguration.getChild( param.getAlias() ) != null ) )
|
||||||
|
{
|
||||||
|
warnOfDeprecation = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( warnOfDeprecation )
|
||||||
|
{
|
||||||
|
StringBuffer buffer = new StringBuffer();
|
||||||
|
buffer.append( "In mojo: " ).append( mojoDescriptor.getGoal() ).append( ", parameter: " ).append( param.getName() );
|
||||||
|
|
||||||
|
if ( param.getAlias() != null )
|
||||||
|
{
|
||||||
|
buffer.append( " (alias: " ).append( param.getAlias() ).append( ")" );
|
||||||
|
}
|
||||||
|
|
||||||
|
buffer.append( " is deprecated:" ).append( "\n\n" ).append( param.getDeprecated() ).append( "\n" );
|
||||||
|
|
||||||
|
getLogger().warn( buffer.toString() );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void setDescriptorClassAndArtifactInfo( PluginDescriptor pluginDescriptor,
|
private void setDescriptorClassAndArtifactInfo( PluginDescriptor pluginDescriptor,
|
||||||
MavenProject project,
|
MavenProject project,
|
||||||
MavenSession session )
|
MavenSession session )
|
||||||
|
|
|
@ -13,7 +13,7 @@ public privileged aspect ProjectReporterDebugAspect
|
||||||
// && target( reporter )
|
// && target( reporter )
|
||||||
// {
|
// {
|
||||||
// SourceLocation location = thisJoinPoint.getSourceLocation();
|
// SourceLocation location = thisJoinPoint.getSourceLocation();
|
||||||
// System.out.println( "Registering: " + key.getClass().getName() + "@" + key.hashCode() + "\nfrom: " + location.getFileName() + ", line: " + location.getLine() + "\nreporter is: " + reporter + "\n\nMessage:\n\n" + message );
|
// System.out.println( "Registering: " + key + "\nfrom: " + location.getFileName() + ", line: " + location.getLine() + "\nreporter is: " + reporter + "\n\nMessage:\n\n" + message );
|
||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
// before():
|
// before():
|
||||||
|
@ -27,7 +27,7 @@ public privileged aspect ProjectReporterDebugAspect
|
||||||
// {
|
// {
|
||||||
// if ( key != null )
|
// if ( key != null )
|
||||||
// {
|
// {
|
||||||
// System.out.println( "Found reported exception: " + key.getClass().getName() + "@" + key.hashCode() );
|
// System.out.println( "Found reported exception: " + key );
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue