Upgrade to Maven Plugin Tools 3.15.1

Closes gh-45933
This commit is contained in:
Andy Wilkinson
2025-06-12 14:10:55 +01:00
parent 3b1f058b62
commit 9db79b24c5
15 changed files with 106 additions and 30 deletions

View File

@@ -124,7 +124,7 @@ bom {
]
}
}
library("Maven Plugin Tools", "3.9.0") {
library("Maven Plugin Tools", "3.15.1") {
group("org.apache.maven.plugin-tools") {
modules = [
"maven-plugin-annotations"

View File

@@ -15,12 +15,10 @@ dependencies {
compileOnly("org.apache.maven.plugin-tools:maven-plugin-annotations")
compileOnly("org.apache.maven:maven-core") {
exclude(group: "javax.annotation", module: "javax.annotation-api")
exclude(group: "javax.inject", module: "javax.inject")
}
compileOnly("org.apache.maven:maven-plugin-api") {
exclude(group: "javax.annotation", module: "javax.annotation-api")
exclude(group: "javax.enterprise", module: "cdi-api")
exclude(group: "javax.inject", module: "javax.inject")
}
dockerTestImplementation(project(":spring-boot-project:spring-boot-tools:spring-boot-test-support-docker"))
@@ -90,6 +88,10 @@ ext {
xsdVersion = versionElements[0] + "." + versionElements[1]
}
tasks.named("checkCompileClasspathForProhibitedDependencies") {
permittedGroups = ["javax.inject"]
}
tasks.register("copySettingsXml", Copy) {
from file("src/intTest/projects/settings.xml")
into layout.buildDirectory.dir("generated-resources/settings")

View File

@@ -41,7 +41,6 @@ import javax.tools.ToolProvider;
import org.apache.maven.execution.MavenSession;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.MojoFailureException;
import org.apache.maven.plugins.annotations.Component;
import org.apache.maven.plugins.annotations.Parameter;
import org.apache.maven.shared.artifact.filter.collection.ArtifactsFilter;
import org.apache.maven.toolchain.ToolchainManager;
@@ -65,8 +64,7 @@ public abstract class AbstractAotMojo extends AbstractDependencyFilterMojo {
/**
* The toolchain manager to use to locate a custom JDK.
*/
@Component
private ToolchainManager toolchainManager;
private final ToolchainManager toolchainManager;
/**
* Skip the execution.
@@ -94,6 +92,10 @@ public abstract class AbstractAotMojo extends AbstractDependencyFilterMojo {
@Parameter(property = "spring-boot.aot.compilerArguments")
private String compilerArguments;
protected AbstractAotMojo(ToolchainManager toolchainManager) {
this.toolchainManager = toolchainManager;
}
/**
* Return Maven execution session.
* @return session

View File

@@ -31,7 +31,6 @@ import org.apache.maven.artifact.Artifact;
import org.apache.maven.execution.MavenSession;
import org.apache.maven.model.Dependency;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugins.annotations.Component;
import org.apache.maven.plugins.annotations.Parameter;
import org.apache.maven.project.MavenProject;
import org.apache.maven.project.MavenProjectHelper;
@@ -81,8 +80,7 @@ public abstract class AbstractPackagerMojo extends AbstractDependencyFilterMojo
* Maven project helper utils.
* @since 1.0.0
*/
@Component
protected MavenProjectHelper projectHelper;
protected final MavenProjectHelper projectHelper;
/**
* The name of the main class. If not specified the first compiled class found that
@@ -128,6 +126,10 @@ public abstract class AbstractPackagerMojo extends AbstractDependencyFilterMojo
@Parameter
private Layers layers = new Layers();
protected AbstractPackagerMojo(MavenProjectHelper projectHelper) {
this.projectHelper = projectHelper;
}
/**
* Return the type of archive that should be packaged by this MOJO.
* @return {@code null}, indicating a layout type will be chosen based on the original

View File

@@ -33,7 +33,6 @@ import org.apache.maven.execution.MavenSession;
import org.apache.maven.model.Resource;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.MojoFailureException;
import org.apache.maven.plugins.annotations.Component;
import org.apache.maven.plugins.annotations.Parameter;
import org.apache.maven.project.MavenProject;
import org.apache.maven.toolchain.ToolchainManager;
@@ -76,8 +75,7 @@ public abstract class AbstractRunMojo extends AbstractDependencyFilterMojo {
*
* @since 2.3.0
*/
@Component
private ToolchainManager toolchainManager;
private final ToolchainManager toolchainManager;
/**
* Add maven resources to the classpath directly, this allows live in-place editing of
@@ -205,6 +203,10 @@ public abstract class AbstractRunMojo extends AbstractDependencyFilterMojo {
@Parameter(property = "spring-boot.run.skip", defaultValue = "false")
private boolean skip;
protected AbstractRunMojo(ToolchainManager toolchainManager) {
this.toolchainManager = toolchainManager;
}
@Override
public void execute() throws MojoExecutionException, MojoFailureException {
if (this.skip) {

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2023 the original author or authors.
* Copyright 2012-2025 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -16,10 +16,13 @@
package org.springframework.boot.maven;
import javax.inject.Inject;
import org.apache.maven.plugins.annotations.Execute;
import org.apache.maven.plugins.annotations.LifecyclePhase;
import org.apache.maven.plugins.annotations.Mojo;
import org.apache.maven.plugins.annotations.ResolutionScope;
import org.apache.maven.project.MavenProjectHelper;
/**
* Package an application into an OCI image using a buildpack, forking the lifecycle to
@@ -36,4 +39,9 @@ import org.apache.maven.plugins.annotations.ResolutionScope;
@Execute(phase = LifecyclePhase.PACKAGE)
public class BuildImageForkMojo extends BuildImageMojo {
@Inject
public BuildImageForkMojo(MavenProjectHelper projectHelper) {
super(projectHelper);
}
}

View File

@@ -33,6 +33,7 @@ import org.apache.maven.artifact.Artifact;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.logging.Log;
import org.apache.maven.plugins.annotations.Parameter;
import org.apache.maven.project.MavenProjectHelper;
import org.springframework.boot.buildpack.platform.build.AbstractBuildLog;
import org.springframework.boot.buildpack.platform.build.BuildLog;
@@ -219,6 +220,10 @@ public abstract class BuildImageMojo extends AbstractPackagerMojo {
@Parameter
private LayoutFactory layoutFactory;
protected BuildImageMojo(MavenProjectHelper projectHelper) {
super(projectHelper);
}
/**
* Return the type of archive that should be used when building the image.
* @return the value of the {@code layout} parameter, or {@code null} if the parameter

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2023 the original author or authors.
* Copyright 2012-2025 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -16,9 +16,12 @@
package org.springframework.boot.maven;
import javax.inject.Inject;
import org.apache.maven.plugins.annotations.LifecyclePhase;
import org.apache.maven.plugins.annotations.Mojo;
import org.apache.maven.plugins.annotations.ResolutionScope;
import org.apache.maven.project.MavenProjectHelper;
/**
* Package an application into an OCI image using a buildpack, but without forking the
@@ -33,4 +36,9 @@ import org.apache.maven.plugins.annotations.ResolutionScope;
requiresDependencyCollection = ResolutionScope.COMPILE_PLUS_RUNTIME)
public class BuildImageNoForkMojo extends BuildImageMojo {
@Inject
public BuildImageNoForkMojo(MavenProjectHelper projectHelper) {
super(projectHelper);
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2024 the original author or authors.
* Copyright 2012-2025 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -23,11 +23,12 @@ import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import javax.inject.Inject;
import org.apache.maven.execution.MavenSession;
import org.apache.maven.plugin.AbstractMojo;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.MojoFailureException;
import org.apache.maven.plugins.annotations.Component;
import org.apache.maven.plugins.annotations.LifecyclePhase;
import org.apache.maven.plugins.annotations.Mojo;
import org.apache.maven.plugins.annotations.Parameter;
@@ -49,8 +50,7 @@ import org.springframework.boot.loader.tools.BuildPropertiesWriter.ProjectDetail
@Mojo(name = "build-info", defaultPhase = LifecyclePhase.GENERATE_RESOURCES, threadSafe = true)
public class BuildInfoMojo extends AbstractMojo {
@Component
private BuildContext buildContext;
private final BuildContext buildContext;
/**
* The Maven session.
@@ -104,6 +104,11 @@ public class BuildInfoMojo extends AbstractMojo {
@Parameter(property = "spring-boot.build-info.skip", defaultValue = "false")
private boolean skip;
@Inject
public BuildInfoMojo(BuildContext buildContext) {
this.buildContext = buildContext;
}
@Override
public void execute() throws MojoExecutionException, MojoFailureException {
if (this.skip) {

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2024 the original author or authors.
* Copyright 2012-2025 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -21,10 +21,13 @@ import java.net.URL;
import java.util.ArrayList;
import java.util.List;
import javax.inject.Inject;
import org.apache.maven.plugins.annotations.LifecyclePhase;
import org.apache.maven.plugins.annotations.Mojo;
import org.apache.maven.plugins.annotations.Parameter;
import org.apache.maven.plugins.annotations.ResolutionScope;
import org.apache.maven.toolchain.ToolchainManager;
import org.springframework.util.ObjectUtils;
@@ -86,6 +89,11 @@ public class ProcessAotMojo extends AbstractAotMojo {
@Parameter
private String[] profiles;
@Inject
public ProcessAotMojo(ToolchainManager toolchainManager) {
super(toolchainManager);
}
@Override
protected void executeAot() throws Exception {
if (this.project.getPackaging().equals("pom")) {

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2024 the original author or authors.
* Copyright 2012-2025 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -28,17 +28,18 @@ import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;
import javax.inject.Inject;
import org.apache.maven.RepositoryUtils;
import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.DefaultArtifact;
import org.apache.maven.artifact.handler.DefaultArtifactHandler;
import org.apache.maven.artifact.resolver.ResolutionErrorHandler;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugins.annotations.Component;
import org.apache.maven.plugins.annotations.LifecyclePhase;
import org.apache.maven.plugins.annotations.Mojo;
import org.apache.maven.plugins.annotations.Parameter;
import org.apache.maven.plugins.annotations.ResolutionScope;
import org.apache.maven.toolchain.ToolchainManager;
import org.eclipse.aether.RepositorySystem;
import org.eclipse.aether.collection.CollectRequest;
import org.eclipse.aether.resolution.ArtifactResult;
@@ -103,11 +104,13 @@ public class ProcessTestAotMojo extends AbstractAotMojo {
@Parameter(defaultValue = "${project.build.directory}/spring-aot/main/classes", required = true)
private File generatedClasses;
@Component
private RepositorySystem repositorySystem;
private final RepositorySystem repositorySystem;
@Component
private ResolutionErrorHandler resolutionErrorHandler;
@Inject
public ProcessTestAotMojo(ToolchainManager toolchainManager, RepositorySystem repositorySystem) {
super(toolchainManager);
this.repositorySystem = repositorySystem;
}
@Override
protected void executeAot() throws Exception {

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2024 the original author or authors.
* Copyright 2012-2025 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -23,6 +23,8 @@ import java.util.List;
import java.util.Properties;
import java.util.regex.Pattern;
import javax.inject.Inject;
import org.apache.maven.artifact.Artifact;
import org.apache.maven.model.Dependency;
import org.apache.maven.plugin.MojoExecutionException;
@@ -31,6 +33,7 @@ import org.apache.maven.plugins.annotations.LifecyclePhase;
import org.apache.maven.plugins.annotations.Mojo;
import org.apache.maven.plugins.annotations.Parameter;
import org.apache.maven.plugins.annotations.ResolutionScope;
import org.apache.maven.project.MavenProjectHelper;
import org.springframework.boot.loader.tools.DefaultLaunchScript;
import org.springframework.boot.loader.tools.LaunchScript;
@@ -179,6 +182,11 @@ public class RepackageMojo extends AbstractPackagerMojo {
@Parameter
private LayoutFactory layoutFactory;
@Inject
public RepackageMojo(MavenProjectHelper projectHelper) {
super(projectHelper);
}
/**
* Return the type of archive that should be packaged by this MOJO.
* @return the value of the {@code layout} parameter, or {@code null} if the parameter

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2023 the original author or authors.
* Copyright 2012-2025 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -20,6 +20,8 @@ import java.io.File;
import java.util.List;
import java.util.Map;
import javax.inject.Inject;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.MojoFailureException;
import org.apache.maven.plugins.annotations.Execute;
@@ -27,6 +29,7 @@ import org.apache.maven.plugins.annotations.LifecyclePhase;
import org.apache.maven.plugins.annotations.Mojo;
import org.apache.maven.plugins.annotations.Parameter;
import org.apache.maven.plugins.annotations.ResolutionScope;
import org.apache.maven.toolchain.ToolchainManager;
import org.springframework.boot.loader.tools.RunProcess;
@@ -58,6 +61,11 @@ public class RunMojo extends AbstractRunMojo {
@Parameter(property = "spring-boot.run.useTestClasspath", defaultValue = "false")
private Boolean useTestClasspath;
@Inject
public RunMojo(ToolchainManager toolchainManager) {
super(toolchainManager);
}
@Override
protected RunArguments resolveJvmArguments() {
RunArguments jvmArguments = super.resolveJvmArguments();

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2023 the original author or authors.
* Copyright 2012-2025 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -24,6 +24,7 @@ import java.util.List;
import java.util.Map;
import java.util.concurrent.Callable;
import javax.inject.Inject;
import javax.management.MBeanServerConnection;
import javax.management.ReflectionException;
import javax.management.remote.JMXConnector;
@@ -34,6 +35,7 @@ import org.apache.maven.plugins.annotations.LifecyclePhase;
import org.apache.maven.plugins.annotations.Mojo;
import org.apache.maven.plugins.annotations.Parameter;
import org.apache.maven.plugins.annotations.ResolutionScope;
import org.apache.maven.toolchain.ToolchainManager;
import org.springframework.boot.loader.tools.RunProcess;
@@ -91,6 +93,11 @@ public class StartMojo extends AbstractRunMojo {
@Parameter(property = "spring-boot.run.useTestClasspath", defaultValue = "false")
private Boolean useTestClasspath;
@Inject
public StartMojo(ToolchainManager toolchainManager) {
super(toolchainManager);
}
@Override
protected void run(JavaProcessExecutor processExecutor, File workingDirectory, List<String> args,
Map<String, String> environmentVariables) throws MojoExecutionException, MojoFailureException {

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2023 the original author or authors.
* Copyright 2012-2025 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -21,6 +21,8 @@ import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import javax.inject.Inject;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.MojoFailureException;
import org.apache.maven.plugins.annotations.Execute;
@@ -28,6 +30,7 @@ import org.apache.maven.plugins.annotations.LifecyclePhase;
import org.apache.maven.plugins.annotations.Mojo;
import org.apache.maven.plugins.annotations.Parameter;
import org.apache.maven.plugins.annotations.ResolutionScope;
import org.apache.maven.toolchain.ToolchainManager;
import org.springframework.boot.loader.tools.RunProcess;
@@ -61,6 +64,11 @@ public class TestRunMojo extends AbstractRunMojo {
@Parameter(defaultValue = "${project.build.testOutputDirectory}", required = true)
private File testClassesDirectory;
@Inject
public TestRunMojo(ToolchainManager toolchainManager) {
super(toolchainManager);
}
@Override
protected List<File> getClassesDirectories() {
ArrayList<File> classesDirectories = new ArrayList<>(super.getClassesDirectories());