Skip to content

Commit cfdb89f

Browse files
committed
Merge branch '3.1.x' into 3.2.x
Closes gh-40538
2 parents 3881cd0 + 2572c6d commit cfdb89f

File tree

2 files changed

+23
-20
lines changed

2 files changed

+23
-20
lines changed

buildSrc/src/main/java/org/springframework/boot/build/starters/StarterMetadata.java

Lines changed: 21 additions & 18 deletions
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-2024 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,15 +20,18 @@
2020
import java.io.FileWriter;
2121
import java.io.IOException;
2222
import java.util.Properties;
23-
import java.util.concurrent.Callable;
2423
import java.util.stream.Collectors;
2524

2625
import org.gradle.api.DefaultTask;
26+
import org.gradle.api.Project;
2727
import org.gradle.api.Task;
2828
import org.gradle.api.artifacts.Configuration;
2929
import org.gradle.api.artifacts.ResolvedArtifact;
3030
import org.gradle.api.file.FileCollection;
31+
import org.gradle.api.file.RegularFileProperty;
32+
import org.gradle.api.provider.Property;
3133
import org.gradle.api.tasks.Classpath;
34+
import org.gradle.api.tasks.Input;
3235
import org.gradle.api.tasks.OutputFile;
3336
import org.gradle.api.tasks.TaskAction;
3437

@@ -39,17 +42,22 @@
3942
*
4043
* @author Andy Wilkinson
4144
*/
42-
public class StarterMetadata extends DefaultTask {
45+
public abstract class StarterMetadata extends DefaultTask {
4346

4447
private Configuration dependencies;
4548

46-
private File destination;
47-
4849
public StarterMetadata() {
49-
getInputs().property("name", (Callable<String>) () -> getProject().getName());
50-
getInputs().property("description", (Callable<String>) () -> getProject().getDescription());
50+
Project project = getProject();
51+
getStarterName().convention(project.provider(project::getName));
52+
getStarterDescription().convention(project.provider(project::getDescription));
5153
}
5254

55+
@Input
56+
public abstract Property<String> getStarterName();
57+
58+
@Input
59+
public abstract Property<String> getStarterDescription();
60+
5361
@Classpath
5462
public FileCollection getDependencies() {
5563
return this.dependencies;
@@ -60,28 +68,23 @@ public void setDependencies(Configuration dependencies) {
6068
}
6169

6270
@OutputFile
63-
public File getDestination() {
64-
return this.destination;
65-
}
66-
67-
public void setDestination(File destination) {
68-
this.destination = destination;
69-
}
71+
public abstract RegularFileProperty getDestination();
7072

7173
@TaskAction
7274
void generateMetadata() throws IOException {
7375
Properties properties = CollectionFactory.createSortedProperties(true);
74-
properties.setProperty("name", getProject().getName());
75-
properties.setProperty("description", getProject().getDescription());
76+
properties.setProperty("name", getStarterName().get());
77+
properties.setProperty("description", getStarterDescription().get());
7678
properties.setProperty("dependencies",
7779
String.join(",",
7880
this.dependencies.getResolvedConfiguration()
7981
.getResolvedArtifacts()
8082
.stream()
8183
.map(ResolvedArtifact::getName)
8284
.collect(Collectors.toSet())));
83-
this.destination.getParentFile().mkdirs();
84-
try (FileWriter writer = new FileWriter(this.destination)) {
85+
File destination = getDestination().getAsFile().get();
86+
destination.getParentFile().mkdirs();
87+
try (FileWriter writer = new FileWriter(destination)) {
8588
properties.store(writer, null);
8689
}
8790
}

buildSrc/src/main/java/org/springframework/boot/build/starters/StarterPlugin.java

Lines changed: 2 additions & 2 deletions
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-2024 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.
@@ -57,7 +57,7 @@ public void apply(Project project) {
5757
Configuration runtimeClasspath = configurations.getByName(JavaPlugin.RUNTIME_CLASSPATH_CONFIGURATION_NAME);
5858
starterMetadata.setDependencies(runtimeClasspath);
5959
File destination = new File(project.getBuildDir(), "starter-metadata.properties");
60-
starterMetadata.setDestination(destination);
60+
starterMetadata.getDestination().set(destination);
6161
configurations.create("starterMetadata");
6262
project.getArtifacts()
6363
.add("starterMetadata", project.provider(starterMetadata::getDestination),

0 commit comments

Comments
 (0)