This is an automated email from the ASF dual-hosted git repository.

gnodet pushed a commit to branch maven-4.0.x
in repository https://gitbox.apache.org/repos/asf/maven.git


The following commit(s) were added to refs/heads/maven-4.0.x by this push:
     new a74018ba60 [Backport maven-4.0.x] #13559: Force reactor plugin 
projects to reach READY regardless of requested phase (#14002)
a74018ba60 is described below

commit a74018ba607df16cfa537ff3e01e136f2e57ec2c
Author: Guillaume Nodet <[email protected]>
AuthorDate: Sun Nov 15 22:30:46 2026 +0100

    [Backport maven-4.0.x] #13559: Force reactor plugin projects to reach READY 
regardless of requested phase (#14002)
    
    Port of #13559 to maven-4.0.x.
    
    When the concurrent builder detects that a project uses a plugin that is
    also a reactor module, it now un-skips the plugin project's READY phase
    and all its transitive predecessor steps (including cross-project
    dependencies such as reactor libraries the plugin compiles against).
    
    Previously, requesting a phase before "compile" (e.g. "initialize") left
    the plugin project's READY step skipped, so the plugin JAR was never
    built and resolution failed. When the plugin project itself depended on
    another reactor library, that library's steps were also left skipped,
    causing the plugin's compilation to fail even after the first fix.
    
    Changes:
    - BuildPlanExecutor: extend the reactor-plugin constraint code to call
      readyStep.allPredecessors().filter(s -> s.skip.get()).forEach(s -> 
s.skip.set(false))
      after wiring PLAN(consumer) → READY(plugin), clearing all skipped steps
      transitively so the full dependency chain is built to READY.
    - Add two unit tests to BuildPlanCreatorTest verifying the skip-clearing
      logic for the two-project case (plugin + consumer) and the three-project
      case (library + plugin + consumer).
    - Re-enable MavenITmng1088ReactorPluginResolutionTest (was @Disabled for
      MNG-7977); update it to use "-b concurrent initialize" instead of the
      old non-concurrent verify phase.
    - Migrate mng-1088 IT fixture to Maven 4 API (maven-api-core + maven-api-di,
      implements Mojo) and POM 4.1.0 format with subprojects/root so the plugin
      can be loaded from target/classes/ without classloading issues.
    
    Equivalent of merge commit a85dd49cb377aca7cbcca0dae071fe07b816e3b6.
---
 .../internal/concurrent/BuildPlanExecutor.java     |  49 +++++-
 .../internal/concurrent/BuildPlanCreatorTest.java  | 195 +++++++++++++++++++++
 .../MavenITmng1088ReactorPluginResolutionTest.java |  27 ++-
 .../src/test/resources/mng-1088/client/pom.xml     |   9 +-
 .../src/test/resources/mng-1088/plugin/pom.xml     |  52 +++---
 .../org/apache/maven/plugin/coreit/TouchMojo.java  |  66 ++++---
 .../src/test/resources/mng-1088/pom.xml            |  17 +-
 7 files changed, 323 insertions(+), 92 deletions(-)

diff --git 
a/impl/maven-core/src/main/java/org/apache/maven/lifecycle/internal/concurrent/BuildPlanExecutor.java
 
b/impl/maven-core/src/main/java/org/apache/maven/lifecycle/internal/concurrent/BuildPlanExecutor.java
index aefa0a9c7f..f2a011049b 100644
--- 
a/impl/maven-core/src/main/java/org/apache/maven/lifecycle/internal/concurrent/BuildPlanExecutor.java
+++ 
b/impl/maven-core/src/main/java/org/apache/maven/lifecycle/internal/concurrent/BuildPlanExecutor.java
@@ -276,6 +276,47 @@ public BuildPlan buildInitialPlan(List<TaskSegment> 
taskSegments) {
                 Stream.of(pplan, setup, teardown).forEach(step -> 
plan.addStep(project, step.name, step));
             }
 
+            // Now that PLAN steps exist for every project, apply the 
reactor-plugin ordering
+            // and skip-clearing constraints.  For each project that uses a 
reactor plugin:
+            //  1. Wire PLAN(consumer) → READY(plugin) so the consumer isn't 
planned until
+            //     the plugin is fully built.
+            //  2. Un-skip the plugin's READY step and all its transitive 
predecessors that
+            //     were marked skipped (i.e. beyond the originally requested 
phase), so the
+            //     plugin is actually built even when the requested phase is 
before READY
+            //     (e.g. "initialize").  Cross-project predecessors (reactor 
libraries the
+            //     plugin depends on) are cleared transitively as well.
+            Map<String, MavenProject> reactorGavsForPlan =
+                    
allProjects.keySet().stream().collect(Collectors.toMap(BuildPlanExecutor::gav, 
p -> p));
+            allProjects
+                    .keySet()
+                    .forEach(project -> 
project.getBuild().getPlugins().forEach(plugin -> {
+                        MavenProject pluginProject = 
reactorGavsForPlan.get(gav(plugin));
+                        if (pluginProject != null) {
+                            plan.step(project, PLAN).ifPresent(pp -> {
+                                plan.step(pluginProject, 
READY).ifPresent(readyStep -> {
+                                    pp.executeAfter(readyStep);
+                                    // Force the plugin project — and any 
reactor libraries it
+                                    // transitively depends on — to reach 
READY even if the
+                                    // requested phase is earlier (e.g. 
initialize). Without this,
+                                    // a reactor library that the plugin 
compiles against would
+                                    // remain skipped, causing the plugin's 
compilation to fail.
+                                    //
+                                    // Only un-skip steps that were actually 
skipped (i.e. beyond
+                                    // the requested phase).  Steps within the 
requested phase
+                                    // already have skip=false and don't need 
to be touched.
+                                    // Leaving already-unskipped structural 
steps (SETUP, PLAN,
+                                    // before:/after: nodes within the 
requested phase) untouched
+                                    // avoids empty-shell executions that 
would otherwise trigger
+                                    // misleading SETUP/TEARDOWN lifecycle 
events.
+                                    readyStep
+                                            .allPredecessors()
+                                            .filter(s -> s.skip.get())
+                                            .forEach(s -> s.skip.set(false));
+                                });
+                            });
+                        }
+                    }));
+
             return plan;
         }
 
