diff --git a/maven-core/src/main/java/org/apache/maven/lifecycle/statemgmt/ClearForkedContextMojo.java b/maven-core/src/main/java/org/apache/maven/lifecycle/statemgmt/ClearForkedContextMojo.java
index 3aae33b9bc..d8e77023fe 100644
--- a/maven-core/src/main/java/org/apache/maven/lifecycle/statemgmt/ClearForkedContextMojo.java
+++ b/maven-core/src/main/java/org/apache/maven/lifecycle/statemgmt/ClearForkedContextMojo.java
@@ -7,24 +7,27 @@ import org.apache.maven.project.MavenProject;
/**
* Remove the execution-project used during the fork, now that the forking mojo is finished executing.
- *
+ *
* @author jdcasey
*
*/
public class ClearForkedContextMojo
extends AbstractMojo
{
-
+
private MavenProject project;
-
+
private int forkId = -1;
-
+
public void execute()
throws MojoExecutionException, MojoFailureException
{
getLog().info( "Cleaning up forked execution context [fork id: " + forkId + "]" );
-
- project.clearExecutionProject();
+
+ if ( project != null )
+ {
+ project.clearExecutionProject();
+ }
}
}
diff --git a/maven-core/src/main/java/org/apache/maven/lifecycle/statemgmt/EndForkedExecutionMojo.java b/maven-core/src/main/java/org/apache/maven/lifecycle/statemgmt/EndForkedExecutionMojo.java
index 3f170992f4..b87f8beade 100644
--- a/maven-core/src/main/java/org/apache/maven/lifecycle/statemgmt/EndForkedExecutionMojo.java
+++ b/maven-core/src/main/java/org/apache/maven/lifecycle/statemgmt/EndForkedExecutionMojo.java
@@ -10,14 +10,14 @@ import org.apache.maven.project.MavenProject;
/**
* Restore the lifecycle execution context's current-project, and set the project instance from the
* forked execution to project.getExecutionProject() for the forking mojo to use.
- *
+ *
* @author jdcasey
*
*/
public class EndForkedExecutionMojo
extends AbstractMojo
{
-
+
private int forkId = -1;
private BuildContextManager buildContextManager;
@@ -26,13 +26,16 @@ public class EndForkedExecutionMojo
throws MojoExecutionException, MojoFailureException
{
getLog().info( "Ending forked execution [fork id: " + forkId + "]" );
-
+
LifecycleExecutionContext ctx = LifecycleExecutionContext.read( buildContextManager );
MavenProject executionProject = ctx.removeForkedProject();
-
+
MavenProject project = ctx.getCurrentProject();
- project.setExecutionProject( executionProject );
-
+ if ( ( project != null ) && ( executionProject != null ) )
+ {
+ project.setExecutionProject( executionProject );
+ }
+
ctx.store( buildContextManager );
}
diff --git a/maven-core/src/main/java/org/apache/maven/lifecycle/statemgmt/StartForkedExecutionMojo.java b/maven-core/src/main/java/org/apache/maven/lifecycle/statemgmt/StartForkedExecutionMojo.java
index 5d881f076e..e032bdf0b5 100644
--- a/maven-core/src/main/java/org/apache/maven/lifecycle/statemgmt/StartForkedExecutionMojo.java
+++ b/maven-core/src/main/java/org/apache/maven/lifecycle/statemgmt/StartForkedExecutionMojo.java
@@ -9,27 +9,30 @@ import org.apache.maven.project.MavenProject;
/**
* Setup a new project instance for the forked executions to use.
- *
+ *
* @author jdcasey
*
*/
public class StartForkedExecutionMojo
extends AbstractMojo
{
-
+
private MavenProject project;
-
+
private int forkId = -1;
-
+
private BuildContextManager buildContextManager;
public void execute()
throws MojoExecutionException, MojoFailureException
{
getLog().info( "Starting forked execution [fork id: " + forkId + "]" );
-
+
LifecycleExecutionContext ctx = LifecycleExecutionContext.read( buildContextManager );
- ctx.addForkedProject( new MavenProject( project ) );
+ if ( project != null )
+ {
+ ctx.addForkedProject( new MavenProject( project ) );
+ }
ctx.store( buildContextManager );
}
diff --git a/maven-core/src/main/resources/META-INF/maven/plugin.xml b/maven-core/src/main/resources/META-INF/maven/plugin.xml
index 7f1fa9a6fd..6a912e154c 100644
--- a/maven-core/src/main/resources/META-INF/maven/plugin.xml
+++ b/maven-core/src/main/resources/META-INF/maven/plugin.xml
@@ -11,7 +11,7 @@
start-fork
Setup the appropriate build state to initiate a forked execution.
false
- true
+ false
false
false
false
@@ -51,7 +51,7 @@
end-fork
Restore the non-fork currentProject instance, for use in the forking mojo.
false
- true
+ false
false
false
false
@@ -83,7 +83,7 @@
clear-fork-context
Tear down any build state used during the previous forked execution.
false
- true
+ false
false
false
false
@@ -117,7 +117,7 @@
resolve-late-bound-plugin
Resolve a late-bound plugin during a build, right before it is to be used.
false
- true
+ false
false
false
false