last of the error-reporting unit tests, and an additional error type to handle modules that are referenced but don't exist, which should stop the build. All tests pass.

git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@613032 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
John Dennis Casey 2008-01-18 01:27:23 +00:00
parent a16c3bf4a8
commit 89f482ac37
27 changed files with 662 additions and 160 deletions

View File

@ -125,32 +125,6 @@ public privileged aspect BuildFailureReporterAspect
private pointcut within_le_getMojoDescriptorForDirectInvocation():
withincode( * DefaultLifecycleExecutor.getMojoDescriptorForDirectInvocation( String, MavenSession, MavenProject ) );
/**
* Call stack is:
* <br/>
* <pre>
* <code>
* DefaultMaven.execute(MavenExecutionRequest)
* --&gt; DefaultLifecycleExecutor.isTaskValid(String, MavenSession, MavenProject)
* --&gt; catch( PluginLoaderException )
* &lt;-- TaskValidationResult
* </code>
* </pre>
*/
after( MojoBinding binding, MavenSession session, MavenProject rootProject ) throwing ( PluginLoaderException cause ):
within_le_getMojoDescriptorForDirectInvocation()
&& call( * PluginLoader+.loadPlugin( MojoBinding, MavenProject, MavenSession ) )
&& args( binding, rootProject, session )
{
getReporter().reportPluginErrorWhileValidatingTask( binding.getGoal(), session, rootProject, cause );
}
// before():
// call( * MojoBindingFactory+.parseMojoBinding( String, MavenProject, MavenSession, boolean ) )
// {
// System.out.println( "Boo" );
// }
/**
* Call stack is:
* <br/>

View File

@ -25,10 +25,10 @@ import org.apache.maven.plugin.PluginManager;
import org.apache.maven.plugin.PluginParameterExpressionEvaluator;
import org.apache.maven.plugin.PluginParameterException;
import org.apache.maven.plugin.Mojo;
import org.apache.maven.lifecycle.statemgmt.ResolveLateBoundPluginMojo;
import org.codehaus.plexus.component.configurator.expression.ExpressionEvaluationException;
import org.codehaus.plexus.component.repository.exception.ComponentLookupException;
import org.codehaus.plexus.configuration.PlexusConfiguration;
import org.codehaus.plexus.PlexusContainer;
import java.util.List;
@ -40,6 +40,10 @@ public privileged aspect LifecycleErrorReporterAspect
execution( void DefaultLifecycleExecutor.executeGoalAndHandleFailures( MojoBinding, .. ) )
&& args( binding, .. );
private pointcut le_executeGoalAndHandleFailures_withSession( MojoBinding binding, MavenSession session ):
execution( void DefaultLifecycleExecutor.executeGoalAndHandleFailures( MojoBinding, MavenSession, .. ) )
&& args( binding, session, .. );
private pointcut pm_executeMojo( MavenProject project ):
execution( void PluginManager+.executeMojo( MavenProject, .. ) )
&& args( project, .. );
@ -48,15 +52,6 @@ public privileged aspect LifecycleErrorReporterAspect
withincode( void PluginManager+.executeMojo( MavenProject, .. ) )
&& args( project, .. );
before( MojoBinding binding, MavenProject project, LifecycleExecutionException err ):
cflow( le_executeGoalAndHandleFailures( binding ) )
&& execution( LifecycleExecutionException.new( String, MavenProject ) )
&& args( .., project )
&& this( err )
{
getReporter().reportMissingPluginDescriptor( binding, project, err );
}
after( MojoBinding binding, MavenProject project ) throwing ( PluginLoaderException cause ):
cflow( le_executeGoalAndHandleFailures( MojoBinding ) )
&& call( * PluginLoader+.loadPlugin( MojoBinding, MavenProject, .. ) )
@ -89,12 +84,11 @@ public privileged aspect LifecycleErrorReporterAspect
return cause;
}
before( MojoBinding binding, MavenProject project, ComponentLookupException cause ):
after( MojoBinding binding, MavenProject project ) throwing ( ComponentLookupException cause ):
cflow( le_executeGoalAndHandleFailures( binding ) )
&& cflow( pm_executeMojo( project ) )
&& withincode( Mojo DefaultPluginManager.getConfiguredMojo( .. ) )
&& handler( ComponentLookupException )
&& args( cause )
&& call( Object PlexusContainer+.lookup( .. ) )
{
getReporter().reportMojoLookupError( binding, project, cause );
}

View File

@ -1,6 +1,7 @@
package org.apache.maven.errors;
import org.apache.maven.reactor.MavenExecutionException;
import org.apache.maven.reactor.MissingModuleException;
import org.apache.maven.artifact.repository.ArtifactRepository;
import org.apache.maven.artifact.versioning.ArtifactVersion;
import org.apache.maven.execution.MavenExecutionRequest;
@ -59,6 +60,13 @@ public aspect MavenExecErrorReporterAspect
return err;
}
after( MissingModuleException err ):
execution( MissingModuleException.new( String, File, File ) )
&& this( err )
{
getReporter().reportMissingModulePom( err );
}
after(): dm_collectProjects( ArtifactRepository, ProfileManager )
{
currentProject = null;

View File

@ -42,6 +42,7 @@ import org.apache.maven.project.MavenProject;
import org.apache.maven.project.MavenProjectBuilder;
import org.apache.maven.project.ProjectBuildingException;
import org.apache.maven.reactor.MavenExecutionException;
import org.apache.maven.reactor.MissingModuleException;
import org.codehaus.plexus.PlexusConstants;
import org.codehaus.plexus.PlexusContainer;
import org.codehaus.plexus.context.Context;
@ -369,7 +370,14 @@ public class DefaultMaven
}
}
moduleFiles.add( moduleFile );
if ( !moduleFile.exists() )
{
throw new MissingModuleException( name, moduleFile, file );
}
else
{
moduleFiles.add( moduleFile );
}
}
List collectedProjects = collectProjects( moduleFiles, localRepository, recursive,

View File

@ -15,7 +15,6 @@ import org.apache.maven.execution.MavenExecutionRequest;
import org.apache.maven.execution.MavenSession;
import org.apache.maven.extension.ExtensionManagerException;
import org.apache.maven.lifecycle.LifecycleException;
import org.apache.maven.lifecycle.LifecycleExecutionException;
import org.apache.maven.lifecycle.LifecycleLoaderException;
import org.apache.maven.lifecycle.LifecycleSpecificationException;
import org.apache.maven.lifecycle.model.MojoBinding;
@ -39,6 +38,7 @@ import org.apache.maven.project.error.ProjectErrorReporter;
import org.apache.maven.project.interpolation.ModelInterpolationException;
import org.apache.maven.project.path.PathTranslator;
import org.apache.maven.reactor.MavenExecutionException;
import org.apache.maven.reactor.MissingModuleException;
import org.apache.maven.realm.RealmManagementException;
import org.codehaus.plexus.component.configurator.expression.ExpressionEvaluationException;
import org.codehaus.plexus.component.repository.exception.ComponentLookupException;
@ -97,8 +97,6 @@ public interface CoreErrorReporter
void reportLifecycleSpecErrorWhileValidatingTask( String task, MavenSession session, MavenProject rootProject, LifecycleSpecificationException cause );
void reportMissingPluginDescriptor( MojoBinding binding, MavenProject project, LifecycleExecutionException err );
void reportMissingRequiredMojoParameter( MojoBinding binding, MavenProject project, List invalidParameters, PluginParameterException err );
void reportMojoExecutionException( MojoBinding binding, MavenProject project, MojoExecutionException cause );
@ -125,4 +123,6 @@ public interface CoreErrorReporter
void reportUseOfBannedMojoParameter( Parameter currentParameter, MojoBinding binding, MavenProject project, String expression, String altExpression, ExpressionEvaluationException err );
void reportMissingModulePom( MissingModuleException err );
}

View File

@ -299,4 +299,12 @@ public final class CoreErrorTips
return null;
}
public static List getMissingModuleTips( File pomFile,
File moduleFile,
String moduleName )
{
// TODO Auto-generated method stub
return null;
}
}

View File

@ -17,7 +17,6 @@ import org.apache.maven.execution.MavenExecutionRequest;
import org.apache.maven.execution.MavenSession;
import org.apache.maven.extension.ExtensionManagerException;
import org.apache.maven.lifecycle.LifecycleException;
import org.apache.maven.lifecycle.LifecycleExecutionException;
import org.apache.maven.lifecycle.LifecycleLoaderException;
import org.apache.maven.lifecycle.LifecycleSpecificationException;
import org.apache.maven.lifecycle.MojoBindingUtils;
@ -46,6 +45,7 @@ import org.apache.maven.project.error.ProjectReporterManager;
import org.apache.maven.project.interpolation.ModelInterpolationException;
import org.apache.maven.project.path.PathTranslator;
import org.apache.maven.reactor.MavenExecutionException;
import org.apache.maven.reactor.MissingModuleException;
import org.apache.maven.realm.RealmManagementException;
import org.codehaus.plexus.component.configurator.expression.ExpressionEvaluationException;
import org.codehaus.plexus.component.repository.exception.ComponentLookupException;
@ -291,34 +291,6 @@ public class DefaultCoreErrorReporter
registerBuildError( cause, writer.toString(), cause.getCause() );
}
public void reportMissingPluginDescriptor( MojoBinding binding,
MavenProject project,
LifecycleExecutionException err )
{
StringWriter writer = new StringWriter();
writer.write( NEWLINE );
writer.write( "Maven cannot find a plugin required by your build:" );
writeMojoBinding( binding, writer );
writer.write( "Referenced from project:" );
writeProjectCoordinate( project, writer );
writer.write( "NOTE: If the above information seems incorrect, check that " +
"the corresponding <plugin/> section in your POM is correct." );
writer.write( NEWLINE );
writer.write( NEWLINE );
writer.write( "If you specified this plugin directly using something like " +
"'javadoc:javadoc', check that the <pluginGroups/> section in your " +
"$HOME/.m2/settings.xml contains the proper groupId for the plugin " +
"you are trying to use (each groupId goes in a separate <pluginGroup/> " +
"element within the <pluginGroups/> section." );
addTips( CoreErrorTips.getMissingPluginDescriptorTips( binding, project ), writer );
registerBuildError( err, writer.toString() );
}
public void reportInvalidPluginExecutionEnvironment( MojoBinding binding,
MavenProject project,
PluginExecutionException cause )
@ -1667,4 +1639,31 @@ public class DefaultCoreErrorReporter
}
}
public void reportMissingModulePom( MissingModuleException err )
{
StringWriter writer = new StringWriter();
writer.write( NEWLINE );
writer.write( "The module: " );
writer.write( err.getModuleName() );
writer.write( " cannot be found." );
writer.write( NEWLINE );
writer.write( NEWLINE );
writer.write( "Module's expected path: " );
writer.write( NEWLINE );
writer.write( err.getModuleFile().getAbsolutePath() );
writer.write( NEWLINE );
writer.write( NEWLINE );
writer.write( "Referenced by POM: " );
writer.write( NEWLINE );
writer.write( err.getPomFile().getAbsolutePath() );
writer.write( NEWLINE );
writer.write( NEWLINE );
writer.write( NEWLINE );
addTips( CoreErrorTips.getMissingModuleTips( err.getPomFile(), err.getModuleFile(), err.getModuleName() ), writer );
registerBuildError( err, writer.toString() );
}
}

View File

@ -20,6 +20,7 @@ package org.apache.maven.extension;
*/
import org.apache.maven.execution.MavenExecutionRequest;
import org.apache.maven.reactor.MissingModuleException;
import java.io.File;
import java.util.List;
@ -31,10 +32,10 @@ public interface BuildExtensionScanner
void scanForBuildExtensions( List files,
MavenExecutionRequest request )
throws ExtensionScanningException;
throws ExtensionScanningException, MissingModuleException;
void scanForBuildExtensions( File pom,
MavenExecutionRequest request )
throws ExtensionScanningException;
throws ExtensionScanningException, MissingModuleException;
}