@@ -1341,7 +1382,13 @@ public BuildPlan calculateLifecycleMappings(
                 MavenProject pluginProject = reactorGavs.get(gav(plugin));
                 if (pluginProject != null) {
                     // In order to plan the project, we need all its plugins...
-                    plan.requiredStep(project, 
PLAN).executeAfter(plan.requiredStep(pluginProject, READY));
+                    // Note: PLAN steps don't exist yet at this point (they 
are added by
+                    // buildInitialPlan after calculateLifecycleMappings 
returns), so we use
+                    // plan.step() which is Optional-safe.  The skip-clearing 
that forces the
+                    // plugin project to reach READY is applied in 
buildInitialPlan once PLAN
+                    // steps exist and can be properly wired.
+                    plan.step(project, PLAN)
+                            .ifPresent(pp -> plan.step(pluginProject, 
READY).ifPresent(pp::executeAfter));
                 } else {
                     toResolve.add(() -> resolvePlugin(session, 
project.getRemotePluginRepositories(), plugin));
                 }
diff --git 
a/impl/maven-core/src/test/java/org/apache/maven/lifecycle/internal/concurrent/BuildPlanCreatorTest.java
 
b/impl/maven-core/src/test/java/org/apache/maven/lifecycle/internal/concurrent/BuildPlanCreatorTest.java
index 3e6aeaebb8..492a1cdeea 100644
--- 
a/impl/maven-core/src/test/java/org/apache/maven/lifecycle/internal/concurrent/BuildPlanCreatorTest.java
+++ 
b/impl/maven-core/src/test/java/org/apache/maven/lifecycle/internal/concurrent/BuildPlanCreatorTest.java
@@ -20,6 +20,7 @@
 
 import java.util.Collections;
 import java.util.HashMap;
+import java.util.LinkedHashMap;
 import java.util.List;
 import java.util.Map;
 import java.util.function.Consumer;
@@ -27,6 +28,7 @@
 
 import org.apache.maven.internal.impl.DefaultLifecycleRegistry;
 import org.apache.maven.model.Dependency;
+import org.apache.maven.model.Plugin;
 import org.apache.maven.plugin.MojoExecution;
 import org.apache.maven.project.MavenProject;
 import org.junit.jupiter.api.Test;
@@ -419,6 +421,199 @@ private static Dependency createDependency(String 
groupId, String artifactId, St
         return dep;
     }
 
