From 3e6a9b3708ebcd2b7d4bd282cd6f6dfac16722fa Mon Sep 17 00:00:00 2001 From: Andy Wilkinson Date: Fri, 26 Apr 2024 16:09:59 +0100 Subject: [PATCH] Stop calling getProject() during execution of AutoConfigurationMetadata Closes gh-40540 --- .../build/autoconfigure/AutoConfigurationMetadata.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/buildSrc/src/main/java/org/springframework/boot/build/autoconfigure/AutoConfigurationMetadata.java b/buildSrc/src/main/java/org/springframework/boot/build/autoconfigure/AutoConfigurationMetadata.java index 4f65e0ec71b0..751ca0b87521 100644 --- a/buildSrc/src/main/java/org/springframework/boot/build/autoconfigure/AutoConfigurationMetadata.java +++ b/buildSrc/src/main/java/org/springframework/boot/build/autoconfigure/AutoConfigurationMetadata.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2023 the original author or authors. + * Copyright 2012-2024 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. @@ -52,6 +52,8 @@ public class AutoConfigurationMetadata extends DefaultTask { private static final String COMMENT_START = "#"; + private final String moduleName; + private SourceSet sourceSet; private File outputFile; @@ -66,6 +68,7 @@ public AutoConfigurationMetadata() { dependsOn((Callable) () -> this.sourceSet.getProcessResourcesTaskName()); getProject().getConfigurations() .maybeCreate(AutoConfigurationPlugin.AUTO_CONFIGURATION_METADATA_CONFIGURATION_NAME); + this.moduleName = getProject().getName(); } public void setSourceSet(SourceSet sourceSet) { @@ -107,7 +110,7 @@ private Properties readAutoConfiguration() throws IOException { } } autoConfiguration.setProperty("autoConfigurationClassNames", String.join(",", publicClassNames)); - autoConfiguration.setProperty("module", getProject().getName()); + autoConfiguration.setProperty("module", this.moduleName); return autoConfiguration; }