View File

@ -38,6 +38,7 @@ import org.apache.maven.project.build.model.ModelLineageBuilder;
import org.apache.maven.project.build.model.ModelLineageIterator;
import org.apache.maven.project.interpolation.ModelInterpolationException;
import org.apache.maven.project.interpolation.ModelInterpolator;
import org.apache.maven.reactor.MissingModuleException;
import org.codehaus.plexus.logging.LogEnabled;
import org.codehaus.plexus.logging.Logger;
import org.codehaus.plexus.logging.console.ConsoleLogger;
@ -90,7 +91,7 @@ public class DefaultBuildExtensionScanner
public void scanForBuildExtensions( List files,
MavenExecutionRequest request )
throws ExtensionScanningException
throws ExtensionScanningException, MissingModuleException
{
List visited = new ArrayList();
@ -104,7 +105,7 @@ public class DefaultBuildExtensionScanner
public void scanForBuildExtensions( File pom,
MavenExecutionRequest request )
throws ExtensionScanningException
throws ExtensionScanningException, MissingModuleException
{
scanInternal( pom, request, new ArrayList(), Collections.singletonList( pom ) );
}
@ -113,7 +114,7 @@ public class DefaultBuildExtensionScanner
MavenExecutionRequest request,
List visitedModelIds,
List reactorFiles )
throws ExtensionScanningException
throws ExtensionScanningException, MissingModuleException
{
try
@ -244,7 +245,7 @@ public class DefaultBuildExtensionScanner
List originalRemoteRepositories,
List visitedModelIds,
List reactorFiles )
throws ExtensionScanningException
throws ExtensionScanningException, MissingModuleException
{
// FIXME: This gets a little sticky, because modules can be added by profiles that require
// an extension in place before they can be activated.
@ -302,11 +303,7 @@ public class DefaultBuildExtensionScanner
if ( !modulePomDirectory.exists() )
{
getLogger().debug(
"Cannot find POM for module: " + moduleSubpath
+ "; continuing scan with next module. (Full path was: "
+ modulePomDirectory + ")" );
continue;
throw new MissingModuleException( moduleSubpath, modulePomDirectory, containingPom );
}
scanInternal( modulePomDirectory, request, visitedModelIds, reactorFiles );

View File

@ -462,7 +462,7 @@ public class DefaultLifecycleExecutor
// using both the PluginDescriptor and the MojoBinding.
try
{
PluginDescriptor pluginDescriptor = null;
PluginDescriptor pluginDescriptor;
try
{
pluginDescriptor = pluginLoader.loadPlugin(
@ -487,62 +487,53 @@ public class DefaultLifecycleExecutor
}
}
if ( pluginDescriptor != null )
MojoDescriptor mojoDescriptor = pluginDescriptor.getMojo( mojoBinding.getGoal() );
MojoExecution mojoExecution = new MojoExecution( mojoDescriptor );
mojoExecution.setConfiguration( (Xpp3Dom) mojoBinding.getConfiguration() );
try
{
MojoDescriptor mojoDescriptor = pluginDescriptor.getMojo( mojoBinding.getGoal() );
MojoExecution mojoExecution = new MojoExecution( mojoDescriptor );
mojoExecution.setConfiguration( (Xpp3Dom) mojoBinding.getConfiguration() );
try
{
pluginManager.executeMojo(
project,
mojoExecution,
session );
}
catch ( PluginManagerException e )
{
throw new LifecycleExecutionException(
"Internal error in the plugin manager executing goal '"
+ mojoDescriptor.getId() + "': " + e.getMessage(),
project,
e );
}
catch ( ArtifactNotFoundException e )
{
throw new LifecycleExecutionException(
e.getMessage(),
project,
e );
}
catch ( InvalidDependencyVersionException e )
{
throw new LifecycleExecutionException(
e.getMessage(),
project,
e );
}
catch ( ArtifactResolutionException e )
{
throw new LifecycleExecutionException(
e.getMessage(),
project,
e );
}
catch ( PluginConfigurationException e )
{
throw new LifecycleExecutionException(
e.getMessage(),
project,
e );
}
pluginManager.executeMojo(
project,
mojoExecution,
session );
}
else
catch ( PluginManagerException e )
{
throw new LifecycleExecutionException(
"Failed to load plugin for: "
+ MojoBindingUtils.toString( mojoBinding ) + ". Reason: unknown", project );
"Internal error in the plugin manager executing goal '"
+ mojoDescriptor.getId() + "': " + e.getMessage(),
project,
e );
}
catch ( ArtifactNotFoundException e )
{
throw new LifecycleExecutionException(
e.getMessage(),
project,
e );
}
catch ( InvalidDependencyVersionException e )
{
throw new LifecycleExecutionException(
e.getMessage(),
project,
e );
}
catch ( ArtifactResolutionException e )
{
throw new LifecycleExecutionException(
e.getMessage(),
project,
e );
}
catch ( PluginConfigurationException e )
{
throw new LifecycleExecutionException(
e.getMessage(),
project,
e );
}
}
catch ( LifecycleExecutionException e )

