mirror of https://github.com/apache/maven.git
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:
parent
5eaab27857
commit
cb077dc469
|
@ -248,6 +248,12 @@ public class DefaultLifecycleBindingManager
|
||||||
}
|
}
|
||||||
|
|
||||||
MojoDescriptor mojoDescriptor = pluginDescriptor.getMojo( goal );
|
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();
|
phase = mojoDescriptor.getPhase();
|
||||||
|
|
||||||
logger.debug( "Phase from plugin descriptor: " + mojoDescriptor.getFullGoalName() + " is: " + phase );
|
logger.debug( "Phase from plugin descriptor: " + mojoDescriptor.getFullGoalName() + " is: " + phase );
|
||||||
|
|
|
@ -264,17 +264,19 @@ public final class CLIReportingUtils
|
||||||
handleGenericException( e, showStackTraces, writer );
|
handleGenericException( e, showStackTraces, writer );
|
||||||
|
|
||||||
MavenProject project = e.getProject();
|
MavenProject project = e.getProject();
|
||||||
|
if(project != null)
|
||||||
writer.write( NEWLINE );
|
|
||||||
writer.write( "While building project with id: " );
|
|
||||||
writer.write( project.getId() );
|
|
||||||
writer.write( NEWLINE );
|
|
||||||
if ( project.getFile() != null )
|
|
||||||
{
|
{
|
||||||
writer.write( "Project File: " );
|
writer.write( NEWLINE );
|
||||||
writer.write( project.getFile().getAbsolutePath() );
|
writer.write( "While building project with id: " );
|
||||||
|
writer.write( project.getId() );
|
||||||
|
writer.write( NEWLINE );
|
||||||
|
if ( project.getFile() != null )
|
||||||
|
{
|
||||||
|
writer.write( "Project File: " );
|
||||||
|
writer.write( project.getFile().getAbsolutePath() );
|
||||||
|
}
|
||||||
|
writer.write( NEWLINE );
|
||||||
}
|
}
|
||||||
writer.write( NEWLINE );
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,6 +33,7 @@ import org.apache.maven.settings.Settings;
|
||||||
import org.apache.maven.settings.SettingsConfigurationException;
|
import org.apache.maven.settings.SettingsConfigurationException;
|
||||||
import org.apache.maven.settings.io.xpp3.SettingsXpp3Reader;
|
import org.apache.maven.settings.io.xpp3.SettingsXpp3Reader;
|
||||||
import org.apache.maven.settings.io.xpp3.SettingsXpp3Writer;
|
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.FileUtils;
|
||||||
import org.codehaus.plexus.util.IOUtil;
|
import org.codehaus.plexus.util.IOUtil;
|
||||||
import org.codehaus.plexus.util.ReaderFactory;
|
import org.codehaus.plexus.util.ReaderFactory;
|
||||||
|
@ -57,6 +58,7 @@ public class MavenEmbedderTest
|
||||||
|
|
||||||
protected MavenEmbedder maven;
|
protected MavenEmbedder maven;
|
||||||
|
|
||||||
|
|
||||||
protected void setUp()
|
protected void setUp()
|
||||||
throws Exception
|
throws Exception
|
||||||
{
|
{
|
||||||
|
@ -134,6 +136,30 @@ public class MavenEmbedderTest
|
||||||
assertTrue( jar.exists() );
|
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()
|
public void testExecutionUsingAPomFile()
|
||||||
throws Exception
|
throws Exception
|
||||||
{
|
{
|
||||||
|
|
|
@ -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>
|
Loading…
Reference in New Issue