Rename spring-boot-deprecated-properties-support
Rename `spring-boot-deprecated-properties-support` to `spring-boot-properties-migrator`. See gh-11301
This commit is contained in:
parent
952e766e51
commit
b1525f4f2e
|
|
@ -21,8 +21,8 @@
|
|||
<module>spring-boot-actuator</module>
|
||||
<module>spring-boot-actuator-autoconfigure</module>
|
||||
<module>spring-boot-autoconfigure</module>
|
||||
<module>spring-boot-deprecated-properties-support</module>
|
||||
<module>spring-boot-devtools</module>
|
||||
<module>spring-boot-properties-migrator</module>
|
||||
<module>spring-boot-test</module>
|
||||
<module>spring-boot-test-autoconfigure</module>
|
||||
<module>spring-boot-tools</module>
|
||||
|
|
|
|||
|
|
@ -239,11 +239,6 @@
|
|||
<artifactId>spring-boot-autoconfigure-processor</artifactId>
|
||||
<version>${revision}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-configuration-analyzer</artifactId>
|
||||
<version>${revision}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-configuration-metadata</artifactId>
|
||||
|
|
@ -269,6 +264,11 @@
|
|||
<artifactId>spring-boot-loader-tools</artifactId>
|
||||
<version>${revision}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-properties-migrator</artifactId>
|
||||
<version>${revision}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter</artifactId>
|
||||
|
|
|
|||
|
|
@ -1,2 +0,0 @@
|
|||
org.springframework.context.ApplicationListener=\
|
||||
org.springframework.boot.deprecatedproperties.DeprecatedPropertiesListener
|
||||
|
|
@ -8,9 +8,9 @@
|
|||
<version>${revision}</version>
|
||||
<relativePath>../spring-boot-parent</relativePath>
|
||||
</parent>
|
||||
<artifactId>spring-boot-deprecated-properties-support</artifactId>
|
||||
<name>Spring Boot Deprecated Properties Support</name>
|
||||
<description>Spring Boot Deprecated Properties Support</description>
|
||||
<artifactId>spring-boot-properties-migrator</artifactId>
|
||||
<name>Spring Boot Properties Migrator</name>
|
||||
<description>Spring Boot Properties Migrator</description>
|
||||
<properties>
|
||||
<main.basedir>${basedir}/../..</main.basedir>
|
||||
</properties>
|
||||
|
|
@ -14,7 +14,7 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.boot.deprecatedproperties;
|
||||
package org.springframework.boot.legacyproperties;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
|
|
@ -35,19 +35,19 @@ import org.springframework.core.io.support.PathMatchingResourcePatternResolver;
|
|||
|
||||
/**
|
||||
* An {@link ApplicationListener} that inspects the {@link ConfigurableEnvironment
|
||||
* environment} for deprecated configuration keys. Automatically renames the keys that
|
||||
* environment} for legacy configuration keys. Automatically renames the keys that
|
||||
* have a matching replacement and log a report of what was discovered.
|
||||
*
|
||||
* @author Stephane Nicoll
|
||||
* @since 2.0.0
|
||||
*/
|
||||
public class DeprecatedPropertiesListener
|
||||
public class LegacyPropertiesListener
|
||||
implements ApplicationListener<SpringApplicationEvent> {
|
||||
|
||||
private static final Log logger = LogFactory
|
||||
.getLog(DeprecatedPropertiesListener.class);
|
||||
.getLog(LegacyPropertiesListener.class);
|
||||
|
||||
private DeprecatedPropertiesReport report;
|
||||
private LegacyPropertiesReport report;
|
||||
|
||||
private boolean reported;
|
||||
|
||||
|
|
@ -58,13 +58,13 @@ public class DeprecatedPropertiesListener
|
|||
}
|
||||
if (event instanceof ApplicationReadyEvent
|
||||
|| event instanceof ApplicationFailedEvent) {
|
||||
logLegacyPropertiesAnalysis();
|
||||
logLegacyPropertiesReport();
|
||||
}
|
||||
}
|
||||
|
||||
private void onApplicationPreparedEvent(ApplicationPreparedEvent event) {
|
||||
ConfigurationMetadataRepository repository = loadRepository();
|
||||
DeprecatedPropertiesReporter reporter = new DeprecatedPropertiesReporter(repository,
|
||||
LegacyPropertiesReporter reporter = new LegacyPropertiesReporter(repository,
|
||||
event.getApplicationContext().getEnvironment());
|
||||
this.report = reporter.getReport();
|
||||
}
|
||||
|
|
@ -90,7 +90,7 @@ public class DeprecatedPropertiesListener
|
|||
return builder.build();
|
||||
}
|
||||
|
||||
private void logLegacyPropertiesAnalysis() {
|
||||
private void logLegacyPropertiesReport() {
|
||||
if (this.report == null || this.reported) {
|
||||
return;
|
||||
}
|
||||
|
|
@ -14,7 +14,7 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.boot.deprecatedproperties;
|
||||
package org.springframework.boot.legacyproperties;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
|
|
@ -28,13 +28,13 @@ import org.springframework.boot.configurationmetadata.ConfigurationMetadataPrope
|
|||
import org.springframework.util.StringUtils;
|
||||
|
||||
/**
|
||||
* Provides a deprecated properties report.
|
||||
* Provides a legacy properties report.
|
||||
*
|
||||
* @author Stephane Nicoll
|
||||
*/
|
||||
class DeprecatedPropertiesReport {
|
||||
class LegacyPropertiesReport {
|
||||
|
||||
private final Map<String, DeprecatedProperties> content = new LinkedHashMap<>();
|
||||
private final Map<String, LegacyProperties> content = new LinkedHashMap<>();
|
||||
|
||||
/**
|
||||
* Return a report for all the legacy properties that were automatically renamed. If
|
||||
|
|
@ -42,8 +42,8 @@ class DeprecatedPropertiesReport {
|
|||
* @return a report with the configurations keys that should be renamed
|
||||
*/
|
||||
public String getWarningReport() {
|
||||
Map<String, List<DeprecatedProperty>> content = getContent(
|
||||
DeprecatedProperties::getRenamed);
|
||||
Map<String, List<LegacyProperty>> content = getContent(
|
||||
LegacyProperties::getRenamed);
|
||||
if (content.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
|
|
@ -66,8 +66,8 @@ class DeprecatedPropertiesReport {
|
|||
* @return a report with the configurations keys that are no longer supported
|
||||
*/
|
||||
public String getErrorReport() {
|
||||
Map<String, List<DeprecatedProperty>> content = getContent(
|
||||
DeprecatedProperties::getUnsupported);
|
||||
Map<String, List<LegacyProperty>> content = getContent(
|
||||
LegacyProperties::getUnsupported);
|
||||
if (content.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
|
|
@ -85,8 +85,8 @@ class DeprecatedPropertiesReport {
|
|||
return report.toString();
|
||||
}
|
||||
|
||||
private Map<String, List<DeprecatedProperty>> getContent(
|
||||
Function<DeprecatedProperties, List<DeprecatedProperty>> extractor) {
|
||||
private Map<String, List<LegacyProperty>> getContent(
|
||||
Function<LegacyProperties, List<LegacyProperty>> extractor) {
|
||||
return this.content.entrySet().stream()
|
||||
.filter((entry) -> !extractor.apply(entry.getValue()).isEmpty())
|
||||
.collect(Collectors.toMap(Map.Entry::getKey,
|
||||
|
|
@ -94,11 +94,11 @@ class DeprecatedPropertiesReport {
|
|||
}
|
||||
|
||||
private void append(StringBuilder report,
|
||||
Map<String, List<DeprecatedProperty>> content,
|
||||
Map<String, List<LegacyProperty>> content,
|
||||
Function<ConfigurationMetadataProperty, String> deprecationMessage) {
|
||||
content.forEach((name, properties) -> {
|
||||
report.append(String.format("Property source '%s':%n", name));
|
||||
properties.sort(DeprecatedProperty.COMPARATOR);
|
||||
properties.sort(LegacyProperty.COMPARATOR);
|
||||
properties.forEach((property) -> {
|
||||
ConfigurationMetadataProperty metadata = property.getMetadata();
|
||||
report.append(String.format("\tKey: %s%n", metadata.getId()));
|
||||
|
|
@ -119,32 +119,32 @@ class DeprecatedPropertiesReport {
|
|||
* @param renamed the properties that were renamed
|
||||
* @param unsupported the properties that are no longer supported
|
||||
*/
|
||||
void add(String name, List<DeprecatedProperty> renamed,
|
||||
List<DeprecatedProperty> unsupported) {
|
||||
this.content.put(name, new DeprecatedProperties(renamed, unsupported));
|
||||
void add(String name, List<LegacyProperty> renamed,
|
||||
List<LegacyProperty> unsupported) {
|
||||
this.content.put(name, new LegacyProperties(renamed, unsupported));
|
||||
}
|
||||
|
||||
private static class DeprecatedProperties {
|
||||
private static class LegacyProperties {
|
||||
|
||||
private final List<DeprecatedProperty> renamed;
|
||||
private final List<LegacyProperty> renamed;
|
||||
|
||||
private final List<DeprecatedProperty> unsupported;
|
||||
private final List<LegacyProperty> unsupported;
|
||||
|
||||
DeprecatedProperties(List<DeprecatedProperty> renamed,
|
||||
List<DeprecatedProperty> unsupported) {
|
||||
LegacyProperties(List<LegacyProperty> renamed,
|
||||
List<LegacyProperty> unsupported) {
|
||||
this.renamed = asNewList(renamed);
|
||||
this.unsupported = asNewList(unsupported);
|
||||
}
|
||||
|
||||
private <T> List<T> asNewList(List<T> source) {
|
||||
return (source == null ? Collections.emptyList() : new ArrayList<T>(source));
|
||||
return (source == null ? Collections.emptyList() : new ArrayList<>(source));
|
||||
}
|
||||
|
||||
public List<DeprecatedProperty> getRenamed() {
|
||||
public List<LegacyProperty> getRenamed() {
|
||||
return this.renamed;
|
||||
}
|
||||
|
||||
public List<DeprecatedProperty> getUnsupported() {
|
||||
public List<LegacyProperty> getUnsupported() {
|
||||
return this.unsupported;
|
||||
}
|
||||
|
||||
|
|
@ -14,7 +14,7 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.boot.deprecatedproperties;
|
||||
package org.springframework.boot.legacyproperties;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
|
|
@ -40,17 +40,17 @@ import org.springframework.util.MultiValueMap;
|
|||
import org.springframework.util.StringUtils;
|
||||
|
||||
/**
|
||||
* Report on {@link DeprecatedProperty deprecated properties}.
|
||||
* Report on {@link LegacyProperty legacy properties}.
|
||||
*
|
||||
* @author Stephane Nicoll
|
||||
*/
|
||||
class DeprecatedPropertiesReporter {
|
||||
class LegacyPropertiesReporter {
|
||||
|
||||
private final Map<String, ConfigurationMetadataProperty> allProperties;
|
||||
|
||||
private final ConfigurableEnvironment environment;
|
||||
|
||||
DeprecatedPropertiesReporter(ConfigurationMetadataRepository metadataRepository,
|
||||
LegacyPropertiesReporter(ConfigurationMetadataRepository metadataRepository,
|
||||
ConfigurableEnvironment environment) {
|
||||
this.allProperties = Collections
|
||||
.unmodifiableMap(metadataRepository.getAllProperties());
|
||||
|
|
@ -62,9 +62,9 @@ class DeprecatedPropertiesReporter {
|
|||
* legacy properties if a replacement exists.
|
||||
* @return the analysis
|
||||
*/
|
||||
public DeprecatedPropertiesReport getReport() {
|
||||
DeprecatedPropertiesReport report = new DeprecatedPropertiesReport();
|
||||
Map<String, List<DeprecatedProperty>> properties = getMatchingProperties(
|
||||
public LegacyPropertiesReport getReport() {
|
||||
LegacyPropertiesReport report = new LegacyPropertiesReport();
|
||||
Map<String, List<LegacyProperty>> properties = getMatchingProperties(
|
||||
deprecatedFilter());
|
||||
if (properties.isEmpty()) {
|
||||
return report;
|
||||
|
|
@ -80,20 +80,19 @@ class DeprecatedPropertiesReporter {
|
|||
}
|
||||
|
||||
private PropertySource<?> mapPropertiesWithReplacement(
|
||||
DeprecatedPropertiesReport report, String name,
|
||||
List<DeprecatedProperty> properties) {
|
||||
List<DeprecatedProperty> renamed = new ArrayList<>();
|
||||
List<DeprecatedProperty> unsupported = new ArrayList<>();
|
||||
properties.forEach((property) -> {
|
||||
(isRenamed(property) ? renamed : unsupported).add(property);
|
||||
});
|
||||
LegacyPropertiesReport report, String name,
|
||||
List<LegacyProperty> properties) {
|
||||
List<LegacyProperty> renamed = new ArrayList<>();
|
||||
List<LegacyProperty> unsupported = new ArrayList<>();
|
||||
properties.forEach((property) ->
|
||||
(isRenamed(property) ? renamed : unsupported).add(property));
|
||||
report.add(name, renamed, unsupported);
|
||||
if (renamed.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
String target = "migrate-" + name;
|
||||
Map<String, OriginTrackedValue> content = new LinkedHashMap<>();
|
||||
for (DeprecatedProperty candidate : renamed) {
|
||||
for (LegacyProperty candidate : renamed) {
|
||||
OriginTrackedValue value = OriginTrackedValue.of(
|
||||
candidate.getProperty().getValue(),
|
||||
candidate.getProperty().getOrigin());
|
||||
|
|
@ -102,7 +101,7 @@ class DeprecatedPropertiesReporter {
|
|||
return new OriginTrackedMapPropertySource(target, content);
|
||||
}
|
||||
|
||||
private boolean isRenamed(DeprecatedProperty property) {
|
||||
private boolean isRenamed(LegacyProperty property) {
|
||||
ConfigurationMetadataProperty metadata = property.getMetadata();
|
||||
String replacementId = metadata.getDeprecation().getReplacement();
|
||||
if (StringUtils.hasText(replacementId)) {
|
||||
|
|
@ -128,9 +127,9 @@ class DeprecatedPropertiesReporter {
|
|||
return null;
|
||||
}
|
||||
|
||||
private Map<String, List<DeprecatedProperty>> getMatchingProperties(
|
||||
private Map<String, List<LegacyProperty>> getMatchingProperties(
|
||||
Predicate<ConfigurationMetadataProperty> filter) {
|
||||
MultiValueMap<String, DeprecatedProperty> result = new LinkedMultiValueMap<>();
|
||||
MultiValueMap<String, LegacyProperty> result = new LinkedMultiValueMap<>();
|
||||
List<ConfigurationMetadataProperty> candidates = this.allProperties.values()
|
||||
.stream().filter(filter).collect(Collectors.toList());
|
||||
getPropertySourcesAsMap().forEach((name, source) -> {
|
||||
|
|
@ -140,7 +139,7 @@ class DeprecatedPropertiesReporter {
|
|||
ConfigurationPropertyName.of(metadata.getId()));
|
||||
if (configurationProperty != null) {
|
||||
result.add(name,
|
||||
new DeprecatedProperty(metadata, configurationProperty));
|
||||
new LegacyProperty(metadata, configurationProperty));
|
||||
}
|
||||
});
|
||||
});
|
||||
|
|
@ -14,7 +14,7 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.boot.deprecatedproperties;
|
||||
package org.springframework.boot.legacyproperties;
|
||||
|
||||
import java.util.Comparator;
|
||||
|
||||
|
|
@ -28,9 +28,9 @@ import org.springframework.boot.origin.TextResourceOrigin;
|
|||
*
|
||||
* @author Stephane Nicoll
|
||||
*/
|
||||
class DeprecatedProperty {
|
||||
class LegacyProperty {
|
||||
|
||||
public static final Comparator<DeprecatedProperty> COMPARATOR = Comparator
|
||||
public static final Comparator<LegacyProperty> COMPARATOR = Comparator
|
||||
.comparing((property) -> property.getMetadata().getId());
|
||||
|
||||
private final ConfigurationMetadataProperty metadata;
|
||||
|
|
@ -39,7 +39,7 @@ class DeprecatedProperty {
|
|||
|
||||
private final Integer lineNumber;
|
||||
|
||||
DeprecatedProperty(ConfigurationMetadataProperty metadata,
|
||||
LegacyProperty(ConfigurationMetadataProperty metadata,
|
||||
ConfigurationProperty property) {
|
||||
this.metadata = metadata;
|
||||
this.property = property;
|
||||
|
|
@ -15,6 +15,6 @@
|
|||
*/
|
||||
|
||||
/**
|
||||
* Support for migrating deprecated Spring Boot properties.
|
||||
* Support for migrating legacy Spring Boot properties.
|
||||
*/
|
||||
package org.springframework.boot.deprecatedproperties;
|
||||
package org.springframework.boot.legacyproperties;
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
org.springframework.context.ApplicationListener=\
|
||||
org.springframework.boot.legacyproperties.LegacyPropertiesListener
|
||||
|
|
@ -14,7 +14,7 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.boot.deprecatedproperties;
|
||||
package org.springframework.boot.legacyproperties;
|
||||
|
||||
import org.junit.After;
|
||||
import org.junit.Rule;
|
||||
|
|
@ -28,11 +28,11 @@ import org.springframework.context.annotation.Configuration;
|
|||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
/**
|
||||
* Tests for {@link DeprecatedPropertiesListener}.
|
||||
* Tests for {@link LegacyPropertiesListener}.
|
||||
*
|
||||
* @author Stephane Nicoll
|
||||
*/
|
||||
public class DeprecatedPropertiesListenerTests {
|
||||
public class LegacyPropertiesListenerTests {
|
||||
|
||||
@Rule
|
||||
public final OutputCapture output = new OutputCapture();
|
||||
|
|
@ -14,7 +14,7 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.boot.deprecatedproperties;
|
||||
package org.springframework.boot.legacyproperties;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
|
|
@ -39,11 +39,11 @@ import org.springframework.mock.env.MockEnvironment;
|
|||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
/**
|
||||
* Tests for {@link DeprecatedPropertiesReporter}.
|
||||
* Tests for {@link LegacyPropertiesReporter}.
|
||||
*
|
||||
* @author Stephane Nicoll
|
||||
*/
|
||||
public class DeprecatedPropertiesReporterTests {
|
||||
public class LegacyPropertiesReporterTests {
|
||||
|
||||
private ConfigurableEnvironment environment = new MockEnvironment();
|
||||
|
||||
|
|
@ -172,9 +172,9 @@ public class DeprecatedPropertiesReporterTests {
|
|||
return createAnalyzer(repository).getReport().getErrorReport();
|
||||
}
|
||||
|
||||
private DeprecatedPropertiesReporter createAnalyzer(
|
||||
private LegacyPropertiesReporter createAnalyzer(
|
||||
ConfigurationMetadataRepository repository) {
|
||||
return new DeprecatedPropertiesReporter(repository, this.environment);
|
||||
return new LegacyPropertiesReporter(repository, this.environment);
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Reference in New Issue