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

slachiewicz pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/maven-compiler-plugin.git

commit a14e989a7964725d40b9b72d053d8099f165e735
Author: Sylwester Lachiewicz <[email protected]>
AuthorDate: Fri Nov 6 17:47:09 2026 +0000

    Delete the JPMS test output with JDK APIs, check the compile ran, skip 
without a system compiler
---
 .../apache/maven/plugin/compiler/CompilerMojoTest.java   | 16 +++++++++++++---
 .../maven/plugin/compiler/TestCompilerMojoTest.java      |  2 ++
 2 files changed, 15 insertions(+), 3 deletions(-)

diff --git 
a/src/test/java/org/apache/maven/plugin/compiler/CompilerMojoTest.java 
b/src/test/java/org/apache/maven/plugin/compiler/CompilerMojoTest.java
index c2a22ae7..78bc5598 100644
--- a/src/test/java/org/apache/maven/plugin/compiler/CompilerMojoTest.java
+++ b/src/test/java/org/apache/maven/plugin/compiler/CompilerMojoTest.java
@@ -22,8 +22,10 @@ import java.io.File;
 import java.nio.file.Files;
 import java.nio.file.Path;
 import java.util.Arrays;
+import java.util.Comparator;
 import java.util.HashSet;
 import java.util.Set;
+import java.util.stream.Stream;
 
 import org.apache.maven.api.plugin.testing.InjectMojo;
 import org.apache.maven.api.plugin.testing.MojoTest;
@@ -31,7 +33,6 @@ import org.apache.maven.artifact.Artifact;
 import org.apache.maven.plugin.compiler.stubs.CompilerManagerStub;
 import org.apache.maven.plugin.logging.Log;
 import org.apache.maven.plugin.testing.stubs.ArtifactStub;
-import org.codehaus.plexus.util.FileUtils;
 import org.junit.jupiter.api.Test;
 import org.junit.jupiter.api.condition.EnabledForJreRange;
 import org.junit.jupiter.api.condition.JRE;
@@ -356,11 +357,20 @@ class CompilerMojoTest {
         // The mojo only writes jpms.args when it compiles, and only logs a 
warning when it cannot write it, while
         // target/ keeps the classes of earlier runs (the next run would find 
nothing to compile). Start from an empty
         // output directory so the assertion reads this run's file.
-        FileUtils.deleteDirectory(compilerMojo.getOutputDirectory());
-        Path jpmsArgs = 
compilerMojo.getOutputDirectory().toPath().resolve("META-INF/jpms.args");
+        Path output = compilerMojo.getOutputDirectory().toPath();
+        if (Files.exists(output)) {
+            try (Stream<Path> paths = Files.walk(output)) {
+                for (Path path : (Iterable<Path>) 
paths.sorted(Comparator.reverseOrder())::iterator) {
+                    Files.delete(path);
+                }
+            }
+        }
+        Path jpmsArgs = output.resolve("META-INF/jpms.args");
 
         compilerMojo.execute();
 
+        assertTrue(Files.exists(output.resolve("org/maven/test/Main.class")), 
"the module was not compiled");
+        assertTrue(Files.exists(jpmsArgs), "the module was compiled, but 
META-INF/jpms.args was not written");
         assertEquals(Arrays.asList("--add-exports", 
"app/org.maven.test=ALL-UNNAMED"), Files.readAllLines(jpmsArgs));
     }
 
diff --git 
a/src/test/java/org/apache/maven/plugin/compiler/TestCompilerMojoTest.java 
b/src/test/java/org/apache/maven/plugin/compiler/TestCompilerMojoTest.java
index 08e5b1de..ecc4fc42 100644
--- a/src/test/java/org/apache/maven/plugin/compiler/TestCompilerMojoTest.java
+++ b/src/test/java/org/apache/maven/plugin/compiler/TestCompilerMojoTest.java
@@ -50,6 +50,7 @@ import static 
org.apache.maven.plugin.compiler.MojoTestUtils.getMockMavenSession
 import static org.junit.jupiter.api.Assertions.assertEquals;
 import static org.junit.jupiter.api.Assertions.assertFalse;
 import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assumptions.assumeTrue;
 
 @MojoTest
 class TestCompilerMojoTest {
@@ -195,6 +196,7 @@ class TestCompilerMojoTest {
                 .getParent();
         Path mainSources = fixture.resolve("src/main/java");
         JavaCompiler javac = ToolProvider.getSystemJavaCompiler();
+        assumeTrue(javac != null, "needs the JDK's system Java compiler");
         assertEquals(
                 0,
                 javac.run(

Reply via email to