This is an automated email from the ASF dual-hosted git repository.
sjaranowski pushed a commit to branch maven-compiler-plugin-3.x
in repository https://gitbox.apache.org/repos/asf/maven-compiler-plugin.git
The following commit(s) were added to refs/heads/maven-compiler-plugin-3.x by
this push:
new db50a3a Bump maven-plugin-testing-harness to 3.4.0
db50a3a is described below
commit db50a3a96ac533843bfc86712b4c9866a239caae
Author: Slawomir Jaranowski <[email protected]>
AuthorDate: Sun Dec 7 11:24:14 2025 +0100
Bump maven-plugin-testing-harness to 3.4.0
---
pom.xml | 2 +-
.../maven/plugin/compiler/CompilerMojoTest.java | 18 ++++--------
.../maven/plugin/compiler/MojoTestUtils.java | 30 -------------------
.../plugin/compiler/TestCompilerMojoTest.java | 14 ++++-----
.../plugin/compiler/stubs/DebugEnabledLog.java | 34 ----------------------
.../compiler-basic-sourcetarget/plugin-config.xml | 4 +--
6 files changed, 14 insertions(+), 88 deletions(-)
diff --git a/pom.xml b/pom.xml
index 10b7a4d..23b2795 100644
--- a/pom.xml
+++ b/pom.xml
@@ -171,7 +171,7 @@ under the License.
<dependency>
<groupId>org.apache.maven.plugin-testing</groupId>
<artifactId>maven-plugin-testing-harness</artifactId>
- <version>4.0.0-alpha-2</version>
+ <version>3.4.0</version>
<scope>test</scope>
</dependency>
<dependency>
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 70be493..a7ec138 100644
--- a/src/test/java/org/apache/maven/plugin/compiler/CompilerMojoTest.java
+++ b/src/test/java/org/apache/maven/plugin/compiler/CompilerMojoTest.java
@@ -20,23 +20,21 @@ package org.apache.maven.plugin.compiler;
import java.io.File;
import java.util.Arrays;
-import java.util.Collections;
import java.util.HashSet;
import java.util.Set;
+import org.apache.maven.api.plugin.testing.InjectMojo;
+import org.apache.maven.api.plugin.testing.MojoTest;
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.junit5.InjectMojo;
-import org.apache.maven.plugin.testing.junit5.MojoTest;
import org.apache.maven.plugin.testing.stubs.ArtifactStub;
import org.junit.jupiter.api.Test;
+import static
org.apache.maven.api.plugin.testing.MojoExtension.getVariableValueFromObject;
+import static
org.apache.maven.api.plugin.testing.MojoExtension.setVariableValueToObject;
import static
org.apache.maven.plugin.compiler.MojoTestUtils.getMockMavenProject;
import static
org.apache.maven.plugin.compiler.MojoTestUtils.getMockMavenSession;
-import static
org.apache.maven.plugin.compiler.MojoTestUtils.getMockMojoExecution;
-import static
org.apache.maven.plugin.compiler.MojoTestUtils.getVariableValueFromObject;
-import static
org.apache.maven.plugin.compiler.MojoTestUtils.setVariableValueToObject;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertNotNull;
@@ -70,7 +68,7 @@ class CompilerMojoTest {
setVariableValueToObject(compilerMojo, "targetOrReleaseSet", false);
compilerMojo.execute();
- Artifact projectArtifact = getVariableValueFromObject(compilerMojo,
"projectArtifact");
+ Artifact projectArtifact = (Artifact)
getVariableValueFromObject(compilerMojo, "projectArtifact");
assertNotNull(
projectArtifact.getFile(),
"MCOMPILER-94: artifact file should only be null if there is
nothing to compile");
@@ -110,7 +108,7 @@ class CompilerMojoTest {
assertFalse(compilerMojo.getOutputDirectory().exists());
- Artifact projectArtifact = getVariableValueFromObject(compilerMojo,
"projectArtifact");
+ Artifact projectArtifact = (Artifact)
getVariableValueFromObject(compilerMojo, "projectArtifact");
assertNull(
projectArtifact.getFile(), "MCOMPILER-94: artifact file should
be null if there is nothing to compile");
}
@@ -296,11 +294,7 @@ class CompilerMojoTest {
private void setUpCompilerMojoTestEnv(CompilerMojo mojo) throws Exception {
setVariableValueToObject(mojo, "projectArtifact", new ArtifactStub());
- setVariableValueToObject(mojo, "compilePath", Collections.EMPTY_LIST);
setVariableValueToObject(mojo, "session", getMockMavenSession());
setVariableValueToObject(mojo, "project", getMockMavenProject());
- setVariableValueToObject(mojo, "mojoExecution",
getMockMojoExecution());
- setVariableValueToObject(mojo, "source",
AbstractCompilerMojo.DEFAULT_SOURCE);
- setVariableValueToObject(mojo, "target",
AbstractCompilerMojo.DEFAULT_TARGET);
}
}
diff --git a/src/test/java/org/apache/maven/plugin/compiler/MojoTestUtils.java
b/src/test/java/org/apache/maven/plugin/compiler/MojoTestUtils.java
index 7173d64..8b38939 100644
--- a/src/test/java/org/apache/maven/plugin/compiler/MojoTestUtils.java
+++ b/src/test/java/org/apache/maven/plugin/compiler/MojoTestUtils.java
@@ -18,33 +18,14 @@
*/
package org.apache.maven.plugin.compiler;
-import java.lang.reflect.Field;
-
import org.apache.maven.execution.MavenSession;
-import org.apache.maven.plugin.MojoExecution;
-import org.apache.maven.plugin.descriptor.MojoDescriptor;
-import org.apache.maven.plugin.descriptor.PluginDescriptor;
import org.apache.maven.project.MavenProject;
-import org.codehaus.plexus.util.ReflectionUtils;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
public class MojoTestUtils {
- public static <T> T getVariableValueFromObject(Object object, String
variable) throws IllegalAccessException {
- Field field =
ReflectionUtils.getFieldByNameIncludingSuperclasses(variable,
object.getClass());
- field.setAccessible(true);
- return (T) field.get(object);
- }
-
- public static <T> void setVariableValueToObject(Object object, String
variable, T value)
- throws IllegalAccessException {
- Field field =
ReflectionUtils.getFieldByNameIncludingSuperclasses(variable,
object.getClass());
- field.setAccessible(true);
- field.set(object, value);
- }
-
public static MavenProject getMockMavenProject() {
MavenProject mp = new MavenProject();
mp.getBuild().setDirectory("target");
@@ -61,15 +42,4 @@ public class MojoTestUtils {
when(session.getCurrentProject()).thenReturn(getMockMavenProject());
return session;
}
-
- public static MojoExecution getMockMojoExecution() {
- MojoDescriptor md = new MojoDescriptor();
- MojoExecution me = new MojoExecution(md);
-
- PluginDescriptor pd = new PluginDescriptor();
- pd.setArtifactId("maven-compiler-plugin");
- md.setPluginDescriptor(pd);
-
- return me;
- }
}
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 a415b76..4f18b77 100644
--- a/src/test/java/org/apache/maven/plugin/compiler/TestCompilerMojoTest.java
+++ b/src/test/java/org/apache/maven/plugin/compiler/TestCompilerMojoTest.java
@@ -26,19 +26,18 @@ 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;
import org.apache.maven.plugin.compiler.stubs.CompilerManagerStub;
-import org.apache.maven.plugin.testing.junit5.InjectMojo;
-import org.apache.maven.plugin.testing.junit5.MojoTest;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.Arguments;
import org.junit.jupiter.params.provider.MethodSource;
+import static
org.apache.maven.api.plugin.testing.MojoExtension.getVariableValueFromObject;
+import static
org.apache.maven.api.plugin.testing.MojoExtension.setVariableValueToObject;
import static
org.apache.maven.plugin.compiler.MojoTestUtils.getMockMavenProject;
import static
org.apache.maven.plugin.compiler.MojoTestUtils.getMockMavenSession;
-import static
org.apache.maven.plugin.compiler.MojoTestUtils.getMockMojoExecution;
-import static
org.apache.maven.plugin.compiler.MojoTestUtils.getVariableValueFromObject;
-import static
org.apache.maven.plugin.compiler.MojoTestUtils.setVariableValueToObject;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;
@@ -171,7 +170,7 @@ class TestCompilerMojoTest {
}
private void setUpCompilerMojoTestEnv(TestCompilerMojo mojo) throws
Exception {
- File buildDir = getVariableValueFromObject(mojo, "buildDirectory");
+ File buildDir = (File) getVariableValueFromObject(mojo,
"buildDirectory");
File testClassesDir = new File(buildDir, "test-classes");
setVariableValueToObject(mojo, "outputDirectory", testClassesDir);
@@ -188,9 +187,6 @@ class TestCompilerMojoTest {
setVariableValueToObject(mojo, "compileSourceRoots",
Arrays.asList(sourceRoot, testSourceRoot));
setVariableValueToObject(mojo, "session", getMockMavenSession());
- setVariableValueToObject(mojo, "mojoExecution",
getMockMojoExecution());
- setVariableValueToObject(mojo, "source",
AbstractCompilerMojo.DEFAULT_SOURCE);
- setVariableValueToObject(mojo, "target",
AbstractCompilerMojo.DEFAULT_TARGET);
}
static Stream<Arguments> olderThanJDK9() {
diff --git
a/src/test/java/org/apache/maven/plugin/compiler/stubs/DebugEnabledLog.java
b/src/test/java/org/apache/maven/plugin/compiler/stubs/DebugEnabledLog.java
deleted file mode 100644
index 4663fa1..0000000
--- a/src/test/java/org/apache/maven/plugin/compiler/stubs/DebugEnabledLog.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * 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.
- */
-package org.apache.maven.plugin.compiler.stubs;
-
-import org.apache.maven.plugin.logging.SystemStreamLog;
-
-/**
- * @author Edwin Punzalan
- */
-public class DebugEnabledLog extends SystemStreamLog {
- public DebugEnabledLog() {
- super();
- }
-
- public boolean isDebugEnabled() {
- return true;
- }
-}
diff --git
a/src/test/resources/unit/compiler-basic-sourcetarget/plugin-config.xml
b/src/test/resources/unit/compiler-basic-sourcetarget/plugin-config.xml
index b4059e0..546047a 100644
--- a/src/test/resources/unit/compiler-basic-sourcetarget/plugin-config.xml
+++ b/src/test/resources/unit/compiler-basic-sourcetarget/plugin-config.xml
@@ -30,8 +30,8 @@
<debug>true</debug>
<outputDirectory>${basedir}/target/test/unit/compiler-basic-test/target/classes</outputDirectory>
<buildDirectory>${basedir}/target/test/unit/compiler-basic-test/target</buildDirectory>
- <source>1.6</source>
- <target>1.6</target>
+ <source>1.8</source>
+ <target>1.8</target>
</configuration>
</plugin>
</plugins>