Skip to content

Commit 2c23417

Browse files
committed
Upgrade to Maven Plugin Tools 3.15.1
Closes gh-45905
1 parent 4996c70 commit 2c23417

File tree

15 files changed

+106
-30
lines changed

15 files changed

+106
-30
lines changed

spring-boot-project/spring-boot-parent/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ bom {
124124
]
125125
}
126126
}
127-
library("Maven Plugin Tools", "3.9.0") {
127+
library("Maven Plugin Tools", "3.15.1") {
128128
group("org.apache.maven.plugin-tools") {
129129
modules = [
130130
"maven-plugin-annotations"

spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/build.gradle

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,10 @@ dependencies {
1515
compileOnly("org.apache.maven.plugin-tools:maven-plugin-annotations")
1616
compileOnly("org.apache.maven:maven-core") {
1717
exclude(group: "javax.annotation", module: "javax.annotation-api")
18-
exclude(group: "javax.inject", module: "javax.inject")
1918
}
2019
compileOnly("org.apache.maven:maven-plugin-api") {
2120
exclude(group: "javax.annotation", module: "javax.annotation-api")
2221
exclude(group: "javax.enterprise", module: "cdi-api")
23-
exclude(group: "javax.inject", module: "javax.inject")
2422
}
2523

2624
dockerTestImplementation(project(":spring-boot-project:spring-boot-tools:spring-boot-test-support-docker"))
@@ -90,6 +88,10 @@ ext {
9088
xsdVersion = versionElements[0] + "." + versionElements[1]
9189
}
9290

91+
tasks.named("checkCompileClasspathForProhibitedDependencies") {
92+
permittedGroups = ["javax.inject"]
93+
}
94+
9395
tasks.register("copySettingsXml", Copy) {
9496
from file("src/intTest/projects/settings.xml")
9597
into layout.buildDirectory.dir("generated-resources/settings")

spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven/AbstractAotMojo.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@
4141
import org.apache.maven.execution.MavenSession;
4242
import org.apache.maven.plugin.MojoExecutionException;
4343
import org.apache.maven.plugin.MojoFailureException;
44-
import org.apache.maven.plugins.annotations.Component;
4544
import org.apache.maven.plugins.annotations.Parameter;
4645
import org.apache.maven.shared.artifact.filter.collection.ArtifactsFilter;
4746
import org.apache.maven.toolchain.ToolchainManager;
@@ -65,8 +64,7 @@ public abstract class AbstractAotMojo extends AbstractDependencyFilterMojo {
6564
/**
6665
* The toolchain manager to use to locate a custom JDK.
6766
*/
68-
@Component
69-
private ToolchainManager toolchainManager;
67+
private final ToolchainManager toolchainManager;
7068

7169
/**
7270
* Skip the execution.
@@ -94,6 +92,10 @@ public abstract class AbstractAotMojo extends AbstractDependencyFilterMojo {
9492
@Parameter(property = "spring-boot.aot.compilerArguments")
9593
private String compilerArguments;
9694

95+
protected AbstractAotMojo(ToolchainManager toolchainManager) {
96+
this.toolchainManager = toolchainManager;
97+
}
98+
9799
/**
98100
* Return Maven execution session.
99101
* @return session

spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven/AbstractPackagerMojo.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@
3131
import org.apache.maven.execution.MavenSession;
3232
import org.apache.maven.model.Dependency;
3333
import org.apache.maven.plugin.MojoExecutionException;
34-
import org.apache.maven.plugins.annotations.Component;
3534
import org.apache.maven.plugins.annotations.Parameter;
3635
import org.apache.maven.project.MavenProject;
3736
import org.apache.maven.project.MavenProjectHelper;
@@ -81,8 +80,7 @@ public abstract class AbstractPackagerMojo extends AbstractDependencyFilterMojo
8180
* Maven project helper utils.
8281
* @since 1.0.0
8382
*/
84-
@Component
85-
protected MavenProjectHelper projectHelper;
83+
protected final MavenProjectHelper projectHelper;
8684

8785
/**
8886
* 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
128126
@Parameter
129127
private Layers layers = new Layers();
130128

129+
protected AbstractPackagerMojo(MavenProjectHelper projectHelper) {
130+
this.projectHelper = projectHelper;
131+
}
132+
131133
/**
132134
* Return the type of archive that should be packaged by this MOJO.
133135
* @return {@code null}, indicating a layout type will be chosen based on the original

spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven/AbstractRunMojo.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@
3333
import org.apache.maven.model.Resource;
3434
import org.apache.maven.plugin.MojoExecutionException;
3535
import org.apache.maven.plugin.MojoFailureException;
36-
import org.apache.maven.plugins.annotations.Component;
3736
import org.apache.maven.plugins.annotations.Parameter;
3837
import org.apache.maven.project.MavenProject;
3938
import org.apache.maven.toolchain.ToolchainManager;
@@ -76,8 +75,7 @@ public abstract class AbstractRunMojo extends AbstractDependencyFilterMojo {
7675
*
7776
* @since 2.3.0
7877
*/
79-
@Component
80-
private ToolchainManager toolchainManager;
78+
private final ToolchainManager toolchainManager;
8179

8280
/**
8381
* Add maven resources to the classpath directly, this allows live in-place editing of
@@ -205,6 +203,10 @@ public abstract class AbstractRunMojo extends AbstractDependencyFilterMojo {
205203
@Parameter(property = "spring-boot.run.skip", defaultValue = "false")
206204
private boolean skip;
207205

206+
protected AbstractRunMojo(ToolchainManager toolchainManager) {
207+
this.toolchainManager = toolchainManager;
208+
}
209+
208210
@Override
209211
public void execute() throws MojoExecutionException, MojoFailureException {
210212
if (this.skip) {

spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven/BuildImageForkMojo.java

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2023 the original author or authors.
2+
* Copyright 2012-2025 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -16,10 +16,13 @@
1616

1717
package org.springframework.boot.maven;
1818

19+
import javax.inject.Inject;
20+
1921
import org.apache.maven.plugins.annotations.Execute;
2022
import org.apache.maven.plugins.annotations.LifecyclePhase;
2123
import org.apache.maven.plugins.annotations.Mojo;
2224
import org.apache.maven.plugins.annotations.ResolutionScope;
25+
import org.apache.maven.project.MavenProjectHelper;
2326

2427
/**
2528
* Package an application into an OCI image using a buildpack, forking the lifecycle to
@@ -36,4 +39,9 @@
3639
@Execute(phase = LifecyclePhase.PACKAGE)
3740
public class BuildImageForkMojo extends BuildImageMojo {
3841

42+
@Inject
43+
public BuildImageForkMojo(MavenProjectHelper projectHelper) {
44+
super(projectHelper);
45+
}
46+
3947
}

spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven/BuildImageMojo.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
import org.apache.maven.plugin.MojoExecutionException;
3434
import org.apache.maven.plugin.logging.Log;
3535
import org.apache.maven.plugins.annotations.Parameter;
36+
import org.apache.maven.project.MavenProjectHelper;
3637

3738
import org.springframework.boot.buildpack.platform.build.AbstractBuildLog;
3839
import org.springframework.boot.buildpack.platform.build.BuildLog;
@@ -219,6 +220,10 @@ public abstract class BuildImageMojo extends AbstractPackagerMojo {
219220
@Parameter
220221
private LayoutFactory layoutFactory;
221222

223+
protected BuildImageMojo(MavenProjectHelper projectHelper) {
224+
super(projectHelper);
225+
}
226+
222227
/**
223228
* Return the type of archive that should be used when building the image.
224229
* @return the value of the {@code layout} parameter, or {@code null} if the parameter

spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven/BuildImageNoForkMojo.java

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2023 the original author or authors.
2+
* Copyright 2012-2025 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -16,9 +16,12 @@
1616

1717
package org.springframework.boot.maven;
1818

19+
import javax.inject.Inject;
20+
1921
import org.apache.maven.plugins.annotations.LifecyclePhase;
2022
import org.apache.maven.plugins.annotations.Mojo;
2123
import org.apache.maven.plugins.annotations.ResolutionScope;
24+
import org.apache.maven.project.MavenProjectHelper;
2225

2326
/**
2427
* Package an application into an OCI image using a buildpack, but without forking the
@@ -33,4 +36,9 @@
3336
requiresDependencyCollection = ResolutionScope.COMPILE_PLUS_RUNTIME)
3437
public class BuildImageNoForkMojo extends BuildImageMojo {
3538

39+
@Inject
40+
public BuildImageNoForkMojo(MavenProjectHelper projectHelper) {
41+
super(projectHelper);
42+
}
43+
3644
}

spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven/BuildInfoMojo.java

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2024 the original author or authors.
2+
* Copyright 2012-2025 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -23,11 +23,12 @@
2323
import java.util.List;
2424
import java.util.Map;
2525

26+
import javax.inject.Inject;
27+
2628
import org.apache.maven.execution.MavenSession;
2729
import org.apache.maven.plugin.AbstractMojo;
2830
import org.apache.maven.plugin.MojoExecutionException;
2931
import org.apache.maven.plugin.MojoFailureException;
30-
import org.apache.maven.plugins.annotations.Component;
3132
import org.apache.maven.plugins.annotations.LifecyclePhase;
3233
import org.apache.maven.plugins.annotations.Mojo;
3334
import org.apache.maven.plugins.annotations.Parameter;
@@ -49,8 +50,7 @@
4950
@Mojo(name = "build-info", defaultPhase = LifecyclePhase.GENERATE_RESOURCES, threadSafe = true)
5051
public class BuildInfoMojo extends AbstractMojo {
5152

52-
@Component
53-
private BuildContext buildContext;
53+
private final BuildContext buildContext;
5454

5555
/**
5656
* The Maven session.
@@ -104,6 +104,11 @@ public class BuildInfoMojo extends AbstractMojo {
104104
@Parameter(property = "spring-boot.build-info.skip", defaultValue = "false")
105105
private boolean skip;
106106

107+
@Inject
108+
public BuildInfoMojo(BuildContext buildContext) {
109+
this.buildContext = buildContext;
110+
}
111+
107112
@Override
108113
public void execute() throws MojoExecutionException, MojoFailureException {
109114
if (this.skip) {

spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven/ProcessAotMojo.java

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2024 the original author or authors.
2+
* Copyright 2012-2025 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -21,10 +21,13 @@
2121
import java.util.ArrayList;
2222
import java.util.List;
2323

24+
import javax.inject.Inject;
25+
2426
import org.apache.maven.plugins.annotations.LifecyclePhase;
2527
import org.apache.maven.plugins.annotations.Mojo;
2628
import org.apache.maven.plugins.annotations.Parameter;
2729
import org.apache.maven.plugins.annotations.ResolutionScope;
30+
import org.apache.maven.toolchain.ToolchainManager;
2831

2932
import org.springframework.util.ObjectUtils;
3033

@@ -86,6 +89,11 @@ public class ProcessAotMojo extends AbstractAotMojo {
8689
@Parameter
8790
private String[] profiles;
8891

92+
@Inject
93+
public ProcessAotMojo(ToolchainManager toolchainManager) {
94+
super(toolchainManager);
95+
}
96+
8997
@Override
9098
protected void executeAot() throws Exception {
9199
if (this.project.getPackaging().equals("pom")) {

spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven/ProcessTestAotMojo.java

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2024 the original author or authors.
2+
* Copyright 2012-2025 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -28,17 +28,18 @@
2828
import java.util.Set;
2929
import java.util.stream.Collectors;
3030

31+
import javax.inject.Inject;
32+
3133
import org.apache.maven.RepositoryUtils;
3234
import org.apache.maven.artifact.Artifact;
3335
import org.apache.maven.artifact.DefaultArtifact;
3436
import org.apache.maven.artifact.handler.DefaultArtifactHandler;
35-
import org.apache.maven.artifact.resolver.ResolutionErrorHandler;
3637
import org.apache.maven.plugin.MojoExecutionException;
37-
import org.apache.maven.plugins.annotations.Component;
3838
import org.apache.maven.plugins.annotations.LifecyclePhase;
3939
import org.apache.maven.plugins.annotations.Mojo;
4040
import org.apache.maven.plugins.annotations.Parameter;
4141
import org.apache.maven.plugins.annotations.ResolutionScope;
42+
import org.apache.maven.toolchain.ToolchainManager;
4243
import org.eclipse.aether.RepositorySystem;
4344
import org.eclipse.aether.collection.CollectRequest;
4445
import org.eclipse.aether.resolution.ArtifactResult;
@@ -103,11 +104,13 @@ public class ProcessTestAotMojo extends AbstractAotMojo {
103104
@Parameter(defaultValue = "${project.build.directory}/spring-aot/main/classes", required = true)
104105
private File generatedClasses;
105106

106-
@Component
107-
private RepositorySystem repositorySystem;
107+
private final RepositorySystem repositorySystem;
108108

109-
@Component
110-
private ResolutionErrorHandler resolutionErrorHandler;
109+
@Inject
110+
public ProcessTestAotMojo(ToolchainManager toolchainManager, RepositorySystem repositorySystem) {
111+
super(toolchainManager);
112+
this.repositorySystem = repositorySystem;
113+
}
111114

112115
@Override
113116
protected void executeAot() throws Exception {

spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven/RepackageMojo.java

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2024 the original author or authors.
2+
* Copyright 2012-2025 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -23,6 +23,8 @@
2323
import java.util.Properties;
2424
import java.util.regex.Pattern;
2525

26+
import javax.inject.Inject;
27+
2628
import org.apache.maven.artifact.Artifact;
2729
import org.apache.maven.model.Dependency;
2830
import org.apache.maven.plugin.MojoExecutionException;
@@ -31,6 +33,7 @@
3133
import org.apache.maven.plugins.annotations.Mojo;
3234
import org.apache.maven.plugins.annotations.Parameter;
3335
import org.apache.maven.plugins.annotations.ResolutionScope;
36+
import org.apache.maven.project.MavenProjectHelper;
3437

3538
import org.springframework.boot.loader.tools.DefaultLaunchScript;
3639
import org.springframework.boot.loader.tools.LaunchScript;
@@ -179,6 +182,11 @@ public class RepackageMojo extends AbstractPackagerMojo {
179182
@Parameter
180183
private LayoutFactory layoutFactory;
181184

185+
@Inject
186+
public RepackageMojo(MavenProjectHelper projectHelper) {
187+
super(projectHelper);
188+
}
189+
182190
/**
183191
* Return the type of archive that should be packaged by this MOJO.
184192
* @return the value of the {@code layout} parameter, or {@code null} if the parameter

spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven/RunMojo.java

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2023 the original author or authors.
2+
* Copyright 2012-2025 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -20,13 +20,16 @@
2020
import java.util.List;
2121
import java.util.Map;
2222

23+
import javax.inject.Inject;
24+
2325
import org.apache.maven.plugin.MojoExecutionException;
2426
import org.apache.maven.plugin.MojoFailureException;
2527
import org.apache.maven.plugins.annotations.Execute;
2628
import org.apache.maven.plugins.annotations.LifecyclePhase;
2729
import org.apache.maven.plugins.annotations.Mojo;
2830
import org.apache.maven.plugins.annotations.Parameter;
2931
import org.apache.maven.plugins.annotations.ResolutionScope;
32+
import org.apache.maven.toolchain.ToolchainManager;
3033

3134
import org.springframework.boot.loader.tools.RunProcess;
3235

@@ -58,6 +61,11 @@ public class RunMojo extends AbstractRunMojo {
5861
@Parameter(property = "spring-boot.run.useTestClasspath", defaultValue = "false")
5962
private Boolean useTestClasspath;
6063

64+
@Inject
65+
public RunMojo(ToolchainManager toolchainManager) {
66+
super(toolchainManager);
67+
}
68+
6169
@Override
6270
protected RunArguments resolveJvmArguments() {
6371
RunArguments jvmArguments = super.resolveJvmArguments();

0 commit comments

Comments
 (0)