mirror of https://github.com/apache/maven.git
[MNG-4776] NPE during build from parent but not from child
git-svn-id: https://svn.apache.org/repos/asf/maven/maven-3/trunk@989222 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
6c37a89744
commit
6b82e83024
|
@ -484,10 +484,8 @@ public class DefaultLifecycleExecutionPlanCalculator
|
||||||
LifecyclePhaseNotFoundException, LifecycleNotFoundException, PluginVersionResolutionException
|
LifecyclePhaseNotFoundException, LifecycleNotFoundException, PluginVersionResolutionException
|
||||||
{
|
{
|
||||||
calculateForkedExecutions( mojoExecution, session, session.getCurrentProject(), new HashSet<MojoDescriptor>() );
|
calculateForkedExecutions( mojoExecution, session, session.getCurrentProject(), new HashSet<MojoDescriptor>() );
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private void calculateForkedExecutions( MojoExecution mojoExecution, MavenSession session, MavenProject project,
|
private void calculateForkedExecutions( MojoExecution mojoExecution, MavenSession session, MavenProject project,
|
||||||
Collection<MojoDescriptor> alreadyForkedExecutions )
|
Collection<MojoDescriptor> alreadyForkedExecutions )
|
||||||
throws MojoNotFoundException, PluginNotFoundException, PluginResolutionException,
|
throws MojoNotFoundException, PluginNotFoundException, PluginResolutionException,
|
||||||
|
@ -511,6 +509,11 @@ public class DefaultLifecycleExecutionPlanCalculator
|
||||||
|
|
||||||
for ( MavenProject forkedProject : forkedProjects )
|
for ( MavenProject forkedProject : forkedProjects )
|
||||||
{
|
{
|
||||||
|
if ( forkedProject != project )
|
||||||
|
{
|
||||||
|
lifecyclePluginResolver.resolveMissingPluginVersions( forkedProject, session );
|
||||||
|
}
|
||||||
|
|
||||||
List<MojoExecution> forkedExecutions;
|
List<MojoExecution> forkedExecutions;
|
||||||
|
|
||||||
if ( StringUtils.isNotEmpty( mojoDescriptor.getExecutePhase() ) )
|
if ( StringUtils.isNotEmpty( mojoDescriptor.getExecutePhase() ) )
|
||||||
|
|
|
@ -60,7 +60,7 @@ public class LifecyclePluginResolver
|
||||||
public void resolveMissingPluginVersions( MavenProject project, MavenSession session )
|
public void resolveMissingPluginVersions( MavenProject project, MavenSession session )
|
||||||
throws PluginVersionResolutionException
|
throws PluginVersionResolutionException
|
||||||
{
|
{
|
||||||
Map<String, String> versions = new HashMap<String, String>();
|
Map<String, String> versions = new HashMap<String, String>( 64 );
|
||||||
|
|
||||||
for ( Plugin plugin : project.getBuildPlugins() )
|
for ( Plugin plugin : project.getBuildPlugins() )
|
||||||
{
|
{
|
||||||
|
|
|
@ -42,6 +42,7 @@ import org.apache.maven.project.MavenProject;
|
||||||
import org.codehaus.plexus.component.annotations.Component;
|
import org.codehaus.plexus.component.annotations.Component;
|
||||||
import org.codehaus.plexus.component.annotations.Requirement;
|
import org.codehaus.plexus.component.annotations.Requirement;
|
||||||
import org.codehaus.plexus.configuration.PlexusConfiguration;
|
import org.codehaus.plexus.configuration.PlexusConfiguration;
|
||||||
|
import org.codehaus.plexus.logging.Logger;
|
||||||
import org.codehaus.plexus.util.xml.Xpp3Dom;
|
import org.codehaus.plexus.util.xml.Xpp3Dom;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
@ -63,6 +64,10 @@ import java.util.StringTokenizer;
|
||||||
@Component( role = MojoDescriptorCreator.class )
|
@Component( role = MojoDescriptorCreator.class )
|
||||||
public class MojoDescriptorCreator
|
public class MojoDescriptorCreator
|
||||||
{
|
{
|
||||||
|
|
||||||
|
@Requirement
|
||||||
|
private Logger logger;
|
||||||
|
|
||||||
@Requirement
|
@Requirement
|
||||||
private PluginVersionResolver pluginVersionResolver;
|
private PluginVersionResolver pluginVersionResolver;
|
||||||
|
|
||||||
|
@ -72,17 +77,22 @@ public class MojoDescriptorCreator
|
||||||
@Requirement
|
@Requirement
|
||||||
private PluginPrefixResolver pluginPrefixResolver;
|
private PluginPrefixResolver pluginPrefixResolver;
|
||||||
|
|
||||||
|
@Requirement
|
||||||
|
private LifecyclePluginResolver lifecyclePluginResolver;
|
||||||
|
|
||||||
@SuppressWarnings( { "UnusedDeclaration" } )
|
@SuppressWarnings( { "UnusedDeclaration" } )
|
||||||
public MojoDescriptorCreator()
|
public MojoDescriptorCreator()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
public MojoDescriptorCreator( PluginVersionResolver pluginVersionResolver, BuildPluginManager pluginManager,
|
public MojoDescriptorCreator( PluginVersionResolver pluginVersionResolver, BuildPluginManager pluginManager,
|
||||||
PluginPrefixResolver pluginPrefixResolver )
|
PluginPrefixResolver pluginPrefixResolver,
|
||||||
|
LifecyclePluginResolver lifecyclePluginResolver )
|
||||||
{
|
{
|
||||||
this.pluginVersionResolver = pluginVersionResolver;
|
this.pluginVersionResolver = pluginVersionResolver;
|
||||||
this.pluginManager = pluginManager;
|
this.pluginManager = pluginManager;
|
||||||
this.pluginPrefixResolver = pluginPrefixResolver;
|
this.pluginPrefixResolver = pluginPrefixResolver;
|
||||||
|
this.lifecyclePluginResolver = lifecyclePluginResolver;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Plugin findPlugin( String groupId, String artifactId, Collection<Plugin> plugins )
|
private Plugin findPlugin( String groupId, String artifactId, Collection<Plugin> plugins )
|
||||||
|
@ -221,6 +231,19 @@ public class MojoDescriptorCreator
|
||||||
{
|
{
|
||||||
// [prefix]:[goal]
|
// [prefix]:[goal]
|
||||||
|
|
||||||
|
if ( session.getCurrentProject() != null )
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
lifecyclePluginResolver.resolveMissingPluginVersions( session.getCurrentProject(), session );
|
||||||
|
}
|
||||||
|
catch ( PluginVersionResolutionException e )
|
||||||
|
{
|
||||||
|
// not critical here
|
||||||
|
logger.debug( e.getMessage(), e );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
PluginPrefixRequest prefixRequest = new DefaultPluginPrefixRequest( prefix, session );
|
PluginPrefixRequest prefixRequest = new DefaultPluginPrefixRequest( prefix, session );
|
||||||
PluginPrefixResult prefixResult = pluginPrefixResolver.resolve( prefixRequest );
|
PluginPrefixResult prefixResult = pluginPrefixResolver.resolve( prefixRequest );
|
||||||
|
|
||||||
|
|
|
@ -73,6 +73,7 @@ public class LifecycleExecutionPlanCalculatorTest
|
||||||
public static MojoDescriptorCreator createMojoDescriptorCreator()
|
public static MojoDescriptorCreator createMojoDescriptorCreator()
|
||||||
{
|
{
|
||||||
return new MojoDescriptorCreator( new PluginVersionResolverStub(), new BuildPluginManagerStub(),
|
return new MojoDescriptorCreator( new PluginVersionResolverStub(), new BuildPluginManagerStub(),
|
||||||
new PluginPrefixResolverStub() );
|
new PluginPrefixResolverStub(),
|
||||||
|
new LifecyclePluginResolver( new PluginVersionResolverStub() ) );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue