Skip to content

Bump org.apache.maven.plugins:maven-plugins from 43 to 44 #328

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ under the License.
<parent>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-plugins</artifactId>
<version>43</version>
<version>44</version>
<relativePath />
</parent>

Expand Down Expand Up @@ -88,7 +88,6 @@ under the License.
<guiceVersion>6.0.0</guiceVersion>
<mockitoVersion>5.17.0</mockitoVersion>
<mavenPluginTestingHarnessVersion>4.0.0-beta-4</mavenPluginTestingHarnessVersion>
<plexusCompilerVersion>2.15.0</plexusCompilerVersion>
<sisuPlexusVersion>0.9.0.M2</sisuPlexusVersion>
<version.maven-plugin-tools-3.x>3.13.1</version.maven-plugin-tools-3.x>
<version.maven-plugin-tools>4.0.0-beta-1</version.maven-plugin-tools>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
package org.apache.maven.plugin.compiler;

import java.io.File;
import java.io.IOException;
import java.io.UncheckedIOException;
import java.net.URI;
import java.nio.file.Files;
import java.nio.file.Path;
Expand Down Expand Up @@ -48,7 +50,6 @@
import org.apache.maven.api.plugin.testing.stubs.SessionMock;
import org.apache.maven.api.services.ArtifactManager;
import org.apache.maven.api.services.MessageBuilderFactory;
import org.apache.maven.api.services.ProjectManager;
import org.apache.maven.api.services.ToolchainManager;
import org.apache.maven.impl.DefaultMessageBuilderFactory;
import org.apache.maven.impl.InternalSession;
Expand Down Expand Up @@ -79,16 +80,33 @@ public class CompilerMojoTestCase {
@Inject
private Session session;

/**
* Verifies that the {@value CompilerStub#OUTPUT_FILE} file exists, then deletes it.
* The deletion is necessary for preventing an {@link IndexOutOfBoundsException} in
* {@code maven-dependency-plugin} version 3.8.1, because the output file is empty.
*
* @param mojo the tested mojo
*/
private static void assertCompilerStubOutputFileExists(AbstractCompilerMojo mojo) {
try {
Files.delete(assertOutputFileExists(mojo, CompilerStub.OUTPUT_FILE));
} catch (IOException e) {
throw new UncheckedIOException(e);
}
}

/**
* Verifies that the given output file exists.
*
* @param mojo the tested mojo
* @param first the first path element
* @param more the other path elements, if any
* @return the file
*/
private static void assertOutputFileExists(AbstractCompilerMojo mojo, String first, String... more) {
private static Path assertOutputFileExists(AbstractCompilerMojo mojo, String first, String... more) {
Path file = mojo.getOutputDirectory().resolve(Path.of(first, more));
assertTrue(Files.isRegularFile(file), () -> "File not found: " + file);
return file;
}

/**
Expand Down Expand Up @@ -228,11 +246,11 @@ public void testOneOutputFileForAllInput(

assertEquals(CompilerStub.COMPILER_ID, compileMojo.compilerId);
compileMojo.execute();
assertOutputFileExists(compileMojo, CompilerStub.OUTPUT_FILE);
assertCompilerStubOutputFileExists(compileMojo);

assertEquals(CompilerStub.COMPILER_ID, testCompileMojo.compilerId);
testCompileMojo.execute();
assertOutputFileExists(testCompileMojo, CompilerStub.OUTPUT_FILE);
assertCompilerStubOutputFileExists(testCompileMojo);
}

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

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

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ public class CompilerStub implements JavaCompiler, StandardJavaFileManager {
*
* @see #getOptions()
*/
private static final ThreadLocal<Iterable<String>> arguments = new ThreadLocal<>();
private static final ThreadLocal<Iterable<String>> ARGUMENTS = new ThreadLocal<>();

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

arguments.set(options);
ARGUMENTS.set(options);
return new CompilationTask() {
@Override
public void addModules(Iterable<String> moduleNames) {}
Expand Down Expand Up @@ -354,7 +354,7 @@ public int run(InputStream in, OutputStream out, OutputStream err, String... arg
*/
public static List<String> getOptions() {
var options = new ArrayList<String>();
Iterable<String> args = arguments.get();
Iterable<String> args = ARGUMENTS.get();
if (args != null) {
args.forEach(options::add);
}
Expand Down