From 9db79b24c5d7833a1def54f36d2ee8eca8794b33 Mon Sep 17 00:00:00 2001 From: Andy Wilkinson Date: Thu, 12 Jun 2025 14:10:55 +0100 Subject: [PATCH] Upgrade to Maven Plugin Tools 3.15.1 Closes gh-45933 --- .../spring-boot-parent/build.gradle | 2 +- .../spring-boot-maven-plugin/build.gradle | 6 ++++-- .../boot/maven/AbstractAotMojo.java | 8 +++++--- .../boot/maven/AbstractPackagerMojo.java | 8 +++++--- .../boot/maven/AbstractRunMojo.java | 8 +++++--- .../boot/maven/BuildImageForkMojo.java | 10 +++++++++- .../boot/maven/BuildImageMojo.java | 5 +++++ .../boot/maven/BuildImageNoForkMojo.java | 10 +++++++++- .../boot/maven/BuildInfoMojo.java | 13 +++++++++---- .../boot/maven/ProcessAotMojo.java | 10 +++++++++- .../boot/maven/ProcessTestAotMojo.java | 17 ++++++++++------- .../boot/maven/RepackageMojo.java | 10 +++++++++- .../org/springframework/boot/maven/RunMojo.java | 10 +++++++++- .../springframework/boot/maven/StartMojo.java | 9 ++++++++- .../springframework/boot/maven/TestRunMojo.java | 10 +++++++++- 15 files changed, 106 insertions(+), 30 deletions(-) diff --git a/spring-boot-project/spring-boot-parent/build.gradle b/spring-boot-project/spring-boot-parent/build.gradle index 573bd1f6b9..ac31b31667 100644 --- a/spring-boot-project/spring-boot-parent/build.gradle +++ b/spring-boot-project/spring-boot-parent/build.gradle @@ -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" diff --git a/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/build.gradle b/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/build.gradle index beb84b6367..65dcca7ef2 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/build.gradle +++ b/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/build.gradle @@ -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") diff --git a/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven/AbstractAotMojo.java b/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven/AbstractAotMojo.java index aae376b296..8bbdca59a9 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven/AbstractAotMojo.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven/AbstractAotMojo.java @@ -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 diff --git a/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven/AbstractPackagerMojo.java b/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven/AbstractPackagerMojo.java index ffc0848a1e..dc4ace6687 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven/AbstractPackagerMojo.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven/AbstractPackagerMojo.java @@ -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 diff --git a/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven/AbstractRunMojo.java b/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven/AbstractRunMojo.java index 0862960283..0595d130c4 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven/AbstractRunMojo.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven/AbstractRunMojo.java @@ -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) { diff --git a/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven/BuildImageForkMojo.java b/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven/BuildImageForkMojo.java index 9ade9bc377..23a6da6bb9 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven/BuildImageForkMojo.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven/BuildImageForkMojo.java @@ -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); + } + } diff --git a/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven/BuildImageMojo.java b/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven/BuildImageMojo.java index 503b23e747..16e8115fa9 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven/BuildImageMojo.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven/BuildImageMojo.java @@ -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 diff --git a/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven/BuildImageNoForkMojo.java b/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven/BuildImageNoForkMojo.java index 495c523476..548aa1217c 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven/BuildImageNoForkMojo.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven/BuildImageNoForkMojo.java @@ -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); + } + } diff --git a/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven/BuildInfoMojo.java b/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven/BuildInfoMojo.java index 9d8319a702..4ff0414bcc 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven/BuildInfoMojo.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven/BuildInfoMojo.java @@ -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) { diff --git a/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven/ProcessAotMojo.java b/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven/ProcessAotMojo.java index ef16eea0ae..ff4affa46a 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven/ProcessAotMojo.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven/ProcessAotMojo.java @@ -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")) { diff --git a/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven/ProcessTestAotMojo.java b/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven/ProcessTestAotMojo.java index efc0ba4f92..b0872da0e5 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven/ProcessTestAotMojo.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven/ProcessTestAotMojo.java @@ -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 { diff --git a/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven/RepackageMojo.java b/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven/RepackageMojo.java index 1808a6380d..588df73e9a 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven/RepackageMojo.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven/RepackageMojo.java @@ -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 diff --git a/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven/RunMojo.java b/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven/RunMojo.java index fc9b9c4403..8b3eab4c03 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven/RunMojo.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven/RunMojo.java @@ -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(); diff --git a/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven/StartMojo.java b/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven/StartMojo.java index d7fda1688c..85406da402 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven/StartMojo.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven/StartMojo.java @@ -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 args, Map environmentVariables) throws MojoExecutionException, MojoFailureException { diff --git a/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven/TestRunMojo.java b/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven/TestRunMojo.java index 5c41d9a3b7..3c129dcd50 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven/TestRunMojo.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven/TestRunMojo.java @@ -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 getClassesDirectories() { ArrayList classesDirectories = new ArrayList<>(super.getClassesDirectories());