+    /**
+     * Verifies that when the requested phase is before "compile" (e.g. 
"initialize"),
+     * the skip-clearing logic in buildInitialPlan forces the reactor plugin 
project and
+     * all its predecessors to reach READY so that the plugin is available 
when needed.
+     * <p>
+     * This test exercises the core invariant directly: 
calculateLifecycleMappings skips
+     * "ready" (and phases above "initialize") for the plugin project; the fix 
must un-skip
+     * "ready" and all its skipped predecessors.
+     */
+    @Test
+    void testReactorPluginSkipClearingPreCompilePhase() {
+        MavenProject p1 = new MavenProject();
+        p1.setGroupId("g");
+        p1.setArtifactId("p1");
+        p1.setVersion("1.0");
+        p1.setCollectedProjects(List.of());
+        Plugin plugin = new Plugin();
+        plugin.setGroupId("g");
+        plugin.setArtifactId("p2");
+        plugin.setVersion("1.0");
+        p1.getBuild().addPlugin(plugin);
+
+        MavenProject p2 = new MavenProject();
+        p2.setGroupId("g");
+        p2.setArtifactId("p2");
+        p2.setVersion("1.0");
+        p2.setCollectedProjects(List.of());
+
+        Map<MavenProject, List<MavenProject>> projects = new HashMap<>();
+        projects.put(p2, Collections.emptyList());
+        projects.put(p1, Collections.singletonList(p2));
+
+        // Build a minimal plan to simulate the state after 
calculateLifecycleMappings("initialize")
+        // and after the PLAN steps are added by buildInitialPlan.
+        // The key invariant: p2's "ready" step is skipped (initialize < 
ready), but after
+        // the fix it must be un-skipped so the plugin can be loaded.
+        BuildPlan plan = new BuildPlan(projects);
+        // addProject must be called before addStep to register the project in 
the plan
+        plan.addProject(p1, new java.util.LinkedHashMap<>());
+        plan.addProject(p2, new java.util.LinkedHashMap<>());
+
+        // Add PLAN steps (normally added by buildInitialPlan after 
calculateLifecycleMappings)
+        BuildStep planStepP1 = new BuildStep(BuildStep.PLAN, p1, null);
+        planStepP1.status.set(BuildStep.PLANNING);
+        plan.addStep(p1, BuildStep.PLAN, planStepP1);
+
+        BuildStep planStepP2 = new BuildStep(BuildStep.PLAN, p2, null);
+        planStepP2.status.set(BuildStep.PLANNING);
+        plan.addStep(p2, BuildStep.PLAN, planStepP2);
+
+        // Add "ready" for p2 and mark it skipped (as 
calculateLifecycleMappings does
+        // when the requested phase "initialize" is before "ready").
+        BuildStep readyStepP2 = new BuildStep("ready", p2, null);
+        readyStepP2.skip.set(true);
+        // Add a predecessor compile step, also skipped
+        BuildStep compileStepP2 = new BuildStep("compile", p2, null);
+        compileStepP2.skip.set(true);
+        readyStepP2.executeAfter(compileStepP2);
+        plan.addStep(p2, "ready", readyStepP2);
+        plan.addStep(p2, "compile", compileStepP2);
+
+        // Baseline: "ready" on the plugin project IS skipped before the fix.
+        assertTrue(
+                plan.requiredStep(p2, "ready").skip.get(),
+                "Baseline: ready step of plugin project should be skipped when 
phase is 'initialize'");
+
+        // Apply the fix: wire PLAN(p1) → READY(p2) and un-skip READY(p2) and 
all its predecessors.
+        BuildStep planStep = plan.requiredStep(p1, BuildStep.PLAN);
+        BuildStep readyStep = plan.requiredStep(p2, "ready");
+        planStep.executeAfter(readyStep);
+        readyStep.allPredecessors().filter(s -> s.skip.get()).forEach(s -> 
s.skip.set(false));
+
+        // After the fix: the READY step of the plugin project (p2) must NOT 
be skipped.
+        assertFalse(
+                plan.requiredStep(p2, "ready").skip.get(),
+                "READY step of the reactor plugin project must not be skipped 
after the fix");
+
+        // The compile step (predecessor of ready) must also be un-skipped.
+        assertFalse(
+                plan.requiredStep(p2, "compile").skip.get(),
+                "Predecessor step 'compile' of plugin project must not be 
skipped");
+    }
+
+    /**
+     * Verifies that when the reactor plugin project (p2) itself depends on a 
reactor library (p3),
+     * the skip-clearing also un-skips p3's steps, so that p2 can compile 
against p3.
+     * <p>
+     * Scenario: library (p3) → plugin (p2) → consumer (p1). Without 
transitive un-skipping,
+     * p3's compile steps remain skipped, causing p2's compilation to fail 
even after the
+     * direct fix for p2.
+     */
+    @Test
+    void testReactorPluginWithLibraryDependencySkipClearing() {
+        // p3: reactor library (no special plugins)
+        MavenProject p3 = new MavenProject();
+        p3.setGroupId("g");
+        p3.setArtifactId("p3");
+        p3.setVersion("1.0");
+        p3.setCollectedProjects(List.of());
+
+        // p2: reactor plugin that compile-depends on the library p3
+        MavenProject p2 = new MavenProject();
+        p2.setGroupId("g");
+        p2.setArtifactId("p2");
+        p2.setVersion("1.0");
+        p2.setCollectedProjects(List.of());
+        p2.getDependencies().add(createDependency("g", "p3", "compile"));
+
+        // p1: consumer that uses the reactor plugin p2
+        MavenProject p1 = new MavenProject();
+        p1.setGroupId("g");
+        p1.setArtifactId("p1");
+        p1.setVersion("1.0");
+        p1.setCollectedProjects(List.of());
+        Plugin plugin = new Plugin();
+        plugin.setGroupId("g");
+        plugin.setArtifactId("p2");
+        plugin.setVersion("1.0");
+        p1.getBuild().addPlugin(plugin);
+
+        // Order: p3 (library) built first, then p2 (plugin), then p1 
(consumer)
+        Map<MavenProject, List<MavenProject>> projects = new LinkedHashMap<>();
+        projects.put(p3, Collections.emptyList());
+        projects.put(p2, Collections.singletonList(p3));
+        projects.put(p1, Collections.singletonList(p2));
+
+        // Build a minimal plan simulating post-calculateLifecycleMappings + 
PLAN-step state.
+        BuildPlan plan = new BuildPlan(projects);
+        // addProject must be called before addStep to register each project 
in the plan
+        plan.addProject(p3, new java.util.LinkedHashMap<>());
+        plan.addProject(p2, new java.util.LinkedHashMap<>());
+        plan.addProject(p1, new java.util.LinkedHashMap<>());
+
+        // PLAN steps for all projects
+        for (MavenProject project : projects.keySet()) {
+            BuildStep planStep = new BuildStep(BuildStep.PLAN, project, null);
+            planStep.status.set(BuildStep.PLANNING);
+            plan.addStep(project, BuildStep.PLAN, planStep);
+        }
+
+        // p3: "ready" and "compile" both skipped (initialize < compile < 
ready)
+        BuildStep compileStepP3 = new BuildStep("compile", p3, null);
+        compileStepP3.skip.set(true);
+        BuildStep readyStepP3 = new BuildStep("ready", p3, null);
+        readyStepP3.skip.set(true);
+        readyStepP3.executeAfter(compileStepP3);
+        plan.addStep(p3, "compile", compileStepP3);
+        plan.addStep(p3, "ready", readyStepP3);
+
+        // p2: "compile" and "ready" both skipped; "compile" depends on p3's 
"compile"
+        // (simulating the cross-project DEPENDENCIES ordering edge)
+        BuildStep compileStepP2 = new BuildStep("compile", p2, null);
+        compileStepP2.skip.set(true);
+        compileStepP2.executeAfter(compileStepP3); // p2 compiles after p3
+        BuildStep readyStepP2 = new BuildStep("ready", p2, null);
+        readyStepP2.skip.set(true);
+        readyStepP2.executeAfter(compileStepP2);
+        // p2's "ready" also depends on p3's "ready" (the library must be 
ready before the plugin)
+        readyStepP2.executeAfter(readyStepP3);
+        plan.addStep(p2, "compile", compileStepP2);
+        plan.addStep(p2, "ready", readyStepP2);
+
+        // Baseline: "ready" on both plugin and library must be skipped.
+        assertTrue(
+                plan.requiredStep(p2, "ready").skip.get(),
+                "Baseline: ready step of plugin project (p2) should be 
skipped");
+        assertTrue(
+                plan.requiredStep(p3, "ready").skip.get(),
+                "Baseline: ready step of library project (p3) should be 
skipped");
+
+        // Apply the fix: wire PLAN(p1) → READY(p2) and un-skip READY(p2) and 
all its predecessors.
+        // allPredecessors() traverses cross-project edges, so p3's skipped 
steps are also un-skipped.
+        BuildStep planStepP1 = plan.requiredStep(p1, BuildStep.PLAN);
+        BuildStep readyStep = plan.requiredStep(p2, "ready");
+        planStepP1.executeAfter(readyStep);
+        readyStep.allPredecessors().filter(s -> s.skip.get()).forEach(s -> 
s.skip.set(false));
+
+        // After the fix: the plugin project (p2) must be un-skipped all the 
way to READY.
+        assertFalse(
+                plan.requiredStep(p2, "ready").skip.get(),
+                "READY step of the reactor plugin project (p2) must not be 
skipped");
+
+        // Also: the library project (p3) that p2 depends on must be 
un-skipped.
+        assertFalse(
+                plan.requiredStep(p3, "ready").skip.get(),
+                "READY step of the reactor library project (p3) must not be 
skipped — "
+                        + "the plugin (p2) compiles against it and cannot 
reach READY otherwise");
+
+        // Compile steps of both p2 and p3 must also be un-skipped.
+        assertFalse(plan.requiredStep(p2, "compile").skip.get(), "compile step 
of p2 must not be skipped");
+        assertFalse(plan.requiredStep(p3, "compile").skip.get(), "compile step 
of p3 must not be skipped");
+    }
+
     /*
     @Test
     void testPlugins() {
diff --git 
a/its/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng1088ReactorPluginResolutionTest.java
 
b/its/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng1088ReactorPluginResolutionTest.java
index 13ac1a72cf..6b8152a9ed 100644
--- 
a/its/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng1088ReactorPluginResolutionTest.java
+++ 
b/its/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng1088ReactorPluginResolutionTest.java
@@ -20,42 +20,39 @@
 
 import java.io.File;
 
-import org.junit.jupiter.api.Disabled;
 import org.junit.jupiter.api.Test;
 
 /**
  * This is a test set for <a 
href="https://issues.apache.org/jira/browse/MNG-1088";>MNG-1088</a>.
  *
- * @author Brett Porter
+ * <p>Verifies that the concurrent builder automatically builds a reactor 
plugin project up to
+ * the READY phase when another project in the reactor uses that plugin, even 
if the user
+ * requested a phase before "compile" (e.g. "initialize").
  *
+ * @author Brett Porter
  */
-@Disabled("Disabled for MNG-7977")
-public class MavenITmng1088ReactorPluginResolutionTest extends 
AbstractMavenIntegrationTestCase {
+class MavenITmng1088ReactorPluginResolutionTest extends 
AbstractMavenIntegrationTestCase {
 
-    public MavenITmng1088ReactorPluginResolutionTest() {
-        super(ALL_MAVEN_VERSIONS);
+    MavenITmng1088ReactorPluginResolutionTest() {
+        super("[4.0.0-rc-1,)");
     }
 
     /**
-     * Test that the plugin manager falls back to resolution from the 
repository if a plugin is part of the reactor
-     * (i.e. an active project artifact) but the lifecycle has not been 
executed far enough to produce a file for
-     * the plugin (i.e. a phase before "compile").
+     * Test that a reactor plugin is automatically compiled and made available 
when the
+     * concurrent builder detects a cross-project plugin dependency, even when 
the user
+     * only requested a lifecycle phase before "compile" (here: "initialize").
      *
      * @throws Exception in case of failure
      */
     @Test
-    public void testitMNG1088() throws Exception {
+    void testitMNG1088() throws Exception {
         File testDir = extractResources("/mng-1088");
 
         Verifier verifier = newVerifier(testDir.getAbsolutePath());
         verifier.setAutoclean(false);
         verifier.deleteDirectory("client/target");
         verifier.deleteArtifacts("org.apache.maven.its.mng1088");
-        verifier.filterFile("settings-template.xml", "settings.xml");
-        verifier.addCliArgument("--settings");
-        verifier.addCliArgument("settings.xml");
-        // NOTE: It's essential part of the test to invoke a phase before 
"compile"
-        verifier.addCliArgument("initialize");
+        verifier.addCliArguments("-DmavenVersion=" + 
verifier.getMavenVersion(), "-b", "concurrent", "initialize");
         verifier.execute();
         verifier.verifyErrorFreeLog();
 
diff --git a/its/core-it-suite/src/test/resources/mng-1088/client/pom.xml 
b/its/core-it-suite/src/test/resources/mng-1088/client/pom.xml
index d982f7b35e..e2db889464 100644
--- a/its/core-it-suite/src/test/resources/mng-1088/client/pom.xml
+++ b/its/core-it-suite/src/test/resources/mng-1088/client/pom.xml
@@ -17,8 +17,8 @@ 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>
+<project xmlns="http://maven.apache.org/POM/4.1.0";>
+  <modelVersion>4.1.0</modelVersion>
 
   <groupId>org.apache.maven.its.mng1088</groupId>
   <artifactId>client</artifactId>
@@ -26,9 +26,8 @@ under the License.
   <packaging>jar</packaging>
 
   <name>Maven Integration Test :: MNG-1088 :: Plugin Client</name>
-  <description>Test that the plugin manager falls back to resolution from the 
repository if a plugin is part of the reactor
-    (i.e. an active project artifact) but the lifecycle has not been executed 
far enough to produce a file for
-    the plugin (i.e. a phase before "compile").</description>
+  <description>Test that the concurrent builder automatically builds a reactor 
plugin project up to READY
+    when another project uses that plugin, even if the requested phase is 
before "compile".</description>
 
   <build>
     <plugins>
diff --git a/its/core-it-suite/src/test/resources/mng-1088/plugin/pom.xml 
b/its/core-it-suite/src/test/resources/mng-1088/plugin/pom.xml
index 09687bc167..bb3261c83e 100644
--- a/its/core-it-suite/src/test/resources/mng-1088/plugin/pom.xml
+++ b/its/core-it-suite/src/test/resources/mng-1088/plugin/pom.xml
@@ -17,8 +17,8 @@ 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>
+<project xmlns="http://maven.apache.org/POM/4.1.0";>
+  <modelVersion>4.1.0</modelVersion>
 
   <groupId>org.apache.maven.its.mng1088</groupId>
   <artifactId>p</artifactId>
@@ -26,42 +26,40 @@ under the License.
   <packaging>maven-plugin</packaging>
 
   <name>Maven Integration Test :: MNG-1088 :: Plugin</name>
-  <description>Test that the plugin manager falls back to resolution from the 
repository if a plugin is part of the reactor
-    (i.e. an active project artifact) but the lifecycle has not been executed 
far enough to produce a file for
-    the plugin (i.e. a phase before "compile").</description>
-
-  <distributionManagement>
-    <repository>
-      <uniqueVersion>false</uniqueVersion>
-      <id>maven-core-it</id>
-      <url>file:///${basedir}/repo</url>
-    </repository>
-  </distributionManagement>
+  <description>Test that the concurrent builder automatically builds a reactor 
plugin project up to READY
+    when another project uses that plugin, even if the requested phase is 
before "compile".</description>
 
   <properties>
     <maven.test.skip>true</maven.test.skip>
+    <mavenPluginPluginVersion>4.0.0-beta-3</mavenPluginPluginVersion>
   </properties>
 
   <dependencies>
+    <!-- Maven 4 API — available in the reactor-built plugin realm without 
extra JARs -->
+    <dependency>
+      <groupId>org.apache.maven</groupId>
+      <artifactId>maven-api-core</artifactId>
+      <version>${mavenVersion}</version>
+      <scope>provided</scope>
+    </dependency>
     <dependency>
       <groupId>org.apache.maven</groupId>
-      <artifactId>maven-plugin-api</artifactId>
-      <version>3.8.6</version>
+      <artifactId>maven-api-di</artifactId>
+      <version>${mavenVersion}</version>
+      <scope>provided</scope>
     </dependency>
   </dependencies>
 
   <build>
-    <resources>
-      <resource>
-        <directory>.</directory>
-        <includes>
-          <include>pom.xml</include>
-          <include>src/**</include>
-        </includes>
-      </resource>
-      <resource>
-        <directory>src/main/resources</directory>
-      </resource>
-    </resources>
+    <plugins>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-plugin-plugin</artifactId>
+        <version>${mavenPluginPluginVersion}</version>
+        <configuration>
+          <goalPrefix>coreit</goalPrefix>
+        </configuration>
+      </plugin>
+    </plugins>
   </build>
 </project>
diff --git 
a/its/core-it-suite/src/test/resources/mng-1088/plugin/src/main/java/org/apache/maven/plugin/coreit/TouchMojo.java
 
b/its/core-it-suite/src/test/resources/mng-1088/plugin/src/main/java/org/apache/maven/plugin/coreit/TouchMojo.java
index a2ebf93592..57b887dc3a 100644
--- 
a/its/core-it-suite/src/test/resources/mng-1088/plugin/src/main/java/org/apache/maven/plugin/coreit/TouchMojo.java
+++ 
b/its/core-it-suite/src/test/resources/mng-1088/plugin/src/main/java/org/apache/maven/plugin/coreit/TouchMojo.java
@@ -18,61 +18,57 @@
  */
 package org.apache.maven.plugin.coreit;
 
-/*
- * 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.
- */
-
-import java.io.File;
 import java.io.IOException;
+import java.nio.file.Files;
+import java.nio.file.Path;
 
-import org.apache.maven.plugin.AbstractMojo;
-import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.api.Project;
+import org.apache.maven.api.di.Inject;
+import org.apache.maven.api.plugin.Log;
+import org.apache.maven.api.plugin.MojoException;
+import org.apache.maven.api.plugin.annotations.Mojo;
+import org.apache.maven.api.plugin.annotations.Parameter;
 
 /**
  * Creates a text file.
- *
- * @goal touch
- * @phase validate
+ * <p>
+ * This mojo uses the Maven 4 API so that it can be loaded from reactor-built
+ * classes (target/classes/) without requiring the Maven 3 compat jars.
  *
  * @author Benjamin Bentmann
  */
-public class TouchMojo extends AbstractMojo {
+@Mojo(name = "touch", defaultPhase = "validate")
+public class TouchMojo implements org.apache.maven.api.plugin.Mojo {
+
+    @Inject
+    private Log log;
+
+    @Inject
+    private Project project;
 
     /**
      * The path to the output file, relative to the project base directory.
-     *
-     * @parameter expression="${touch.file}" default-value="target/touch.txt"
      */
-    private File file;
+    @Parameter(property = "touch.file", defaultValue = "target/touch.txt")
+    private String file;
 
     /**
      * Runs this mojo.
      *
-     * @throws MojoExecutionException If the output file could not be created.
+     * @throws MojoException If the output file could not be created.
      */
-    public void execute() throws MojoExecutionException {
-        getLog().info("[MAVEN-CORE-IT-LOG] Creating output file: " + file);
+    @Override
+    public void execute() {
+        Path path = project.getBasedir().resolve(file);
+        log.info("[MAVEN-CORE-IT-LOG] Creating output file: " + 
path.toAbsolutePath());
 
         try {
-            file.getParentFile().mkdirs();
-            file.createNewFile();
+            Files.createDirectories(path.getParent());
+            if (!Files.exists(path)) {
+                Files.createFile(path);
+            }
         } catch (IOException e) {
-            throw new MojoExecutionException("Output file could not be 
created: " + file, e);
+            throw new MojoException("Output file could not be created: " + 
path, e);
         }
     }
 }
diff --git a/its/core-it-suite/src/test/resources/mng-1088/pom.xml 
b/its/core-it-suite/src/test/resources/mng-1088/pom.xml
index 30c245651c..880206582b 100644
--- a/its/core-it-suite/src/test/resources/mng-1088/pom.xml
+++ b/its/core-it-suite/src/test/resources/mng-1088/pom.xml
@@ -17,8 +17,8 @@ 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>
+<project xmlns="http://maven.apache.org/POM/4.1.0"; root="true">
+  <modelVersion>4.1.0</modelVersion>
 
   <groupId>org.apache.maven.its.mng1088</groupId>
   <artifactId>aggregator</artifactId>
@@ -26,12 +26,11 @@ under the License.
   <packaging>pom</packaging>
 
   <name>Maven Integration Test :: MNG-1088</name>
-  <description>Test that the plugin manager falls back to resolution from the 
repository if a plugin is part of the reactor
-    (i.e. an active project artifact) but the lifecycle has not been executed 
far enough to produce a file for
-    the plugin (i.e. a phase before "compile").</description>
+  <description>Test that the concurrent builder automatically builds a reactor 
plugin project up to READY
+    when another project uses that plugin, even if the requested phase is 
before "compile".</description>
 
-  <modules>
-    <module>plugin</module>
-    <module>client</module>
-  </modules>
+  <subprojects>
+    <subproject>plugin</subproject>
+    <subproject>client</subproject>
+  </subprojects>
 </project>

Reply via email to