mirror of
https://github.com/spring-projects/spring-boot.git
synced 2026-09-17 20:19:06 +00:00
Document properties that were added as deprecated
This commit handles a corner case where we have to add properties in a release that represents something we mean to remove but that's not ready to go away just yet. Those properties are now considered in the changelog, but marked as deprecated. Closes gh-47759
This commit is contained in:
+6
-4
@@ -57,12 +57,14 @@ record Changelog(String oldVersionNumber, String newVersionNumber, List<Differen
|
||||
}
|
||||
for (ConfigurationMetadataProperty newProperty : newMetadata.getAllProperties().values()) {
|
||||
if (!seenIds.contains(newProperty.getId())) {
|
||||
if (newProperty.isDeprecated() && newProperty.getDeprecation().getLevel() == Level.ERROR) {
|
||||
differences.add(new Difference(DifferenceType.DELETED, null, newProperty));
|
||||
}
|
||||
else if (!newProperty.isDeprecated()) {
|
||||
if (!newProperty.isDeprecated()) {
|
||||
differences.add(new Difference(DifferenceType.ADDED, null, newProperty));
|
||||
}
|
||||
else {
|
||||
DifferenceType differenceType = (newProperty.getDeprecation().getLevel() == Level.ERROR)
|
||||
? DifferenceType.DELETED : DifferenceType.ADDED;
|
||||
differences.add(new Difference(differenceType, null, newProperty));
|
||||
}
|
||||
}
|
||||
}
|
||||
return List.copyOf(differences);
|
||||
|
||||
+4
-7
@@ -104,7 +104,10 @@ class ChangelogWriter implements AutoCloseable {
|
||||
}
|
||||
|
||||
private void writeAdded(Difference difference) {
|
||||
writeRegularPropertyRow(difference.newProperty());
|
||||
ConfigurationMetadataProperty property = difference.newProperty();
|
||||
writeCell(monospace(property.getId()) + (property.isDeprecated() ? " (deprecated)" : ""));
|
||||
writeCell(monospace(asString(property.getDefaultValue())));
|
||||
writeCell(property.getShortDescription());
|
||||
}
|
||||
|
||||
private void writeRemoved(List<Difference> deleted, List<Difference> deprecated) {
|
||||
@@ -157,12 +160,6 @@ class ChangelogWriter implements AutoCloseable {
|
||||
write("|======================%n");
|
||||
}
|
||||
|
||||
private void writeRegularPropertyRow(ConfigurationMetadataProperty property) {
|
||||
writeCell(monospace(property.getId()));
|
||||
writeCell(monospace(asString(property.getDefaultValue())));
|
||||
writeCell(property.getShortDescription());
|
||||
}
|
||||
|
||||
private void writeDeprecatedPropertyRow(ConfigurationMetadataProperty property) {
|
||||
Deprecation deprecation = (property.getDeprecation() != null) ? property.getDeprecation() : new Deprecation();
|
||||
writeCell(monospace(property.getId()));
|
||||
|
||||
+4
-3
@@ -39,13 +39,14 @@ class ChangelogTests {
|
||||
assertThat(differences).isNotNull();
|
||||
assertThat(differences.oldVersionNumber()).isEqualTo("1.0");
|
||||
assertThat(differences.newVersionNumber()).isEqualTo("2.0");
|
||||
assertThat(differences.differences()).hasSize(5);
|
||||
assertThat(differences.differences()).hasSize(6);
|
||||
List<Difference> added = differences.differences()
|
||||
.stream()
|
||||
.filter((difference) -> difference.type() == DifferenceType.ADDED)
|
||||
.toList();
|
||||
assertThat(added).hasSize(1);
|
||||
assertProperty(added.get(0).newProperty(), "test.add", String.class, "new");
|
||||
assertThat(added).hasSize(2)
|
||||
.anySatisfy((entry) -> assertProperty(entry.newProperty(), "test.add", String.class, "new"))
|
||||
.anySatisfy((entry) -> assertProperty(entry.newProperty(), "test.add.deprecated", String.class, "test2"));
|
||||
List<Difference> deleted = differences.differences()
|
||||
.stream()
|
||||
.filter((difference) -> difference.type() == DifferenceType.DELETED)
|
||||
|
||||
+10
@@ -6,6 +6,16 @@
|
||||
"description": "Test add.",
|
||||
"defaultValue": "new"
|
||||
},
|
||||
{
|
||||
"name": "test.add.deprecated",
|
||||
"type": "java.lang.String",
|
||||
"description": "Test add deprecated.",
|
||||
"defaultValue": "test2",
|
||||
"deprecation": {
|
||||
"replacement": "test.equal",
|
||||
"reason": "Deprecated in favor of Equal"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "test.equal",
|
||||
"type": "java.lang.String",
|
||||
|
||||
+4
@@ -16,6 +16,10 @@ _None_.
|
||||
| `test.add`
|
||||
| `new`
|
||||
| Test add.
|
||||
|
||||
| `test.add.deprecated` (deprecated)
|
||||
| `test2`
|
||||
| Test add deprecated.
|
||||
|======================
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user