More unit tests for error-reporting pointcuts, and some minor adjustments for duplicated handler methods.

git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@611014 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
John Dennis Casey 2008-01-11 01:57:27 +00:00
parent 867e53f7fd
commit 25460922d5
30 changed files with 1441 additions and 379 deletions

View File

@ -84,13 +84,16 @@ public privileged aspect ExtensionErrorReporterAspect
getReporter().reportErrorResolvingExtensionDirectDependencies( extensionArtifact, projectArtifact, remoteRepos, request, cause );
}
before( Artifact extensionArtifact, Artifact projectArtifact, List remoteRepos, MavenExecutionRequest request, ArtifactResolutionResult resolutionResult, ExtensionManagerException err ):
ExtensionManagerException around( Artifact extensionArtifact, Artifact projectArtifact, List remoteRepos, MavenExecutionRequest request, ArtifactResolutionResult resolutionResult ):
cflow( dem_addExtension( extensionArtifact, projectArtifact, remoteRepos, request ) )
&& execution( ExtensionManagerException.new( .., ArtifactResolutionResult ) )
&& call( ExtensionManagerException.new( .., ArtifactResolutionResult ) )
&& args( .., resolutionResult )
&& this( err )
{
ExtensionManagerException err = proceed( extensionArtifact, projectArtifact, remoteRepos, request, resolutionResult );
getReporter().reportErrorResolvingExtensionDependencies( extensionArtifact, projectArtifact, remoteRepos, request, resolutionResult, err );
return err;
}
private pointcut call_eme_ctor_RealmManagementException( RealmManagementException cause ):
@ -214,27 +217,17 @@ public privileged aspect ExtensionErrorReporterAspect
cflow( dem_addPluginAsExtension( Plugin, originModel, remoteRepos, request ) )
&& cflow( execution( * PluginManager+.verifyPlugin( .. ) ) )
&& cflow( dpm_verifyVersionedPlugin( plugin ) )
&& execution( PluginVersionResolutionException.new( .., String ) )
&& call( PluginVersionResolutionException.new( .., String ) )
&& this( err )
{
getReporter().reportIncompatibleMavenVersionForExtensionPlugin( plugin, originModel, remoteRepos, request, requiredVersion, currentVersion, err );
}
before( Plugin plugin, Model originModel, List remoteRepos, MavenExecutionRequest request, ProjectBuildingException cause ):
cflow( dem_addPluginAsExtension( Plugin, originModel, remoteRepos, request ) )
&& cflow( execution( * PluginManager+.verifyPlugin( .. ) ) )
&& cflow( dpm_verifyVersionedPlugin( plugin ) )
&& execution( InvalidPluginException.new( .., ProjectBuildingException ) )
&& args( .., cause )
{
getReporter().handleErrorBuildingExtensionPluginPOM( plugin, originModel, remoteRepos, request, cause );
}
before( Plugin plugin, Model originModel, List remoteRepos, MavenExecutionRequest request, InvalidDependencyVersionException cause ):
cflow( dem_addPluginAsExtension( Plugin, originModel, remoteRepos, request ) )
&& cflow( execution( * PluginManager+.verifyPlugin( .. ) ) )
&& cflow( dpm_verifyVersionedPlugin( plugin ) )
&& execution( InvalidPluginException.new( .., InvalidDependencyVersionException ) )
&& call( InvalidPluginException.new( .., InvalidDependencyVersionException ) )
&& args( .., cause )
{
getReporter().reportInvalidDependencyVersionInExtensionPluginPOM( plugin, originModel, remoteRepos, request, cause );

View File

@ -33,7 +33,6 @@ import org.apache.maven.plugin.descriptor.Parameter;
import org.apache.maven.plugin.loader.PluginLoaderException;
import org.apache.maven.plugin.version.PluginVersionNotFoundException;
import org.apache.maven.plugin.version.PluginVersionResolutionException;
import org.apache.maven.profiles.ProfileManager;
import org.apache.maven.project.MavenProject;
import org.apache.maven.project.ProjectBuildingException;
import org.apache.maven.project.artifact.InvalidDependencyVersionException;
@ -55,37 +54,67 @@ public interface CoreErrorReporter
extends ProjectErrorReporter
{
void reportNoGoalsSpecifiedException( MavenProject rootProject, NoGoalsSpecifiedException error );
void handleSuperPomBuildingError( ProjectBuildingException exception );
void reportAggregatedMojoFailureException( MavenSession session, MojoBinding binding, MojoFailureException cause );
void reportProjectMojoFailureException( MavenSession session, MojoBinding binding, MojoFailureException cause );
void reportAttemptToOverrideUneditableMojoParameter( Parameter currentParameter, MojoBinding binding, MavenProject project, MavenSession session, MojoExecution exec, PathTranslator translator, Logger logger, PluginConfigurationException cause );
void reportProjectCycle( ProjectCycleException error );
void reportErrorApplyingMojoConfiguration( MojoBinding binding, MavenProject project, PlexusConfiguration config, PluginConfigurationException cause );
void reportPluginErrorWhileValidatingTask( MavenSession session, MavenProject rootProject, PluginLoaderException cause, TaskValidationResult result );
void reportErrorConfiguringExtensionPluginRealm( Plugin plugin, Model originModel, List remoteRepos, MavenExecutionRequest request, PluginManagerException cause );
void reportLifecycleSpecErrorWhileValidatingTask( MavenSession session, MavenProject rootProject, LifecycleSpecificationException cause, TaskValidationResult result );
void reportErrorFormulatingBuildPlan( List tasks, MavenProject configuringProject, String targetDescription, LifecycleException cause );
void reportLifecycleLoaderErrorWhileValidatingTask( MavenSession session, MavenProject rootProject, LifecycleLoaderException cause, TaskValidationResult result );
void reportErrorInterpolatingModel( Model model, Map inheritedValues, File pomFile, MavenExecutionRequest request, ModelInterpolationException cause );
void reportMissingPluginDescriptor( MojoBinding binding, MavenProject project, LifecycleExecutionException err );
void reportErrorLoadingPlugin( MojoBinding binding, MavenProject project, PluginLoaderException cause );
void reportMojoExecutionException( MojoBinding binding, MavenProject project, MojoExecutionException cause );
void reportErrorManagingRealmForExtension( Artifact extensionArtifact, Artifact projectArtifact, List remoteRepos, MavenExecutionRequest request, RealmManagementException cause );
void reportErrorManagingRealmForExtensionPlugin( Plugin plugin, Model originModel, List remoteRepos, MavenExecutionRequest request, RealmManagementException cause );
void reportErrorResolvingExtensionDependencies( Artifact extensionArtifact, Artifact projectArtifact, List remoteRepos, MavenExecutionRequest request, ArtifactResolutionResult resolutionResult, ExtensionManagerException err );
void reportErrorResolvingExtensionDirectDependencies( Artifact extensionArtifact, Artifact projectArtifact, List remoteRepos, MavenExecutionRequest request, ArtifactMetadataRetrievalException cause );
void reportErrorSearchingforCompatibleExtensionPluginVersion( Plugin plugin, Model originModel, List remoteRepos, MavenExecutionRequest request, String requiredMavenVersion, String currentMavenVersion, InvalidVersionSpecificationException cause );
void reportExtensionPluginArtifactNotFound( Plugin plugin, Model originModel, List remoteRepos, MavenExecutionRequest request, PluginNotFoundException cause );
void reportExtensionPluginVersionNotFound( Plugin plugin, Model originModel, List remoteRepos, MavenExecutionRequest request, PluginVersionNotFoundException cause );
void reportIncompatibleMavenVersionForExtensionPlugin( Plugin plugin, Model originModel, List remoteRepos, MavenExecutionRequest request, String requiredMavenVersion, String currentMavenVersion, PluginVersionResolutionException err );
void reportInvalidDependencyVersionInExtensionPluginPOM( Plugin plugin, Model originModel, List remoteRepos, MavenExecutionRequest request, InvalidDependencyVersionException cause );
void reportInvalidMavenVersion( MavenProject project, ArtifactVersion mavenVersion, MavenExecutionException err );
void reportInvalidPluginExecutionEnvironment( MojoBinding binding, MavenProject project, PluginExecutionException cause );
void reportMojoLookupError( MojoBinding binding, MavenProject project, ComponentLookupException cause );
void reportLifecycleLoaderErrorWhileValidatingTask( MavenSession session, MavenProject rootProject, LifecycleLoaderException cause, TaskValidationResult result );
void reportAttemptToOverrideUneditableMojoParameter( Parameter currentParameter, MojoBinding binding, MavenProject project, MavenSession session, MojoExecution exec, PathTranslator translator, Logger logger, PluginConfigurationException cause );
void reportLifecycleSpecErrorWhileValidatingTask( MavenSession session, MavenProject rootProject, LifecycleSpecificationException cause, TaskValidationResult result );
void reportMissingArtifactWhileAddingExtensionPlugin( Plugin plugin, Model originModel, List remoteRepos, MavenExecutionRequest request, ArtifactNotFoundException cause );
void reportMissingPluginDescriptor( MojoBinding binding, MavenProject project, LifecycleExecutionException err );
void reportMissingRequiredMojoParameter( MojoBinding binding, MavenProject project, List invalidParameters, PluginParameterException err );
void reportUseOfBannedMojoParameter( Parameter currentParameter, MojoBinding binding, MavenProject project, String expression, String altExpression, ExpressionEvaluationException err );
void reportMojoExecutionException( MojoBinding binding, MavenProject project, MojoExecutionException cause );
void reportReflectionErrorWhileEvaluatingMojoParameter( Parameter currentParameter, MojoBinding binding, MavenProject project, String expression, Exception cause );
void reportMojoLookupError( MojoBinding binding, MavenProject project, ComponentLookupException cause );
void reportErrorApplyingMojoConfiguration( MojoBinding binding, MavenProject project, PlexusConfiguration config, PluginConfigurationException cause );
void reportNoGoalsSpecifiedException( MavenProject rootProject, NoGoalsSpecifiedException error );
void reportPluginErrorWhileValidatingTask( MavenSession session, MavenProject rootProject, PluginLoaderException cause, TaskValidationResult result );
void reportPomFileCanonicalizationError( File pomFile, IOException cause );
void reportPomFileScanningError( File basedir, String includes, String excludes, IOException cause );
void reportProjectCycle( ProjectCycleException error );
void reportProjectDependenciesNotFound( MavenProject project, String scope, ArtifactNotFoundException cause );
@ -95,48 +124,14 @@ public interface CoreErrorReporter
void reportProjectDependencyArtifactUnresolvable( MavenProject project, Artifact artifact, ArtifactResolutionException cause );
void reportErrorLoadingPlugin( MojoBinding binding, MavenProject project, PluginLoaderException cause );
void reportProjectMojoFailureException( MavenSession session, MojoBinding binding, MojoFailureException cause );
void reportErrorFormulatingBuildPlan( List tasks, MavenProject configuringProject, String targetDescription, LifecycleException cause );
void reportInvalidMavenVersion( MavenProject project, ArtifactVersion mavenVersion, MavenExecutionException err );
void reportPomFileScanningError( File basedir, String includes, String excludes, IOException cause );
void reportPomFileCanonicalizationError( File pomFile, IOException cause );
void handleSuperPomBuildingError( ProfileManager globalProfileManager, ProjectBuildingException exception );
void handleSuperPomBuildingError( ProjectBuildingException exception );
void reportErrorInterpolatingModel( Model model, Map inheritedValues, File pomFile, MavenExecutionRequest request, ModelInterpolationException cause );
void reportErrorResolvingExtensionDirectDependencies( Artifact extensionArtifact, Artifact projectArtifact, List remoteRepos, MavenExecutionRequest request, ArtifactMetadataRetrievalException cause );
void reportErrorResolvingExtensionDependencies( Artifact extensionArtifact, Artifact projectArtifact, List remoteRepos, MavenExecutionRequest request, ArtifactResolutionResult resolutionResult, ExtensionManagerException err );
void reportErrorManagingRealmForExtension( Artifact extensionArtifact, Artifact projectArtifact, List remoteRepos, MavenExecutionRequest request, RealmManagementException cause );
void reportErrorManagingRealmForExtensionPlugin( Plugin plugin, Model originModel, List remoteRepos, MavenExecutionRequest request, RealmManagementException cause );
void reportMissingArtifactWhileAddingExtensionPlugin( Plugin plugin, Model originModel, List remoteRepos, MavenExecutionRequest request, ArtifactNotFoundException cause );
void reportReflectionErrorWhileEvaluatingMojoParameter( Parameter currentParameter, MojoBinding binding, MavenProject project, String expression, Exception cause );
void reportUnresolvableArtifactWhileAddingExtensionPlugin( Plugin plugin, Model originModel, List remoteRepos, MavenExecutionRequest request, ArtifactResolutionException cause );
void reportExtensionPluginArtifactNotFound( Plugin plugin, Model originModel, List remoteRepos, MavenExecutionRequest request, PluginNotFoundException cause );
void reportUnresolvableExtensionPluginPOM( Plugin plugin, Model originModel, List remoteRepos, MavenExecutionRequest request, ArtifactMetadataRetrievalException cause );
void handleErrorBuildingExtensionPluginPOM( Plugin plugin, Model originModel, List remoteRepos, MavenExecutionRequest request, ProjectBuildingException cause );
void reportInvalidDependencyVersionInExtensionPluginPOM( Plugin plugin, Model originModel, List remoteRepos, MavenExecutionRequest request, InvalidDependencyVersionException cause );
void reportErrorSearchingforCompatibleExtensionPluginVersion( Plugin plugin, Model originModel, List remoteRepos, MavenExecutionRequest request, String requiredMavenVersion, String currentMavenVersion, InvalidVersionSpecificationException cause );
void reportIncompatibleMavenVersionForExtensionPlugin( Plugin plugin, Model originModel, List remoteRepos, MavenExecutionRequest request, String requiredMavenVersion, String currentMavenVersion, PluginVersionResolutionException err );
void reportExtensionPluginVersionNotFound( Plugin plugin, Model originModel, List remoteRepos, MavenExecutionRequest request, PluginVersionNotFoundException cause );
void reportErrorConfiguringExtensionPluginRealm( Plugin plugin, Model originModel, List remoteRepos, MavenExecutionRequest request, PluginManagerException cause );
void reportUseOfBannedMojoParameter( Parameter currentParameter, MojoBinding binding, MavenProject project, String expression, String altExpression, ExpressionEvaluationException err );
}

View File

@ -5,7 +5,6 @@ import org.apache.maven.ProjectCycleException;
import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.ArtifactUtils;
import org.apache.maven.artifact.metadata.ArtifactMetadataRetrievalException;
import org.apache.maven.artifact.repository.ArtifactRepository;
import org.apache.maven.artifact.resolver.AbstractArtifactResolutionException;
import org.apache.maven.artifact.resolver.ArtifactNotFoundException;
import org.apache.maven.artifact.resolver.ArtifactResolutionException;
@ -40,7 +39,6 @@ import org.apache.maven.plugin.descriptor.Parameter;
import org.apache.maven.plugin.loader.PluginLoaderException;
import org.apache.maven.plugin.version.PluginVersionNotFoundException;
import org.apache.maven.plugin.version.PluginVersionResolutionException;
import org.apache.maven.profiles.ProfileManager;
import org.apache.maven.project.MavenProject;
import org.apache.maven.project.ProjectBuildingException;
import org.apache.maven.project.artifact.InvalidDependencyVersionException;
@ -947,28 +945,6 @@ public class DefaultCoreErrorReporter
registerBuildError( cause, writer.toString(), cause.getCause() );
}
public void handleSuperPomBuildingError( MavenExecutionRequest request,
ArtifactRepository localRepository,
ProfileManager globalProfileManager,
ProjectBuildingException exception )
{
ProjectErrorReporter projectReporter = ProjectReporterManager.getReporter();
Throwable reportedException = projectReporter.findReportedException( exception );
String formattedMessage = projectReporter.getFormattedMessage( reportedException );
registerBuildError( exception, formattedMessage, reportedException );
}
public void handleSuperPomBuildingError( ProfileManager globalProfileManager,
ProjectBuildingException exception )
{
ProjectErrorReporter projectReporter = ProjectReporterManager.getReporter();
Throwable reportedException = projectReporter.findReportedException( exception );
String formattedMessage = projectReporter.getFormattedMessage( reportedException );
registerBuildError( exception, formattedMessage, reportedException );
}
public void handleSuperPomBuildingError( ProjectBuildingException exception )
{
ProjectErrorReporter projectReporter = ProjectReporterManager.getReporter();
@ -1387,19 +1363,6 @@ public class DefaultCoreErrorReporter
registerBuildError( cause, writer.toString(), cause.getCause() );
}
public void handleErrorBuildingExtensionPluginPOM( Plugin plugin,
Model originModel,
List remoteRepos,
MavenExecutionRequest request,
ProjectBuildingException cause )
{
ProjectErrorReporter projectReporter = ProjectReporterManager.getReporter();
Throwable reportedException = projectReporter.findReportedException( cause );
String formattedMessage = projectReporter.getFormattedMessage( reportedException );
registerBuildError( cause, formattedMessage, reportedException );
}
public void reportInvalidDependencyVersionInExtensionPluginPOM( Plugin plugin,
Model originModel,
List remoteRepos,

View File

@ -407,7 +407,6 @@ public class DefaultBuildExtensionScanner
}
catch ( ProjectBuildingException e )
{
System.out.println( "blah" );
throw new ExtensionScanningException( "Error building model lineage in order to pre-scan for extensions: "
+ e.getMessage(), pom, e );
}

