Skip to content

Commit c810da3

Browse files
committed
Bump org.apache.maven.plugins:maven-plugins from 43 to 44.
Requires resolutions of new Checkstyle errors and deletion of the output file of the stub compiler for avoiding an `IndexOutOfBoundsException` in `maven-dependency-plugin`.
1 parent 9acdc09 commit c810da3

File tree

3 files changed

+27
-12
lines changed

3 files changed

+27
-12
lines changed

pom.xml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ under the License.
2323
<parent>
2424
<groupId>org.apache.maven.plugins</groupId>
2525
<artifactId>maven-plugins</artifactId>
26-
<version>43</version>
26+
<version>44</version>
2727
<relativePath />
2828
</parent>
2929

@@ -88,9 +88,7 @@ under the License.
8888
<guiceVersion>6.0.0</guiceVersion>
8989
<mockitoVersion>5.17.0</mockitoVersion>
9090
<mavenPluginTestingHarnessVersion>4.0.0-beta-4</mavenPluginTestingHarnessVersion>
91-
<plexusCompilerVersion>2.15.0</plexusCompilerVersion>
9291
<sisuPlexusVersion>0.9.0.M2</sisuPlexusVersion>
93-
<version.maven-plugin-tools-3.x>3.13.1</version.maven-plugin-tools-3.x>
9492
<version.maven-plugin-tools>4.0.0-beta-1</version.maven-plugin-tools>
9593

9694
<invoker.junitPackageName>org.apache.maven.plugins.compiler.its</invoker.junitPackageName>

src/test/java/org/apache/maven/plugin/compiler/CompilerMojoTestCase.java

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919
package org.apache.maven.plugin.compiler;
2020

2121
import java.io.File;
22+
import java.io.IOException;
23+
import java.io.UncheckedIOException;
2224
import java.net.URI;
2325
import java.nio.file.Files;
2426
import java.nio.file.Path;
@@ -48,7 +50,6 @@
4850
import org.apache.maven.api.plugin.testing.stubs.SessionMock;
4951
import org.apache.maven.api.services.ArtifactManager;
5052
import org.apache.maven.api.services.MessageBuilderFactory;
51-
import org.apache.maven.api.services.ProjectManager;
5253
import org.apache.maven.api.services.ToolchainManager;
5354
import org.apache.maven.impl.DefaultMessageBuilderFactory;
5455
import org.apache.maven.impl.InternalSession;
@@ -79,16 +80,33 @@ public class CompilerMojoTestCase {
7980
@Inject
8081
private Session session;
8182

83+
/**
84+
* Verifies that the {@value CompilerStub#OUTPUT_FILE} file exists, then deletes it.
85+
* The deletion is necessary for preventing an {@link IndexOutOfBoundsException} in
86+
* {@code maven-dependency-plugin} version 3.8.1, because the output file is empty.
87+
*
88+
* @param mojo the tested mojo
89+
*/
90+
private static void assertCompilerStubOutputFileExists(AbstractCompilerMojo mojo) {
91+
try {
92+
Files.delete(assertOutputFileExists(mojo, CompilerStub.OUTPUT_FILE));
93+
} catch (IOException e) {
94+
throw new UncheckedIOException(e);
95+
}
96+
}
97+
8298
/**
8399
* Verifies that the given output file exists.
84100
*
85101
* @param mojo the tested mojo
86102
* @param first the first path element
87103
* @param more the other path elements, if any
104+
* @return the file
88105
*/
89-
private static void assertOutputFileExists(AbstractCompilerMojo mojo, String first, String... more) {
106+
private static Path assertOutputFileExists(AbstractCompilerMojo mojo, String first, String... more) {
90107
Path file = mojo.getOutputDirectory().resolve(Path.of(first, more));
91108
assertTrue(Files.isRegularFile(file), () -> "File not found: " + file);
109+
return file;
92110
}
93111

94112
/**
@@ -228,11 +246,11 @@ public void testOneOutputFileForAllInput(
228246

229247
assertEquals(CompilerStub.COMPILER_ID, compileMojo.compilerId);
230248
compileMojo.execute();
231-
assertOutputFileExists(compileMojo, CompilerStub.OUTPUT_FILE);
249+
assertCompilerStubOutputFileExists(compileMojo);
232250

233251
assertEquals(CompilerStub.COMPILER_ID, testCompileMojo.compilerId);
234252
testCompileMojo.execute();
235-
assertOutputFileExists(testCompileMojo, CompilerStub.OUTPUT_FILE);
253+
assertCompilerStubOutputFileExists(testCompileMojo);
236254
}
237255

238256
/**
@@ -245,7 +263,7 @@ public void testCompilerArgs(@InjectMojo(goal = "compile", pom = "plugin-config.
245263
assertEquals(CompilerStub.COMPILER_ID, compileMojo.compilerId);
246264
compileMojo.execute();
247265

248-
assertOutputFileExists(compileMojo, CompilerStub.OUTPUT_FILE);
266+
assertCompilerStubOutputFileExists(compileMojo);
249267
assertArrayEquals(
250268
new String[] {"key1=value1", "-Xlint", "-my&special:param-with+chars/not>allowed_in_XML_element_names"},
251269
compileMojo.compilerArgs.toArray(String[]::new));
@@ -429,7 +447,6 @@ private static InternalSession createSession() {
429447
throw new RuntimeException("Unable to setup junit jar path", e);
430448
}
431449

432-
ProjectManager projectManager = session.getService(ProjectManager.class);
433450
doAnswer(iom -> List.of()).when(session).resolveDependencies(any(), eq(PathScope.MAIN_COMPILE));
434451
doAnswer(iom -> artifacts).when(session).resolveDependencies(any(), eq(PathScope.TEST_COMPILE));
435452

src/test/java/org/apache/maven/plugin/compiler/stubs/CompilerStub.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ public class CompilerStub implements JavaCompiler, StandardJavaFileManager {
8585
*
8686
* @see #getOptions()
8787
*/
88-
private static final ThreadLocal<Iterable<String>> arguments = new ThreadLocal<>();
88+
private static final ThreadLocal<Iterable<String>> ARGUMENTS = new ThreadLocal<>();
8989

9090
/**
9191
* Invoked by reflection by {@link java.util.ServiceLoader}.
@@ -309,7 +309,7 @@ public CompilationTask getTask(
309309
Iterable<String> classes,
310310
Iterable<? extends JavaFileObject> compilationUnits) {
311311

312-
arguments.set(options);
312+
ARGUMENTS.set(options);
313313
return new CompilationTask() {
314314
@Override
315315
public void addModules(Iterable<String> moduleNames) {}
@@ -354,7 +354,7 @@ public int run(InputStream in, OutputStream out, OutputStream err, String... arg
354354
*/
355355
public static List<String> getOptions() {
356356
var options = new ArrayList<String>();
357-
Iterable<String> args = arguments.get();
357+
Iterable<String> args = ARGUMENTS.get();
358358
if (args != null) {
359359
args.forEach(options::add);
360360
}

0 commit comments

Comments
 (0)