Skip to content

Commit d6584aa

Browse files
committed
Avoid calling Task.getProject() from a task action at execution time
Fix ``` > Task :spring-boot-project:spring-boot-tools:spring-boot-maven-plugin:formatHelpMojoSource Invocation of Task.project at execution time has been deprecated. This will fail with an error in Gradle 9.0. Consult the upgrading guide for further information: https://docs.gradle.org/8.10.2/userguide/upgrading_version_7.html#task_project ```
1 parent 619b24a commit d6584aa

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

buildSrc/src/main/java/org/springframework/boot/build/mavenplugin/MavenPluginPlugin.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@
106106
*
107107
* @author Andy Wilkinson
108108
* @author Phillip Webb
109+
* @author Yanming Zhou
109110
*/
110111
public class MavenPluginPlugin implements Plugin<Project> {
111112

@@ -334,8 +335,14 @@ private void addExtractVersionPropertiesTask(Project project) {
334335

335336
public abstract static class FormatHelpMojoSource extends DefaultTask {
336337

338+
private final Project project;
339+
337340
private Task generator;
338341

342+
public FormatHelpMojoSource() {
343+
this.project = getProject();
344+
}
345+
339346
void setGenerator(Task generator) {
340347
this.generator = generator;
341348
getInputs().files(this.generator)
@@ -350,7 +357,7 @@ void setGenerator(Task generator) {
350357
void syncAndFormat() {
351358
FileFormatter formatter = new FileFormatter();
352359
for (File output : this.generator.getOutputs().getFiles()) {
353-
formatter.formatFiles(getProject().fileTree(output), StandardCharsets.UTF_8)
360+
formatter.formatFiles(this.project.fileTree(output), StandardCharsets.UTF_8)
354361
.forEach((edit) -> save(output, edit));
355362
}
356363
}

0 commit comments

Comments
 (0)