View File

@ -86,6 +86,10 @@ under the License.
<groupId>easymock</groupId>
<artifactId>easymock</artifactId>
</dependency>
<dependency>
<groupId>commons-httpclient</groupId>
<artifactId>commons-httpclient</artifactId>
</dependency>
</dependencies>
<distributionManagement>

View File

@ -0,0 +1,39 @@
<!--
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>testReportActivatorError</artifactId>
<version>1</version>
<profiles>
<profile>
<id>faulty</id>
<activation>
<custom>
<type>nothing</type>
<configuration>
<foo>bar</foo>
</configuration>
</custom>
</activation>
</profile>
</profiles>
</project>

View File

@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?><project>
<modelVersion>4.0.0</modelVersion>
<groupId>org.apache.maven.errortest</groupId>
<artifactId>testReportAggregatedMojoFailureException-maven-plugin</artifactId>
<packaging>maven-plugin</packaging>
<version>1</version>
<dependencies>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-plugin-api</artifactId>
<version>2.1-SNAPSHOT</version>
</dependency>
</dependencies>
</project>

View File

@ -0,0 +1,36 @@
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
* @aggregator
*
* @author jdcasey
*/
public class TestPlugin
implements Mojo
{
private Log log;
public void execute()
throws MojoExecutionException, MojoFailureException
{
throw new MojoFailureException( this, "This mojo will always fail.", "This mojo is programmed to fail at all times, to express certain error-reporting functions." );
}
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

@ -0,0 +1,33 @@
<!--
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>testReportBadDependencyVersion</artifactId>
<version>1</version>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>[3.1,</version>
</dependency>
</dependencies>
</project>

View File

@ -0,0 +1,35 @@
<!--
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>testReportBadManagedDependencyVersion</artifactId>
<version>1</version>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>[3.1,</version>
</dependency>
</dependencies>
</dependencyManagement>
</project>

View File

@ -0,0 +1,35 @@
<!--
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>testReportBadNonDependencyProjectArtifactVersion</artifactId>
<version>1</version>
<build>
<extensions>
<extension>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>[3.1,</version>
</extension>
</extensions>
</build>
</project>

View File

@ -0,0 +1,41 @@
<!--
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>testReportErrorCreatingArtifactRepository</artifactId>
<version>1</version>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
</dependency>
</dependencies>
<repositories>
<repository>
<id>test</id>
<url>http://www.google.com</url>
<layout>nothing</layout>
</repository>
</repositories>
</project>

View File

@ -0,0 +1,41 @@
<!--
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>testReportErrorCreatingDeploymentArtifactRepository</artifactId>
<version>1</version>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
</dependency>
</dependencies>
<distributionManagement>
<repository>
<id>test</id>
<url>http://www.google.com</url>
<layout>nothing</layout>
</repository>
</distributionManagement>
</project>

View File

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?><project>
<modelVersion>4.0.0</modelVersion>
<groupId>org.apache.maven.errortest</groupId>
<artifactId>module</artifactId>
<version>1</version>
</project>

View File

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?><project>
<modelVersion>4.0.0</modelVersion>
<groupId>org.apache.maven.errortest</groupId>
<artifactId>module</artifactId>
<version>1</version>
</project>

View File

@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?><project>
<modelVersion>4.0.0</modelVersion>
<groupId>org.apache.maven.errortest</groupId>
<artifactId>testReportProjectCollision</artifactId>
<version>1</version>
<packaging>pom</packaging>
<modules>
<module>mod1</module>
<module>mod2</module>
</modules>
</project>

View File

@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?><project>
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.apache.maven.errortest</groupId>
<artifactId>testReportProjectCycle</artifactId>
<version>1</version>
</parent>
<groupId>org.apache.maven.errortest</groupId>
<artifactId>testReportProjectCycle-dep</artifactId>
</project>

View File

@ -0,0 +1,19 @@
<?xml version="1.0" encoding="UTF-8"?><project>
<modelVersion>4.0.0</modelVersion>
<groupId>org.apache.maven.errortest</groupId>
<artifactId>testReportProjectCycle</artifactId>
<version>1</version>
<packaging>pom</packaging>
<modules>
<module>dep</module>
</modules>
<dependencies>
<dependency>
<groupId>org.apache.maven.errortest</groupId>
<artifactId>testReportProjectCycle-dep</artifactId>
<version>1</version>
</dependency>
</dependencies>
</project>

View File

@ -2,11 +2,10 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.apache.maven.test.error</groupId>
<artifactId>test-mojo-failure</artifactId>
<artifactId>testReportProjectMojoFailureException</artifactId>
<packaging>jar</packaging>
<version>1</version>
<name>test-mojo-failure</name>
<url>http://maven.apache.org</url>
<dependencies>
<dependency>
<groupId>junit</groupId>

View File

@ -0,0 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?><project>
<modelVersion>4.0.0</modelVersion>
<groupId>org.apache.maven.errortest</groupId>
<artifactId>testReportProjectValidationFailure</artifactId>
<version>1</version>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
</dependency>
</dependencies>
</project>

View File

@ -0,0 +1,603 @@
package org.apache.maven.error;
import org.apache.maven.NoGoalsSpecifiedException;
import org.apache.maven.ProjectCycleException;
import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.InvalidRepositoryException;
import org.apache.maven.artifact.UnknownRepositoryLayoutException;
import org.apache.maven.artifact.metadata.ArtifactMetadataRetrievalException;
import org.apache.maven.artifact.repository.ArtifactRepository;
import org.apache.maven.artifact.resolver.ArtifactNotFoundException;
import org.apache.maven.artifact.resolver.ArtifactResolutionException;
import org.apache.maven.artifact.resolver.ArtifactResolutionResult;
import org.apache.maven.artifact.versioning.ArtifactVersion;
import org.apache.maven.artifact.versioning.InvalidVersionSpecificationException;
import org.apache.maven.errors.DefaultCoreErrorReporter;
import org.apache.maven.execution.MavenExecutionRequest;
import org.apache.maven.execution.MavenSession;
import org.apache.maven.execution.RealmManagementException;
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.TaskValidationResult;
import org.apache.maven.lifecycle.model.MojoBinding;
import org.apache.maven.model.DeploymentRepository;
import org.apache.maven.model.Model;
import org.apache.maven.model.Parent;
import org.apache.maven.model.Plugin;
import org.apache.maven.model.Profile;
import org.apache.maven.model.Repository;
import org.apache.maven.plugin.MojoExecution;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.MojoFailureException;
import org.apache.maven.plugin.PluginConfigurationException;
import org.apache.maven.plugin.PluginExecutionException;
import org.apache.maven.plugin.PluginManagerException;
import org.apache.maven.plugin.PluginNotFoundException;
import org.apache.maven.plugin.PluginParameterException;
import org.apache.maven.plugin.descriptor.Parameter;
import org.apache.maven.plugin.loader.PluginLoaderException;
import org.apache.maven.plugin.version.PluginVersionNotFoundException;
import org.apache.maven.plugin.version.PluginVersionResolutionException;
import org.apache.maven.profiles.activation.ProfileActivationContext;
import org.apache.maven.profiles.activation.ProfileActivationException;
import org.apache.maven.profiles.activation.ProfileActivator;
import org.apache.maven.project.DuplicateProjectException;
import org.apache.maven.project.InvalidProjectModelException;
import org.apache.maven.project.InvalidProjectVersionException;
import org.apache.maven.project.MavenProject;
import org.apache.maven.project.ProjectBuildingException;
import org.apache.maven.project.artifact.InvalidDependencyVersionException;
import org.apache.maven.project.build.model.ModelAndFile;
import org.apache.maven.project.interpolation.ModelInterpolationException;
import org.apache.maven.project.path.PathTranslator;
import org.apache.maven.reactor.MavenExecutionException;
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.logging.Logger;
import org.codehaus.plexus.util.xml.pull.XmlPullParserException;
import java.io.File;
import java.io.IOException;
import java.util.List;
import java.util.Map;
public class DummyCoreErrorReporter
extends DefaultCoreErrorReporter
{
public void handleSuperPomBuildingError( ProjectBuildingException exception )
{
}
public void reportAggregatedMojoFailureException( MavenSession session,
MojoBinding binding,
MojoFailureException cause )
{
}
public void reportAttemptToOverrideUneditableMojoParameter( Parameter currentParameter,
MojoBinding binding,
MavenProject project,
MavenSession session,
MojoExecution exec,
PathTranslator translator,
Logger logger,
PluginConfigurationException cause )
{
}
public void reportErrorApplyingMojoConfiguration( MojoBinding binding,
MavenProject project,
PlexusConfiguration config,
PluginConfigurationException cause )
{
}
public void reportErrorConfiguringExtensionPluginRealm( Plugin plugin,
Model originModel,
List remoteRepos,
MavenExecutionRequest request,
PluginManagerException cause )
{
}
public void reportErrorFormulatingBuildPlan( List tasks,
MavenProject configuringProject,
String targetDescription,
LifecycleException cause )
{
}
public void reportErrorInterpolatingModel( Model model,
Map inheritedValues,
File pomFile,
MavenExecutionRequest request,
ModelInterpolationException cause )
{
}
public void reportErrorLoadingPlugin( MojoBinding binding,
MavenProject project,
PluginLoaderException cause )
{
}
public void reportErrorManagingRealmForExtension( Artifact extensionArtifact,
Artifact projectArtifact,
List remoteRepos,
MavenExecutionRequest request,
RealmManagementException cause )
{
}
public void reportErrorManagingRealmForExtensionPlugin( Plugin plugin,
Model originModel,
List remoteRepos,
MavenExecutionRequest request,
RealmManagementException cause )
{
}
public void reportErrorResolvingExtensionDependencies( Artifact extensionArtifact,
Artifact projectArtifact,
List remoteRepos,
MavenExecutionRequest request,
ArtifactResolutionResult resolutionResult,
ExtensionManagerException err )
{
}
public void reportErrorResolvingExtensionDirectDependencies( Artifact extensionArtifact,
Artifact projectArtifact,
List remoteRepos,
MavenExecutionRequest request,
ArtifactMetadataRetrievalException cause )
{
}
public void reportErrorSearchingforCompatibleExtensionPluginVersion( Plugin plugin,
Model originModel,
List remoteRepos,
MavenExecutionRequest request,
String requiredMavenVersion,
String currentMavenVersion,
InvalidVersionSpecificationException cause )
{
}
public void reportExtensionPluginArtifactNotFound( Plugin plugin,
Model originModel,
List remoteRepos,
MavenExecutionRequest request,
PluginNotFoundException cause )
{
}
public void reportExtensionPluginVersionNotFound( Plugin plugin,
Model originModel,
List remoteRepos,
MavenExecutionRequest request,
PluginVersionNotFoundException cause )
{
}
public void reportIncompatibleMavenVersionForExtensionPlugin( Plugin plugin,
Model originModel,
List remoteRepos,
MavenExecutionRequest request,
String requiredMavenVersion,
String currentMavenVersion,
PluginVersionResolutionException err )
{
}
public void reportInvalidDependencyVersionInExtensionPluginPOM( Plugin plugin,
Model originModel,
List remoteRepos,
MavenExecutionRequest request,
InvalidDependencyVersionException cause )
{
}
public void reportInvalidMavenVersion( MavenProject project,
ArtifactVersion mavenVersion,
MavenExecutionException err )
{
}
public void reportInvalidPluginExecutionEnvironment( MojoBinding binding,
MavenProject project,
PluginExecutionException cause )
{
}
public void reportLifecycleLoaderErrorWhileValidatingTask( MavenSession session,
MavenProject rootProject,
LifecycleLoaderException cause,
TaskValidationResult result )
{
}
public void reportLifecycleSpecErrorWhileValidatingTask( MavenSession session,
MavenProject rootProject,
LifecycleSpecificationException cause,
TaskValidationResult result )
{
}
public void reportMissingArtifactWhileAddingExtensionPlugin( Plugin plugin,
Model originModel,
List remoteRepos,
MavenExecutionRequest request,
ArtifactNotFoundException cause )
{
}
public void reportMissingPluginDescriptor( MojoBinding binding,
MavenProject project,
LifecycleExecutionException err )
{
}
public void reportMissingRequiredMojoParameter( MojoBinding binding,
MavenProject project,
List invalidParameters,
PluginParameterException err )
{
}
public void reportMojoExecutionException( MojoBinding binding,
MavenProject project,
MojoExecutionException cause )
{
}
public void reportMojoLookupError( MojoBinding binding,
MavenProject project,
ComponentLookupException cause )
{
}
public void reportNoGoalsSpecifiedException( MavenProject rootProject,
NoGoalsSpecifiedException error )
{
}
public void reportPluginErrorWhileValidatingTask( MavenSession session,
MavenProject rootProject,
PluginLoaderException cause,
TaskValidationResult result )
{
}
public void reportPomFileCanonicalizationError( File pomFile,
IOException cause )
{
}
public void reportPomFileScanningError( File basedir,
String includes,
String excludes,
IOException cause )
{
}
public void reportProjectCycle( ProjectCycleException error )
{
}
public void reportProjectDependenciesNotFound( MavenProject project,
String scope,
ArtifactNotFoundException cause )
{
}
public void reportProjectDependenciesUnresolvable( MavenProject project,
String scope,
ArtifactResolutionException cause )
{
}
public void reportProjectDependencyArtifactNotFound( MavenProject project,
Artifact artifact,
ArtifactNotFoundException cause )
{
}
public void reportProjectDependencyArtifactUnresolvable( MavenProject project,
Artifact artifact,
ArtifactResolutionException cause )
{
}
public void reportProjectMojoFailureException( MavenSession session,
MojoBinding binding,
MojoFailureException cause )
{
}
public void reportReflectionErrorWhileEvaluatingMojoParameter( Parameter currentParameter,
MojoBinding binding,
MavenProject project,
String expression,
Exception cause )
{
}
public void reportUnresolvableArtifactWhileAddingExtensionPlugin( Plugin plugin,
Model originModel,
List remoteRepos,
MavenExecutionRequest request,
ArtifactResolutionException cause )
{
}
public void reportUnresolvableExtensionPluginPOM( Plugin plugin,
Model originModel,
List remoteRepos,
MavenExecutionRequest request,
ArtifactMetadataRetrievalException cause )
{
}
public void reportUseOfBannedMojoParameter( Parameter currentParameter,
MojoBinding binding,
MavenProject project,
String expression,
String altExpression,
ExpressionEvaluationException err )
{
}
public void reportActivatorError( ProfileActivator activator,
String projectId,
File pomFile,
Profile profile,
ProfileActivationContext context,
ProfileActivationException cause )
{
}
public void reportActivatorLookupError( String projectId,
File pomFile,
Profile profile,
ComponentLookupException cause )
{
}
public void reportBadDependencyVersion( MavenProject project,
File pomFile,
InvalidDependencyVersionException cause )
{
}
public void reportBadManagedDependencyVersion( MavenProject projectBeingBuilt,
File pomFile,
InvalidDependencyVersionException cause )
{
}
public void reportBadNonDependencyProjectArtifactVersion( MavenProject project,
File pomFile,
InvalidProjectVersionException cause )
{
}
public void reportErrorCreatingArtifactRepository( MavenProject project,
File pomFile,
Repository repo,
UnknownRepositoryLayoutException cause,
boolean isPluginRepo )
{
}
public void reportErrorCreatingDeploymentArtifactRepository( MavenProject project,
File pomFile,
DeploymentRepository repo,
UnknownRepositoryLayoutException cause )
{
}
public void reportErrorInterpolatingModel( MavenProject project,
File pomFile,
ModelInterpolationException cause )
{
}
public void reportErrorLoadingExternalProfilesFromFile( Model model,
File pomFile,
File projectDir,
IOException cause )
{
}
public void reportErrorLoadingExternalProfilesFromFile( Model model,
File pomFile,
File projectDir,
XmlPullParserException cause )
{
}
public void reportErrorParsingParentProjectModel( ModelAndFile childInfo,
File parentPomFile,
XmlPullParserException cause )
{
}
public void reportErrorParsingParentProjectModel( ModelAndFile childInfo,
File parentPomFile,
IOException cause )
{
}
public void reportErrorParsingProjectModel( String projectId,
File pomFile,
XmlPullParserException cause )
{
}
public void reportErrorParsingProjectModel( String projectId,
File pomFile,
IOException cause )
{
}
public void reportInvalidRepositoryWhileGettingRepositoriesFromProfiles( Repository repo,
String projectId,
File pomFile,
InvalidRepositoryException cause )
{
}
public void reportParentPomArtifactNotFound( Parent parentRef,
ArtifactRepository localRepo,
List remoteRepos,
String childId,
File childPomFile,
ArtifactNotFoundException cause )
{
}
public void reportParentPomArtifactUnresolvable( Parent parentRef,
ArtifactRepository localRepo,
List remoteRepos,
String childId,
File childPomFile,
ArtifactResolutionException cause )
{
}
public void reportProjectCollision( List allProjectInstances,
DuplicateProjectException err )
{
}
public void reportProjectValidationFailure( MavenProject project,
File pomFile,
InvalidProjectModelException error )
{
}
}

View File

@ -1,5 +1,10 @@
package org.apache.maven.error;
import org.apache.commons.httpclient.HttpClient;
import org.apache.commons.httpclient.HttpConnectionManager;
import org.apache.commons.httpclient.HttpException;
import org.apache.commons.httpclient.HttpStatus;
import org.apache.commons.httpclient.methods.GetMethod;
import org.apache.maven.embedder.Configuration;
import org.apache.maven.embedder.DefaultConfiguration;
import org.apache.maven.embedder.MavenEmbedder;
@ -7,6 +12,8 @@ import org.apache.maven.embedder.MavenEmbedderConsoleLogger;
import org.apache.maven.errors.CoreErrorReporter;
import org.apache.maven.execution.DefaultMavenExecutionRequest;
import org.apache.maven.execution.MavenExecutionRequest;
import org.apache.maven.execution.MavenExecutionResult;
import org.apache.maven.model.io.xpp3.MavenXpp3Reader;
import org.codehaus.plexus.logging.Logger;
import org.codehaus.plexus.util.FileUtils;
import org.codehaus.plexus.util.xml.pull.XmlPullParserException;
@ -14,8 +21,12 @@ import org.easymock.MockControl;
import java.io.File;
import java.io.IOException;
import java.io.PrintWriter;
import java.io.StringWriter;
import java.net.URISyntaxException;
import java.util.Arrays;
import java.util.Collections;
import java.util.Iterator;
import junit.framework.TestCase;
@ -31,6 +42,10 @@ public class ErrorReporterPointcutTest
private String basedir;
private static boolean isOffline;
private static boolean offlineIsSet = false;
public void setUp()
throws Exception
{
@ -57,10 +72,68 @@ public class ErrorReporterPointcutTest
maven = new MavenEmbedder( configuration );
}
private boolean checkOnline()
{
if ( !offlineIsSet )
{
HttpClient client = new HttpClient();
GetMethod get = new GetMethod(
"http://repo1.maven.org/maven2/org/apache/maven/maven-core/2.0/maven-core-2.0.pom" );
HttpConnectionManager mgr = client.getHttpConnectionManager();
mgr.getParams().setConnectionTimeout( 1 );
try
{
int result = client.executeMethod( get );
if ( result == HttpStatus.SC_OK )
{
new MavenXpp3Reader().read( get.getResponseBodyAsStream() );
isOffline = false;
}
}
catch ( HttpException e )
{
System.out.println( "System is offline" );
isOffline = true;
}
catch ( IOException e )
{
System.out.println( "System is offline" );
isOffline = true;
}
catch ( XmlPullParserException e )
{
System.out.println( "System is offline" );
isOffline = true;
}
finally
{
offlineIsSet = true;
}
}
if ( isOffline )
{
String method = getTestMethodName();
System.out.println( "Test: " + method
+ " requires an access to the Maven central repository. SKIPPING." );
return false;
}
return true;
}
private String getTestMethodName()
{
String method = new Throwable().getStackTrace()[2].getMethodName();
return method;
}
private File prepareProjectDir()
throws URISyntaxException, IOException
{
String method = new Throwable().getStackTrace()[1].getMethodName();
String method = getTestMethodName();
String resource = "error-reporting-projects/" + method;
@ -75,7 +148,8 @@ public class ErrorReporterPointcutTest
FileUtils.deleteDirectory( targetDirectory );
}
catch ( IOException e )
{}
{
}
}
FileUtils.copyDirectoryStructure( testDirectory, targetDirectory );
@ -108,10 +182,69 @@ public class ErrorReporterPointcutTest
}
// FIXME: Fix the offline detection for this one!
public void testReportAggregatedMojoFailureException()
throws URISyntaxException, IOException
{
// TODO Auto-generated method stub
if ( !checkOnline() )
{
return;
}
File projectDir = prepareProjectDir();
buildTestAccessory( new File( projectDir, "plugin" ) );
File basedir = new File( projectDir, "project" );
reporter.reportAggregatedMojoFailureException( null, null, null );
reporterCtl.setMatcher( MockControl.ALWAYS_MATCHER );
reporterCtl.setVoidCallable();
reporterCtl.replay();
MavenExecutionRequest request = new DefaultMavenExecutionRequest().setBaseDirectory( basedir )
.setShowErrors( true )
.setErrorReporter( reporter )
.setGoals( Arrays.asList( new String[] {
"org.apache.maven.errortest:testReportAggregatedMojoFailureException-maven-plugin:1:test"
} ) );
maven.execute( request );
reporterCtl.verify();
}
private void buildTestAccessory( File basedir )
{
MavenExecutionRequest request = new DefaultMavenExecutionRequest().setBaseDirectory( basedir )
.setShowErrors( true )
.setErrorReporter( new DummyCoreErrorReporter() )
.setGoals( Arrays.asList( new String[] {
"clean",
"install"
} ) );
MavenExecutionResult result = maven.execute( request );
if ( result.hasExceptions() )
{
StringWriter writer = new StringWriter();
PrintWriter pWriter = new PrintWriter( writer );
writer.write( "Failed to build project in: " );
writer.write( basedir.getPath() );
writer.write( "\nEncountered the following errors:" );
for ( Iterator it = result.getExceptions().iterator(); it.hasNext(); )
{
Throwable error = (Throwable) it.next();
writer.write( "\n\n" );
error.printStackTrace( pWriter );
}
fail( writer.toString() );
}
}
public void testReportAttemptToOverrideUneditableMojoParameter()
@ -277,8 +410,19 @@ public class ErrorReporterPointcutTest
public void testReportNoGoalsSpecifiedException()
{
// TODO Auto-generated method stub
reporter.reportNoGoalsSpecifiedException( null, null );
reporterCtl.setMatcher( MockControl.ALWAYS_MATCHER );
reporterCtl.setVoidCallable();
reporterCtl.replay();
MavenExecutionRequest request = new DefaultMavenExecutionRequest().setShowErrors( true )
.setErrorReporter( reporter )
.setGoals( Collections.EMPTY_LIST );
maven.execute( request );
reporterCtl.verify();
}
public void testReportPluginErrorWhileValidatingTask()
@ -300,9 +444,26 @@ public class ErrorReporterPointcutTest
}
public void testReportProjectCycle()
throws URISyntaxException, IOException
{
// TODO Auto-generated method stub
File projectDir = prepareProjectDir();
reporter.reportProjectCycle( 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();
}
public void testReportProjectDependenciesNotFound()
@ -377,82 +538,149 @@ public class ErrorReporterPointcutTest
}
public void clearErrors()
// FIXME: How can I test this when it's masked by reportActivatorErrorWhileGettingRepositoriesFromProfiles?
public void testReportActivatorError()
throws URISyntaxException, IOException
{
// TODO Auto-generated method stub
File projectDir = prepareProjectDir();
reporter.reportActivatorError( null, null, null, 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[] {
"initialize"
} ) );
maven.execute( request );
reporterCtl.verify();
}
public Throwable findReportedException( Throwable error )
{
// TODO Auto-generated method stub
return null;
}
public String getFormattedMessage( Throwable error )
{
// TODO Auto-generated method stub
return null;
}
public Throwable getRealCause( Throwable error )
{
// TODO Auto-generated method stub
return null;
}
public void testReportActivatorErrorWhileApplyingProfiles()
{
// TODO Auto-generated method stub
}
public void testReportActivatorErrorWhileGettingRepositoriesFromProfiles()
{
// TODO Auto-generated method stub
}
public void testReportActivatorLookupErrorWhileApplyingProfiles()
{
// TODO Auto-generated method stub
}
public void testReportActivatorLookupErrorWhileGettingRepositoriesFromProfiles()
public void testReportActivatorLookupError()
{
// TODO Auto-generated method stub
}
public void testReportBadDependencyVersion()
throws URISyntaxException, IOException
{
// TODO Auto-generated method stub
File projectDir = prepareProjectDir();
reporter.reportBadDependencyVersion( 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[] {
"compile"
} ) );
maven.execute( request );
reporterCtl.verify();
}
public void testReportBadManagedDependencyVersion()
throws URISyntaxException, IOException
{
// TODO Auto-generated method stub
File projectDir = prepareProjectDir();
reporter.reportBadManagedDependencyVersion( 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[] {
"initialize"
} ) );
maven.execute( request );
reporterCtl.verify();
}
public void testReportBadNonDependencyProjectArtifactVersion()
throws URISyntaxException, IOException
{
// TODO Auto-generated method stub
File projectDir = prepareProjectDir();
reporter.reportBadNonDependencyProjectArtifactVersion( 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[] {
"initialize"
} ) );
maven.execute( request );
reporterCtl.verify();
}
public void testReportErrorCreatingArtifactRepository()
throws URISyntaxException, IOException
{
// TODO Auto-generated method stub
File projectDir = prepareProjectDir();
reporter.reportErrorCreatingArtifactRepository( null, 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[] {
"compile"
} ) );
maven.execute( request );
reporterCtl.verify();
}
public void testReportErrorCreatingDeploymentArtifactRepository()
throws URISyntaxException, IOException
{
// TODO Auto-generated method stub
File projectDir = prepareProjectDir();
reporter.reportErrorCreatingDeploymentArtifactRepository( null, 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[] {
"compile"
} ) );
maven.execute( request );
reporterCtl.verify();
}
public void testReportErrorInterpolatingModel_UsingModelInstance()
@ -520,7 +748,9 @@ public class ErrorReporterPointcutTest
reporterCtl.replay();
MavenExecutionRequest request = new DefaultMavenExecutionRequest().setPom( new File( projectDir, "pom.xml" ) )
MavenExecutionRequest request = new DefaultMavenExecutionRequest().setPom( new File(
projectDir,
"pom.xml" ) )
.setShowErrors( true )
.setErrorReporter( reporter )
.setGoals( Arrays.asList( new String[] {
@ -551,15 +781,49 @@ public class ErrorReporterPointcutTest
}
public void testReportProjectCollision()
throws URISyntaxException, IOException
{
// TODO Auto-generated method stub
File projectDir = prepareProjectDir();
reporter.reportProjectCollision( 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[] {
"initialize"
} ) );
maven.execute( request );
reporterCtl.verify();
}
public void testReportProjectValidationFailure()
throws URISyntaxException, IOException
{
// TODO Auto-generated method stub
File projectDir = prepareProjectDir();
reporter.reportProjectValidationFailure( 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[] {
"initialize"
} ) );
maven.execute( request );
reporterCtl.verify();
}
}

