MNG-3919: NPE in DefaultLifecycleBindingManager

git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@740468 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Britton Isbell 2009-02-03 21:50:27 +00:00
parent 5eaab27857
commit cb077dc469
4 changed files with 93 additions and 10 deletions

View File

@ -248,6 +248,12 @@ public class DefaultLifecycleBindingManager
}
MojoDescriptor mojoDescriptor = pluginDescriptor.getMojo( goal );
if(mojoDescriptor == null)
{
throw new LifecycleSpecificationException( "Mojo Descriptor for goal is invalid: Plugin = "
+ plugin.getKey() + ", Plugin Descriptor = "
+ pluginDescriptor.getPluginLookupKey() +", Goal = " + goal);
}
phase = mojoDescriptor.getPhase();
logger.debug( "Phase from plugin descriptor: " + mojoDescriptor.getFullGoalName() + " is: " + phase );

View File

@ -264,7 +264,8 @@ public final class CLIReportingUtils
handleGenericException( e, showStackTraces, writer );
MavenProject project = e.getProject();
if(project != null)
{
writer.write( NEWLINE );
writer.write( "While building project with id: " );
writer.write( project.getId() );
@ -275,6 +276,7 @@ public final class CLIReportingUtils
writer.write( project.getFile().getAbsolutePath() );
}
writer.write( NEWLINE );
}
return true;
}

View File

@ -33,6 +33,7 @@ import org.apache.maven.settings.Settings;
import org.apache.maven.settings.SettingsConfigurationException;
import org.apache.maven.settings.io.xpp3.SettingsXpp3Reader;
import org.apache.maven.settings.io.xpp3.SettingsXpp3Writer;
import org.apache.maven.lifecycle.LifecycleSpecificationException;
import org.codehaus.plexus.util.FileUtils;
import org.codehaus.plexus.util.IOUtil;
import org.codehaus.plexus.util.ReaderFactory;
@ -57,6 +58,7 @@ public class MavenEmbedderTest
protected MavenEmbedder maven;
protected void setUp()
throws Exception
{
@ -134,6 +136,30 @@ public class MavenEmbedderTest
assertTrue( jar.exists() );
}
/*MNG-3919*/
public void testWithInvalidGoal()
throws Exception
{
File testDirectory = new File( basedir, "src/test/projects/invalid-goal" );
File targetDirectory = new File( basedir, "target/projects/invalid-goal" );
FileUtils.copyDirectoryStructure( testDirectory, targetDirectory );
MavenExecutionRequest request = new DefaultMavenExecutionRequest().setBaseDirectory( targetDirectory )
.setShowErrors( true ).setGoals( Arrays.asList( new String[]{"validate"} ) );
MavenExecutionResult result = maven.execute( request );
List exceptions = result.getExceptions();
assertEquals("Incorrect number of exceptions", 1, exceptions.size());
Iterator it = exceptions.iterator();
if( (it.next() instanceof NullPointerException))
{
fail("Null Pointer on Exception");
}
}
public void testExecutionUsingAPomFile()
throws Exception
{

View File

@ -0,0 +1,49 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
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.its.mng</groupId>
<artifactId>test1</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-site-plugin</artifactId>
<version>2.0-beta-7</version>
<executions>
<execution>
<goals>
<goal>invalid-goal</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>