Merge branch '3.2.x'

Closes gh-40548
This commit is contained in:
Andy Wilkinson 2024-04-26 16:30:37 +01:00
commit ddeb114d36
2 changed files with 8 additions and 2 deletions

View File

@ -48,9 +48,12 @@ import org.gradle.api.tasks.TaskAction;
*/
public class CheckAdditionalSpringConfigurationMetadata extends SourceTask {
private final File projectDir;
private final RegularFileProperty reportLocation;
public CheckAdditionalSpringConfigurationMetadata() {
this.projectDir = getProject().getProjectDir();
this.reportLocation = getProject().getObjects().fileProperty();
}
@ -82,7 +85,7 @@ public class CheckAdditionalSpringConfigurationMetadata extends SourceTask {
ObjectMapper objectMapper = new ObjectMapper();
Report report = new Report();
for (File file : getSource().getFiles()) {
Analysis analysis = report.analysis(getProject().getProjectDir().toPath().relativize(file.toPath()));
Analysis analysis = report.analysis(this.projectDir.toPath().relativize(file.toPath()));
Map<String, Object> json = objectMapper.readValue(file, Map.class);
check("groups", json, analysis);
check("properties", json, analysis);

View File

@ -49,11 +49,14 @@ public class CheckSpringConfigurationMetadata extends DefaultTask {
private List<String> exclusions = new ArrayList<>();
private final File projectDir;
private final RegularFileProperty reportLocation;
private final RegularFileProperty metadataLocation;
public CheckSpringConfigurationMetadata() {
this.projectDir = getProject().getProjectDir();
this.metadataLocation = getProject().getObjects().fileProperty();
this.reportLocation = getProject().getObjects().fileProperty();
}
@ -93,7 +96,7 @@ public class CheckSpringConfigurationMetadata extends DefaultTask {
private Report createReport() throws IOException, JsonParseException, JsonMappingException {
ObjectMapper objectMapper = new ObjectMapper();
File file = this.metadataLocation.get().getAsFile();
Report report = new Report(getProject().getProjectDir().toPath().relativize(file.toPath()));
Report report = new Report(this.projectDir.toPath().relativize(file.toPath()));
Map<String, Object> json = objectMapper.readValue(file, Map.class);
List<Map<String, Object>> properties = (List<Map<String, Object>>) json.get("properties");
for (Map<String, Object> property : properties) {