View File

@ -12,6 +12,7 @@ import org.apache.maven.model.Repository;
import org.apache.maven.model.DeploymentRepository;
import org.apache.maven.artifact.repository.ArtifactRepository;
import org.apache.maven.MavenTools;
import org.apache.maven.project.build.model.DefaultModelLineageBuilder;
import org.apache.maven.project.MavenProject;
import org.apache.maven.project.DefaultMavenProjectBuilder;
import org.apache.maven.project.InvalidProjectModelException;
@ -19,6 +20,7 @@ import org.apache.maven.project.ProjectBuildingException;
import java.io.File;
import java.util.Set;
import java.util.List;
public privileged aspect PBEDerivativeReporterAspect
extends AbstractProjectErrorReporterAspect
@ -34,6 +36,10 @@ public privileged aspect PBEDerivativeReporterAspect
execution( private MavenProject DefaultMavenProjectBuilder.processProjectLogic( MavenProject, File, .. ) )
&& args( project, pomFile, .. );
private pointcut within_pbldr_processProjectLogic( MavenProject project, File pomFile ):
withincode( private MavenProject DefaultMavenProjectBuilder.processProjectLogic( MavenProject, File, .. ) )
&& args( project, pomFile, .. );
private pointcut within_DefaultMavenProjectBuilder():
!withincode( * DefaultProfileAdvisor.*( .. ) )
&& notWithinAspect();
@ -63,8 +69,6 @@ public privileged aspect PBEDerivativeReporterAspect
call( ArtifactRepository MavenTools+.buildArtifactRepository( Repository ) )
&& args( repo );
private boolean processingPluginRepositories = false;
// =========================================================================
// Call Stack:
// =========================================================================
@ -82,31 +86,31 @@ public privileged aspect PBEDerivativeReporterAspect
after( MavenProject project, File pomFile, Repository repo ) throwing( UnknownRepositoryLayoutException cause ):
mavenTools_buildArtifactRepository( repo )
&& cflow( pbldr_processProjectLogic( project, pomFile ) )
&& within_DefaultMavenProjectBuilder()
{
getReporter().reportErrorCreatingArtifactRepository( project, pomFile, repo, cause, processingPluginRepositories );
getReporter().reportErrorCreatingArtifactRepository( project.getId(), pomFile, repo, cause );
}
after():
call( * Model+.getPluginRepositories() )
&& cflow( pbldr_processProjectLogic( MavenProject, File ) )
&& within_DefaultMavenProjectBuilder()
{
processingPluginRepositories = true;
}
private pointcut mlbldr_updateRepositorySet( Model model, File pomFile ):
execution( List DefaultModelLineageBuilder.updateRepositorySet( Model, *, File, .. ) )
&& args( model, *, pomFile, .. );
after():
call( * Model+.getRepositories() )
&& cflow( pbldr_processProjectLogic( MavenProject, File ) )
&& within_DefaultMavenProjectBuilder()
// =========================================================================
// Call Stack:
// =========================================================================
// ...
// --> DefaultModelLineageBuilder.buildModelLineage(..)
// --> DefaultModelLineageBuilder.resumeBuildingModelLineage(..)
// --> DefaultModelLineageBuilder.updateRepositorySet(..) (private)
// --> DefaultMavenTools.buildArtifactRepositories(..)
// --> DefaultMavenTools.buildArtifactRepository(..)
// <------ UnknownRepositoryLayoutException
// <------ ProjectBuildingException
// =========================================================================
after( Model model, File pomFile, Repository repo ) throwing( UnknownRepositoryLayoutException cause ):
mavenTools_buildArtifactRepository( repo )
&& cflow( mlbldr_updateRepositorySet( model, pomFile ) )
{
processingPluginRepositories = false;
}
after( MavenProject project, File pomFile ):
pbldr_processProjectLogic( project, pomFile )
{
processingPluginRepositories = false;
getReporter().reportErrorCreatingArtifactRepository( model.getId(), pomFile, repo, cause );
}
// ModelInterpolationException