View File

@ -418,8 +418,11 @@ public class DefaultPluginManager
pluginRealm.display();
}
throw new IllegalStateException( "The PluginDescriptor for the plugin "
+ projectPlugin.getKey() + " was not found. Should have been in realm: " + pluginRealm );
getLogger().debug( "Removing invalid plugin realm." );
realmManager.disposePluginRealm( projectPlugin );
throw new PluginManagerException( projectPlugin, "The PluginDescriptor for the plugin "
+ projectPlugin.getKey() + " was not found. Should have been in realm: " + pluginRealm, project );
}
pluginDescriptor.setPluginArtifact( pluginArtifact );
@ -854,7 +857,7 @@ public class DefaultPluginManager
mergedConfiguration,
mojoDescriptor );
checkDeprecatedParameters( mojoDescriptor, extractedMojoConfiguration );
checkDeprecatedParameters( mojoDescriptor, pomConfiguration );
checkRequiredParameters( mojoDescriptor, extractedMojoConfiguration, expressionEvaluator );

View File

@ -195,6 +195,18 @@ public class PluginManagerException
pluginVersion = plugin.getVersion();
}
public PluginManagerException( Plugin plugin,
String message,
MavenProject project )
{
super( message );
pluginGroupId = plugin.getGroupId();
pluginArtifactId = plugin.getArtifactId();
pluginVersion = plugin.getVersion();
this.project = project;
}
public String getPluginGroupId()
{
return pluginGroupId;

View File

@ -0,0 +1,30 @@
package org.apache.maven.reactor;
import java.io.File;
public class MissingModuleException
extends MavenExecutionException
{
private File moduleFile;
private final String moduleName;
public MissingModuleException( String moduleName, File moduleFile, File pomFile )
{
super( "The module: " + moduleName + " cannot be found in file: " + moduleFile, pomFile );
this.moduleName = moduleName;
this.moduleFile = moduleFile;
}
public File getModuleFile()
{
return moduleFile;
}
public String getModuleName()
{
return moduleName;
}
}

View File

@ -0,0 +1,49 @@
<?xml version='1.0' encoding='UTF-8'?>
<project>
<modelVersion>4.0.0</modelVersion>
<groupId>org.apache.maven.errortest</groupId>
<artifactId>testReportErrorApplyingMojoConfiguration-maven-plugin</artifactId>
<version>1</version>
<dependencies>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-plugin-api</artifactId>
<version>2.0</version>
</dependency>
</dependencies>
<build>
<pluginManagement>
<plugins>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.3.1</version>
</plugin>
<plugin>
<artifactId>maven-deploy-plugin</artifactId>
<version>2.3</version>
</plugin>
<plugin>
<artifactId>maven-install-plugin</artifactId>
<version>2.2</version>
</plugin>
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<version>2.2</version>
</plugin>
<plugin>
<artifactId>maven-jar-plugin</artifactId>
<version>2.1</version>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.0.2</version>
</plugin>
<plugin>
<artifactId>maven-plugin-plugin</artifactId>
<version>2.3</version>
</plugin>
</plugins>
</pluginManagement>
</build>
</project>

View File

@ -0,0 +1,33 @@
package org.plugin;
import org.apache.maven.plugin.Mojo;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.MojoFailureException;
import org.apache.maven.plugin.logging.Log;
/**
* @goal test
*/
public class TestPlugin
implements Mojo
{
private Log log;
public void execute()
throws MojoExecutionException, MojoFailureException
{
throw new MojoExecutionException( "This is meant to fail." );
}
public Log getLog()
{
return log;
}
public void setLog( Log log )
{
this.log = log;
}
}

View File

@ -0,0 +1,38 @@
<plugin>
<description></description>
<groupId>org.apache.maven.errortest</groupId>
<artifactId>testReportErrorApplyingMojoConfiguration-maven-plugin</artifactId>
<version>1</version>
<goalPrefix>testReportErrorApplyingMojoConfiguration</goalPrefix>
<isolatedRealm>false</isolatedRealm>
<inheritedByDefault>true</inheritedByDefault>
<mojos>
<mojo>
<goal>test</goal>
<description></description>
<requiresDirectInvocation>false</requiresDirectInvocation>
<requiresProject>true</requiresProject>
<requiresReports>false</requiresReports>
<aggregator>false</aggregator>
<requiresOnline>false</requiresOnline>
<inheritedByDefault>true</inheritedByDefault>
<implementation>org.plugin.TestPlugin</implementation>
<language>java</language>
<instantiationStrategy>per-lookup</instantiationStrategy>
<executionStrategy>once-per-session</executionStrategy>
<parameters>
<parameter>
<name>param</name>
<type>java.lang.String</type>
<required>true</required>
<editable>false</editable>
<description></description>
</parameter>
</parameters>
<configuration>
<param implementation="java.lang.String" default-value="something"/>
</configuration>
</mojo>
</mojos>
<dependencies/>
</plugin>

View File

@ -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>
<modelVersion>4.0.0</modelVersion>
<groupId>org.apache.maven</groupId>
<artifactId>testReportErrorApplyingMojoConfiguration</artifactId>
<version>1</version>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.errortest</groupId>
<artifactId>testReportErrorApplyingMojoConfiguration-maven-plugin</artifactId>
<version>1</version>
<executions>
<execution>
<id>test-run</id>
<phase>initialize</phase>
<goals>
<goal>test</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>

View File

@ -0,0 +1,19 @@
<?xml version='1.0' encoding='UTF-8'?>
<project>
<parent>
<artifactId>testReportMissingModulePom</artifactId>
<groupId>org.apache.maven.errortest</groupId>
<version>1</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>testReportMissingModulePom-child1</artifactId>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>

View File

@ -0,0 +1,13 @@
package org.test;
/**
* Hello world!
*
*/
public class App
{
public static void main( String[] args )
{
System.out.println( "Hello World!" );
}
}

View File

@ -0,0 +1,38 @@
package org.test;
import junit.framework.Test;
import junit.framework.TestCase;
import junit.framework.TestSuite;
/**
* Unit test for simple App.
*/
public class AppTest
extends TestCase
{
/**
* Create the test case
*
* @param testName name of the test case
*/
public AppTest( String testName )
{
super( testName );
}
/**
* @return the suite of tests being tested
*/
public static Test suite()
{
return new TestSuite( AppTest.class );
}
/**
* Rigourous Test :-)
*/
public void testApp()
{
assertTrue( true );
}
}

View File

@ -0,0 +1,13 @@
<?xml version='1.0' encoding='UTF-8'?>
<project 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' xmlns='http://maven.apache.org/POM/4.0.0'>
<modelVersion>4.0.0</modelVersion>
<groupId>org.apache.maven.errortest</groupId>
<artifactId>testReportMissingModulePom</artifactId>
<packaging>pom</packaging>
<version>1</version>
<modules>
<module>child1</module>
<module>child2</module>
</modules>
</project>

View File

@ -0,0 +1,54 @@
<?xml version='1.0' encoding='UTF-8'?>
<project>
<modelVersion>4.0.0</modelVersion>
<groupId>org.apache.maven.errortest</groupId>
<artifactId>testReportMojoLookupError-maven-plugin</artifactId>
<packaging>maven-plugin</packaging>
<version>1</version>
<dependencies>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-plugin-api</artifactId>
<version>2.0</version>
</dependency>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-project</artifactId>
<version>2.0</version>
</dependency>
</dependencies>
<build>
<pluginManagement>
<plugins>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.3.1</version>
</plugin>
<plugin>
<artifactId>maven-deploy-plugin</artifactId>
<version>2.3</version>
</plugin>
<plugin>
<artifactId>maven-install-plugin</artifactId>
<version>2.2</version>
</plugin>
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<version>2.2</version>
</plugin>
<plugin>
<artifactId>maven-jar-plugin</artifactId>
<version>2.1</version>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.0.2</version>
</plugin>
<plugin>
<artifactId>maven-plugin-plugin</artifactId>
<version>2.3</version>
</plugin>
</plugins>
</pluginManagement>
</build>
</project>

View File

@ -0,0 +1,42 @@
package org.plugin;
import org.apache.maven.plugin.Mojo;
import org.apache.maven.project.MavenProject;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.MojoFailureException;
import org.apache.maven.plugin.logging.Log;
/**
* @goal test
* @requiresProject false
*
* @author jdcasey
*/
public class TestPlugin
implements Mojo
{
private Log log;
/**
* @component role-hint="nonexistant"
*/
private MavenProject project;
public void execute()
throws MojoExecutionException, MojoFailureException
{
throw new MojoExecutionException( "THIS SHOULD NEVER BE CALLED." );
}
public Log getLog()
{
return log;
}
public void setLog( Log log )
{
this.log = log;
}
}

View File

@ -0,0 +1,25 @@
<!--
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>
<modelVersion>4.0.0</modelVersion>
<groupId>org.apache.maven</groupId>
<artifactId>testReportAggregatedMojoFailureException</artifactId>
<version>1</version>
</project>

View File

@ -197,7 +197,8 @@ public class ErrorReporterPointcutTest
}
}
private void reportExceptions( MavenExecutionResult result, File basedir )
private void reportExceptions( MavenExecutionResult result,
File basedir )
{
StringWriter writer = new StringWriter();
PrintWriter pWriter = new PrintWriter( writer );
@ -293,7 +294,14 @@ public class ErrorReporterPointcutTest
File basedir = new File( projectDir, "project" );
reporter.reportAttemptToOverrideUneditableMojoParameter( null, null, null, null, null, null, null, null );
reporter.reportAttemptToOverrideUneditableMojoParameter( null,
null,
null,
null,
null,
null,
null,
null );
reporterCtl.setMatcher( MockControl.ALWAYS_MATCHER );
reporterCtl.setVoidCallable();
@ -312,9 +320,35 @@ public class ErrorReporterPointcutTest
}
public void testReportErrorApplyingMojoConfiguration()
throws IOException
{
// TODO Auto-generated method stub
if ( !checkOnline() )
{
return;
}
File projectDir = prepareProjectDir();
File plugin = new File( projectDir, "plugin" );
File project = new File( projectDir, "project" );
buildTestAccessory( plugin );
reporter.reportErrorApplyingMojoConfiguration( null, null, null, null );
reporterCtl.setMatcher( MockControl.ALWAYS_MATCHER );
reporterCtl.setVoidCallable();
reporterCtl.replay();
MavenExecutionRequest request = new DefaultMavenExecutionRequest().setBaseDirectory( project )
.setShowErrors( true )
.setErrorReporter( reporter )
.setGoals( Arrays.asList( new String[] {
"org.apache.maven.errortest:testReportErrorApplyingMojoConfiguration-maven-plugin:1:test"
} ) );
maven.execute( request );
reporterCtl.verify();
}
public void testReportErrorConfiguringExtensionPluginRealm()
@ -326,7 +360,11 @@ public class ErrorReporterPointcutTest
File project = new File( projectDir, "project" );
reporter.reportErrorConfiguringExtensionPluginRealm( null, null, null, null, (PluginManagerException) null );
reporter.reportErrorConfiguringExtensionPluginRealm( null,
null,
null,
null,
(PluginManagerException) null );
reporterCtl.setMatcher( MockControl.ALWAYS_MATCHER );
reporterCtl.setVoidCallable();
@ -559,7 +597,13 @@ public class ErrorReporterPointcutTest
File localRepo = new File( projectDir, "local-repo" );
File project = new File( projectDir, "project" );
reporter.reportIncompatibleMavenVersionForExtensionPlugin( null, null, null, null, null, null, null );
reporter.reportIncompatibleMavenVersionForExtensionPlugin( null,
null,
null,
null,
null,
null,
null );
reporterCtl.setMatcher( MockControl.ALWAYS_MATCHER );
reporterCtl.setVoidCallable();
@ -703,12 +747,6 @@ public class ErrorReporterPointcutTest
reporterCtl.verify();
}
public void testReportMissingPluginDescriptor()
{
// TODO Auto-generated method stub
}
public void testReportMissingRequiredMojoParameter()
throws IOException
{
@ -774,9 +812,33 @@ public class ErrorReporterPointcutTest
}
public void testReportMojoLookupError()
throws IOException
{
// TODO Auto-generated method stub
if ( !checkOnline() )
{
return;
}
File projectDir = prepareProjectDir();
buildTestAccessory( new File( projectDir, "plugin" ) );
reporter.reportMojoLookupError( null, null, null );
reporterCtl.setMatcher( MockControl.ALWAYS_MATCHER );
reporterCtl.setVoidCallable();
reporterCtl.replay();
MavenExecutionRequest request = new DefaultMavenExecutionRequest().setBaseDirectory( projectDir )
.setShowErrors( true )
.setErrorReporter( reporter )
.setGoals( Arrays.asList( new String[] {
"org.apache.maven.errortest:testReportMojoLookupError-maven-plugin:1:test"
} ) );
maven.execute( request );
reporterCtl.verify();
}
public void testReportNoGoalsSpecifiedException()
@ -824,7 +886,9 @@ public class ErrorReporterPointcutTest
{
File projectDir = prepareProjectDir();
reporter.reportProjectDependenciesNotFound( null, null, (MultipleArtifactsNotFoundException) null );
reporter.reportProjectDependenciesNotFound( null,
null,
(MultipleArtifactsNotFoundException) null );
reporterCtl.setMatcher( MockControl.ALWAYS_MATCHER );
reporterCtl.setVoidCallable();
@ -897,12 +961,6 @@ public class ErrorReporterPointcutTest
reporterCtl.verify();
}
public void testReportReflectionErrorWhileEvaluatingMojoParameter()
{
// TODO Auto-generated method stub
}
public void testReportUnresolvableArtifactWhileAddingExtensionPlugin()
throws IOException
{
@ -1131,7 +1189,10 @@ public class ErrorReporterPointcutTest
{
File projectDir = prepareProjectDir();
reporter.reportErrorLoadingExternalProfilesFromFile( null, null, null, (XmlPullParserException) null );
reporter.reportErrorLoadingExternalProfilesFromFile( null,
null,
null,
(XmlPullParserException) null );
reporterCtl.setMatcher( MockControl.ALWAYS_MATCHER );
reporterCtl.setVoidCallable();
@ -1273,7 +1334,10 @@ public class ErrorReporterPointcutTest
{
File projectDir = prepareProjectDir();
reporter.reportInvalidRepositoryWhileGettingRepositoriesFromProfiles( null, null, null, null );
reporter.reportInvalidRepositoryWhileGettingRepositoriesFromProfiles( null,
null,
null,
null );
reporterCtl.setMatcher( MockControl.ALWAYS_MATCHER );
reporterCtl.setVoidCallable();
@ -1366,4 +1430,27 @@ public class ErrorReporterPointcutTest
reporterCtl.verify();
}
public void testReportMissingModulePom()
throws IOException
{
File projectDir = prepareProjectDir();
reporter.reportMissingModulePom( null );
reporterCtl.setMatcher( MockControl.ALWAYS_MATCHER );
reporterCtl.setVoidCallable();
reporterCtl.replay();
MavenExecutionRequest request = new DefaultMavenExecutionRequest().setBaseDirectory( projectDir )
.setShowErrors( true )
.setErrorReporter( reporter )
.setGoals( Arrays.asList( new String[] {
"initialize"
} ) );
maven.execute( request );
reporterCtl.verify();
}
}

View File

@ -339,6 +339,25 @@ public class DefaultMavenRealmManager
}
}
public void disposePluginRealm( Plugin plugin )
{
String id = RealmUtils.createPluginRealmId( plugin );
logger.debug( "Disposing realm for plugin with id: " + id );
try
{
world.disposeRealm( id );
}
catch ( NoSuchRealmException e )
{
logger.debug( "Plugin realm: " + id + " didn't exist in ClassWorld instance." );
}
managedRealmIds.remove( id );
pluginArtifacts.remove( id );
}
public ClassRealm createPluginRealm( Plugin plugin,
Artifact pluginArtifact,
Collection artifacts )

View File

@ -37,6 +37,8 @@ public interface MavenRealmManager
Collection artifacts )
throws RealmManagementException;
void disposePluginRealm( Plugin plugin );
void setPluginArtifacts( Plugin plugin,
Collection artifacts );
}