View File

@ -72,7 +72,7 @@ public privileged aspect ProfileErrorReporterAspect
throwing( ComponentLookupException cause ):
applyActivatedProfiles_ComponentLookupException( model, pomFile, profile )
{
getReporter().reportActivatorLookupErrorWhileApplyingProfiles( model, pomFile, profile, cause );
getReporter().reportActivatorLookupError( model.getId(), pomFile, profile, cause );
}
protected pointcut profileActivatorCall( ProfileActivator activator ):
@ -107,7 +107,7 @@ public privileged aspect ProfileErrorReporterAspect
throwing( ProfileActivationException cause ):
applyActivatedProfiles_ActivatorThrown( activator, model, pomFile, profile, context )
{
getReporter().reportActivatorErrorWhileApplyingProfiles( activator, model, pomFile, profile, context, cause );
getReporter().reportActivatorError( activator, model.getId(), pomFile, profile, context, cause );
}
private pointcut pAdv_loadExternalProjectProfiles( Model model, File pomFile ):
@ -189,7 +189,7 @@ public privileged aspect ProfileErrorReporterAspect
throwing( ComponentLookupException cause ):
getArtifactRepositoriesFromActiveProfiles_ComponentLookupException( projectId, pomFile, profile )
{
getReporter().reportActivatorLookupErrorWhileGettingRepositoriesFromProfiles( projectId, pomFile, profile, cause );
getReporter().reportActivatorLookupError( projectId, pomFile, profile, cause );
}
private pointcut getArtifactRepositoriesFromActiveProfiles_ActivatorThrown( ProfileActivator activator,
@ -220,7 +220,7 @@ public privileged aspect ProfileErrorReporterAspect
throwing( ProfileActivationException cause ):
getArtifactRepositoriesFromActiveProfiles_ActivatorThrown( activator, projectId, pomFile, profile, context )
{
getReporter().reportActivatorErrorWhileGettingRepositoriesFromProfiles( activator, projectId, pomFile, profile, context, cause );
getReporter().reportActivatorError( activator, projectId, pomFile, profile, context, cause );
}
private pointcut getArtifactRepositoriesFromActiveProfiles_InvalidRepository( Repository repo,

View File

@ -915,8 +915,15 @@ public class DefaultMavenProjectBuilder
validateModel( model, pomFile );
try
{
project.setRemoteArtifactRepositories(
mavenTools.buildArtifactRepositories( model.getRepositories() ) );
}
catch( Exception e )
{
e.printStackTrace();
}
String projectId = safeVersionlessKey( model.getGroupId(), model.getArtifactId() );

View File

@ -114,46 +114,7 @@ public class DefaultProjectErrorReporter
/**
* @see org.apache.maven.project.error.ProjectErrorReporter#reportActivatorErrorWhileApplyingProfiles(org.apache.maven.profiles.activation.ProfileActivator, org.apache.maven.model.Model, java.io.File, org.apache.maven.model.Profile, org.apache.maven.profiles.activation.ProfileActivationContext, org.apache.maven.profiles.activation.ProfileActivationException)
*/
public void reportActivatorErrorWhileApplyingProfiles( ProfileActivator activator,
Model model,
File pomFile,
Profile profile,
ProfileActivationContext context,
ProfileActivationException cause )
{
StringWriter writer = new StringWriter();
writer.write( NEWLINE );
writer.write( "Profile activator: " );
writer.write( activator.getClass().getName() );
writer.write( " experienced an error while processing profile:" );
writer.write( NEWLINE );
writer.write( NEWLINE );
writer.write( profile.getId() );
writer.write( " (source: " );
writer.write( profile.getSource() );
writer.write( ")" );
writer.write( NEWLINE );
writer.write( NEWLINE );
writer.write( "Error message: " );
writer.write( NEWLINE );
writer.write( cause.getMessage() );
addStandardInfo( model.getId(), pomFile, writer );
addTips( ProjectErrorTips.getTipsForActivatorErrorWhileApplyingProfiles( activator,
model,
pomFile,
profile,
context,
cause ), writer );
registerBuildError( cause, writer.toString(), cause.getCause() );
}
/**
* @see org.apache.maven.project.error.ProjectErrorReporter#reportActivatorErrorWhileGettingRepositoriesFromProfiles(org.apache.maven.profiles.activation.ProfileActivator, java.lang.String, java.io.File, org.apache.maven.model.Profile, org.apache.maven.profiles.activation.ProfileActivationContext, org.apache.maven.profiles.activation.ProfileActivationException)
*/
public void reportActivatorErrorWhileGettingRepositoriesFromProfiles( ProfileActivator activator,
public void reportActivatorError( ProfileActivator activator,
String projectId,
File pomFile,
Profile profile,
@ -179,55 +140,20 @@ public class DefaultProjectErrorReporter
writer.write( cause.getMessage() );
addStandardInfo( projectId, pomFile, writer );
addTips( ProjectErrorTips.getTipsForActivatorErrorWhileGettingRepositoriesFromProfiles( activator,
addTips( ProjectErrorTips.getTipsForActivatorError( activator,
projectId,
pomFile,
profile,
context,
cause ),
writer );
cause ), writer );
registerBuildError( cause, writer.toString(), cause.getCause() );
}
/**
* @see org.apache.maven.project.error.ProjectErrorReporter#reportActivatorLookupErrorWhileApplyingProfiles(org.apache.maven.model.Model, java.io.File, org.apache.maven.model.Profile, org.codehaus.plexus.component.repository.exception.ComponentLookupException)
* @see org.apache.maven.project.error.ProjectErrorReporter#reportActivatorLookupError(java.lang.String, java.io.File, org.apache.maven.model.Profile, org.codehaus.plexus.component.repository.exception.ComponentLookupException)
*/
public void reportActivatorLookupErrorWhileApplyingProfiles( Model model,
File pomFile,
Profile profile,
ComponentLookupException cause )
{
StringWriter writer = new StringWriter();
writer.write( NEWLINE );
writer.write( "Error retrieving profile-activator component while processing profile:" );
writer.write( NEWLINE );
writer.write( NEWLINE );
writer.write( profile.getId() );
writer.write( " (source: " );
writer.write( profile.getSource() );
writer.write( ")" );
writer.write( NEWLINE );
writer.write( NEWLINE );
writer.write( "Error message: " );
writer.write( NEWLINE );
writer.write( cause.getMessage() );
addStandardInfo( model.getId(), pomFile, writer );
addTips( ProjectErrorTips.getTipsForActivatorLookupErrorWhileApplyingProfiles( model,
pomFile,
profile,
cause ),
writer );
registerBuildError( cause, writer.toString(), cause.getCause() );
}
/**
* @see org.apache.maven.project.error.ProjectErrorReporter#reportActivatorLookupErrorWhileGettingRepositoriesFromProfiles(java.lang.String, java.io.File, org.apache.maven.model.Profile, org.codehaus.plexus.component.repository.exception.ComponentLookupException)
*/
public void reportActivatorLookupErrorWhileGettingRepositoriesFromProfiles( String projectId,
public void reportActivatorLookupError( String projectId,
File pomFile,
Profile profile,
ComponentLookupException cause )
@ -249,11 +175,10 @@ public class DefaultProjectErrorReporter
writer.write( cause.getMessage() );
addStandardInfo( projectId, pomFile, writer );
addTips( ProjectErrorTips.getTipsForActivatorLookupErrorWhileGettingRepositoriesFromProfiles( projectId,
addTips( ProjectErrorTips.getTipsForActivatorLookupError( projectId,
pomFile,
profile,
cause ),
writer );
cause ), writer );
registerBuildError( cause, writer.toString(), cause.getCause() );
}
@ -385,11 +310,10 @@ public class DefaultProjectErrorReporter
}
}
public void reportErrorCreatingArtifactRepository( MavenProject project,
public void reportErrorCreatingArtifactRepository( String projectId,
File pomFile,
Repository repo,
UnknownRepositoryLayoutException cause,
boolean isPluginRepo )
UnknownRepositoryLayoutException cause )
{
StringWriter writer = new StringWriter();
@ -405,8 +329,8 @@ public class DefaultProjectErrorReporter
writer.write( cause.getMessage() );
writer.write( NEWLINE );
addStandardInfo( project.getId(), pomFile, writer );
addTips( ProjectErrorTips.getTipsForInvalidRepositorySpec( repo, project.getId(), pomFile, cause ),
addStandardInfo( projectId, pomFile, writer );
addTips( ProjectErrorTips.getTipsForInvalidRepositorySpec( repo, projectId, pomFile, cause ),
writer );
registerBuildError( cause, writer.toString() );

View File

@ -45,27 +45,6 @@ public interface ProjectErrorReporter
* DefaultProfileAdvisor.applyActivatedProfiles(..)
* DefaultProfileAdvisor.applyActivatedExternalProfiles(..)
* --&gt; DefaultProfileAdvisor.applyActivatedProfiles(..) (private)
* --&gt; DefaultProfileManager.getActiveProfiles(..)
* --&gt; DefaultProfileManager.isActive(..) (private)
* --&gt; ProfileActivator.canDetermineActivation(..)
* --&gt; ProfileActivator.isActive(..)
* &lt;------ ProfileActivationException
* &lt;------ ProjectBuildingException
* </pre>
*/
void reportActivatorErrorWhileApplyingProfiles( ProfileActivator activator,
Model model,
File pomFile,
Profile profile,
ProfileActivationContext context,
ProfileActivationException cause );
/**
* <b>Call Stack:</b>
* <br/>
* <pre>
* DefaultProfileAdvisor.applyActivatedProfiles(..)
* DefaultProfileAdvisor.applyActivatedExternalProfiles(..)
* --&gt; DefaultProfileAdvisor.getArtifactRepositoriesFromActiveProfiles(..)
* --&gt; DefaultProfileManager.getActiveProfiles(..)
* --&gt; DefaultProfileManager.isActive(..) (private)
@ -75,7 +54,7 @@ public interface ProjectErrorReporter
* &lt;------ ProjectBuildingException
* </pre>
*/
void reportActivatorErrorWhileGettingRepositoriesFromProfiles( ProfileActivator activator,
void reportActivatorError( ProfileActivator activator,
String projectId,
File pomFile,
Profile profile,
@ -89,25 +68,6 @@ public interface ProjectErrorReporter
* DefaultProfileAdvisor.applyActivatedProfiles(..)
* DefaultProfileAdvisor.applyActivatedExternalProfiles(..)
* --&gt; DefaultProfileAdvisor.applyActivatedProfiles(..) (private)
* --&gt; DefaultProfileManager.getActiveProfiles(..)
* --&gt; DefaultProfileManager.isActive(..) (private)
* --&gt; PlexusContainer.lookupList(..)
* &lt;-- ComponentLookupException
* &lt;-- ProfileActivationException
* &lt;------ ProjectBuildingException
* </pre>
*/
void reportActivatorLookupErrorWhileApplyingProfiles( Model model,
File pomFile,
Profile profile,
ComponentLookupException cause );
/**
* <b>Call Stack:</b>
* <br/>
* <pre>
* DefaultProfileAdvisor.applyActivatedProfiles(..)
* DefaultProfileAdvisor.applyActivatedExternalProfiles(..)
* --&gt; DefaultProfileAdvisor.getArtifactRepositoriesFromActiveProfiles(..)
* --&gt; DefaultProfileManager.getActiveProfiles(..)
* --&gt; DefaultProfileManager.isActive(..) (private)
@ -117,7 +77,7 @@ public interface ProjectErrorReporter
* &lt;------ ProjectBuildingException
* </pre>
*/
void reportActivatorLookupErrorWhileGettingRepositoriesFromProfiles( String projectId,
void reportActivatorLookupError( String projectId,
File pomFile,
Profile profile,
ComponentLookupException cause );
@ -211,11 +171,10 @@ public interface ProjectErrorReporter
* &lt;---------- ProjectBuildingException
* </pre>
*/
void reportErrorCreatingArtifactRepository( MavenProject project,
void reportErrorCreatingArtifactRepository( String projectId,
File pomFile,
Repository repo,
UnknownRepositoryLayoutException cause,
boolean isPluginRepo );
UnknownRepositoryLayoutException cause );
/**
* <b>Call Stack:</b>

View File

@ -33,21 +33,7 @@ public final class ProjectErrorTips
{
}
public static List getTipsForActivatorErrorWhileApplyingProfiles( ProfileActivator activator,
Model model,
File pomFile,
Profile profile,
ProfileActivationContext context,
ProfileActivationException cause )
{
return listOf( new String[]{ "If this is a standard profile activator, see "
+ "http://maven.apache.org/pom.html#Activation for help configuring profile activation.",
"XSD location for pom.xml: http://maven.apache.org/xsd/maven-4.0.0.xsd",
"XSD location for settings.xml: http://maven.apache.org/xsd/settings-1.0.0.xsd",
"XSD location for profiles.xml: http://maven.apache.org/xsd/profiles-1.0.0.xsd" } );
}
public static List getTipsForActivatorErrorWhileGettingRepositoriesFromProfiles( ProfileActivator activator,
public static List getTipsForActivatorError( ProfileActivator activator,
String projectId,
File pomFile,
Profile profile,
@ -61,20 +47,7 @@ public final class ProjectErrorTips
"XSD location for profiles.xml: http://maven.apache.org/xsd/profiles-1.0.0.xsd" } );
}
public static List getTipsForActivatorLookupErrorWhileApplyingProfiles( Model model,
File pomFile,
Profile profile,
ComponentLookupException cause )
{
return listOf( new String[]{ "If this is a custom profile activator, please ensure the activator's "
+ "artifact is present in the POM's build/extensions list.",
"See http://maven.apache.org/pom.html#Extensions for more on build extensions.",
"XSD location for pom.xml: http://maven.apache.org/xsd/maven-4.0.0.xsd",
"XSD location for settings.xml: http://maven.apache.org/xsd/settings-1.0.0.xsd",
"XSD location for profiles.xml: http://maven.apache.org/xsd/profiles-1.0.0.xsd" } );
}
public static List getTipsForActivatorLookupErrorWhileGettingRepositoriesFromProfiles( String projectId,
public static List getTipsForActivatorLookupError( String projectId,
File pomFile,
Profile profile,
ComponentLookupException cause )

View File

@ -227,6 +227,12 @@ under the License.
<version>1.2_Java1.3</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>commons-httpclient</groupId>
<artifactId>commons-httpclient</artifactId>
<version>3.1</version>
<scope>test</scope>
</dependency>
</dependencies>
</dependencyManagement>
<distributionManagement>