Merge branch '2.7.x'

This commit is contained in:
Phillip Webb 2022-05-17 21:50:42 -07:00
commit 06f8041e4d
14 changed files with 34 additions and 40 deletions

View File

@ -106,7 +106,7 @@ class AsciidoctorConventions {
private void createAsciidoctorExtensionsConfiguration(Project project) { private void createAsciidoctorExtensionsConfiguration(Project project) {
project.getConfigurations().create(EXTENSIONS_CONFIGURATION_NAME, (configuration) -> { project.getConfigurations().create(EXTENSIONS_CONFIGURATION_NAME, (configuration) -> {
project.getConfigurations().matching((candidate) -> "dependencyManagement".equals(candidate.getName())) project.getConfigurations().matching((candidate) -> "dependencyManagement".equals(candidate.getName()))
.all((dependencyManagement) -> configuration.extendsFrom(dependencyManagement)); .all(configuration::extendsFrom);
configuration.getDependencies().add(project.getDependencies() configuration.getDependencies().add(project.getDependencies()
.create("io.spring.asciidoctor.backends:spring-asciidoctor-backends:0.0.3")); .create("io.spring.asciidoctor.backends:spring-asciidoctor-backends:0.0.3"));
configuration.getDependencies() configuration.getDependencies()

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2021 the original author or authors. * Copyright 2012-2022 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -44,18 +44,14 @@ public class DeployedPlugin implements Plugin<Project> {
project.getPlugins().apply(MavenRepositoryPlugin.class); project.getPlugins().apply(MavenRepositoryPlugin.class);
PublishingExtension publishing = project.getExtensions().getByType(PublishingExtension.class); PublishingExtension publishing = project.getExtensions().getByType(PublishingExtension.class);
MavenPublication mavenPublication = publishing.getPublications().create("maven", MavenPublication.class); MavenPublication mavenPublication = publishing.getPublications().create("maven", MavenPublication.class);
project.afterEvaluate((evaluated) -> { project.afterEvaluate((evaluated) -> project.getPlugins().withType(JavaPlugin.class).all((javaPlugin) -> {
project.getPlugins().withType(JavaPlugin.class).all((javaPlugin) -> { if (((Jar) project.getTasks().getByName(JavaPlugin.JAR_TASK_NAME)).isEnabled()) {
if (((Jar) project.getTasks().getByName(JavaPlugin.JAR_TASK_NAME)).isEnabled()) { project.getComponents().matching((component) -> component.getName().equals("java"))
project.getComponents().matching((component) -> component.getName().equals("java")) .all(mavenPublication::from);
.all((javaComponent) -> mavenPublication.from(javaComponent)); }
} }));
}); project.getPlugins().withType(JavaPlatformPlugin.class).all((javaPlugin) -> project.getComponents()
}); .matching((component) -> component.getName().equals("javaPlatform")).all(mavenPublication::from));
project.getPlugins().withType(JavaPlatformPlugin.class)
.all((javaPlugin) -> project.getComponents()
.matching((component) -> component.getName().equals("javaPlatform"))
.all((javaComponent) -> mavenPublication.from(javaComponent)));
} }
} }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2020 the original author or authors. * Copyright 2012-2022 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -28,7 +28,6 @@ import java.util.Map;
import org.gradle.api.DefaultTask; import org.gradle.api.DefaultTask;
import org.gradle.api.GradleException; import org.gradle.api.GradleException;
import org.gradle.api.Task;
import org.gradle.api.file.DirectoryProperty; import org.gradle.api.file.DirectoryProperty;
import org.gradle.api.tasks.Input; import org.gradle.api.tasks.Input;
import org.gradle.api.tasks.OutputDirectory; import org.gradle.api.tasks.OutputDirectory;
@ -87,8 +86,7 @@ public class ExtractResources extends DefaultTask {
throw new GradleException("Resource '" + resourceName + "' does not exist"); throw new GradleException("Resource '" + resourceName + "' does not exist");
} }
String resource = FileCopyUtils.copyToString(new InputStreamReader(resourceStream, StandardCharsets.UTF_8)); String resource = FileCopyUtils.copyToString(new InputStreamReader(resourceStream, StandardCharsets.UTF_8));
resource = this.propertyPlaceholderHelper.replacePlaceholders(resource, resource = this.propertyPlaceholderHelper.replacePlaceholders(resource, this.properties::get);
(placeholder) -> this.properties.get(placeholder));
FileCopyUtils.copy(resource, FileCopyUtils.copy(resource,
new FileWriter(this.destinationDirectory.file(resourceName).get().getAsFile())); new FileWriter(this.destinationDirectory.file(resourceName).get().getAsFile()));
} }

View File

@ -160,8 +160,8 @@ class JavaConventions {
project.getTasks().withType(Test.class, (test) -> { project.getTasks().withType(Test.class, (test) -> {
test.useJUnitPlatform(); test.useJUnitPlatform();
test.setMaxHeapSize("1024M"); test.setMaxHeapSize("1024M");
project.getTasks().withType(Checkstyle.class, (checkstyle) -> test.mustRunAfter(checkstyle)); project.getTasks().withType(Checkstyle.class, test::mustRunAfter);
project.getTasks().withType(CheckFormat.class, (checkFormat) -> test.mustRunAfter(checkFormat)); project.getTasks().withType(CheckFormat.class, test::mustRunAfter);
}); });
project.getPlugins().withType(JavaPlugin.class, (javaPlugin) -> project.getDependencies() project.getPlugins().withType(JavaPlugin.class, (javaPlugin) -> project.getDependencies()
.add(JavaPlugin.TEST_RUNTIME_ONLY_CONFIGURATION_NAME, "org.junit.platform:junit-platform-launcher")); .add(JavaPlugin.TEST_RUNTIME_ONLY_CONFIGURATION_NAME, "org.junit.platform:junit-platform-launcher"));

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2021 the original author or authors. * Copyright 2012-2022 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -24,6 +24,7 @@ import java.util.HashSet;
import java.util.LinkedHashMap; import java.util.LinkedHashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Objects;
import java.util.Set; import java.util.Set;
import java.util.SortedSet; import java.util.SortedSet;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@ -70,7 +71,7 @@ public final class InteractiveUpgradeResolver implements UpgradeResolver {
librariesByName.put(library.getName(), library); librariesByName.put(library.getName(), library);
} }
return libraries.stream().filter((library) -> !library.getName().equals("Spring Boot")) return libraries.stream().filter((library) -> !library.getName().equals("Spring Boot"))
.map((library) -> resolveUpgrade(library, librariesByName)).filter((upgrade) -> upgrade != null) .map((library) -> resolveUpgrade(library, librariesByName)).filter(Objects::nonNull)
.collect(Collectors.toList()); .collect(Collectors.toList());
} }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2020 the original author or authors. * Copyright 2012-2022 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -68,7 +68,7 @@ public class CheckClasspathForConflicts extends DefaultTask {
for (File file : this.classpath) { for (File file : this.classpath) {
if (file.isDirectory()) { if (file.isDirectory()) {
Path root = file.toPath(); Path root = file.toPath();
Files.walk(root).filter((path) -> Files.isRegularFile(path)) Files.walk(root).filter(Files::isRegularFile)
.forEach((entry) -> classpathContents.add(root.relativize(entry).toString(), root.toString())); .forEach((entry) -> classpathContents.add(root.relativize(entry).toString(), root.toString()));
} }
else { else {

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2021 the original author or authors. * Copyright 2012-2022 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -63,7 +63,7 @@ class DevToolsR2dbcAutoConfigurationTests {
@Test @Test
void autoConfiguredInMemoryConnectionFactoryIsShutdown() throws Exception { void autoConfiguredInMemoryConnectionFactoryIsShutdown() throws Exception {
ConfigurableApplicationContext context = getContext(() -> createContext()); ConfigurableApplicationContext context = getContext(this::createContext);
ConnectionFactory connectionFactory = context.getBean(ConnectionFactory.class); ConnectionFactory connectionFactory = context.getBean(ConnectionFactory.class);
context.close(); context.close();
assertThat(shutdowns).contains(connectionFactory); assertThat(shutdowns).contains(connectionFactory);

View File

@ -91,7 +91,7 @@ class WarPluginAction implements PluginApplicationAction {
.convention(resolveMainClassName.flatMap((resolver) -> manifestStartClass.isPresent() .convention(resolveMainClassName.flatMap((resolver) -> manifestStartClass.isPresent()
? manifestStartClass : resolveMainClassName.get().readMainClassName())); ? manifestStartClass : resolveMainClassName.get().readMainClassName()));
}); });
bootWarProvider.map((bootWar) -> bootWar.getClasspath()); bootWarProvider.map(War::getClasspath);
return bootWarProvider; return bootWarProvider;
} }

View File

@ -56,7 +56,7 @@ public class EnvironmentPostProcessorApplicationListener implements SmartApplica
* {@link EnvironmentPostProcessor} classes loaded via {@code spring.factories}. * {@link EnvironmentPostProcessor} classes loaded via {@code spring.factories}.
*/ */
public EnvironmentPostProcessorApplicationListener() { public EnvironmentPostProcessorApplicationListener() {
this((classLoader) -> EnvironmentPostProcessorsFactory.fromSpringFactories(classLoader)); this(EnvironmentPostProcessorsFactory::fromSpringFactories);
} }
/** /**

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2021 the original author or authors. * Copyright 2012-2022 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -398,8 +398,7 @@ public final class DataSourceBuilder<T extends DataSource> {
Class<T> dataSourceType) { Class<T> dataSourceType) {
MappedDataSourceProperties<T> result = null; MappedDataSourceProperties<T> result = null;
result = lookup(classLoader, dataSourceType, result, result = lookup(classLoader, dataSourceType, result,
"org.springframework.jdbc.datasource.SimpleDriverDataSource", "org.springframework.jdbc.datasource.SimpleDriverDataSource", SimpleDataSourceProperties::new);
() -> new SimpleDataSourceProperties());
result = lookup(classLoader, dataSourceType, result, "oracle.jdbc.datasource.OracleDataSource", result = lookup(classLoader, dataSourceType, result, "oracle.jdbc.datasource.OracleDataSource",
OracleDataSourceProperties::new); OracleDataSourceProperties::new);
result = lookup(classLoader, dataSourceType, result, "org.h2.jdbcx.JdbcDataSource", result = lookup(classLoader, dataSourceType, result, "org.h2.jdbcx.JdbcDataSource",
@ -660,7 +659,7 @@ public final class DataSourceBuilder<T extends DataSource> {
SimpleDataSourceProperties() { SimpleDataSourceProperties() {
add(DataSourceProperty.URL, SimpleDriverDataSource::getUrl, SimpleDriverDataSource::setUrl); add(DataSourceProperty.URL, SimpleDriverDataSource::getUrl, SimpleDriverDataSource::setUrl);
add(DataSourceProperty.DRIVER_CLASS_NAME, Class.class, (dataSource) -> dataSource.getDriver().getClass(), add(DataSourceProperty.DRIVER_CLASS_NAME, Class.class, (dataSource) -> dataSource.getDriver().getClass(),
(dataSource, driverClass) -> dataSource.setDriverClass(driverClass)); SimpleDriverDataSource::setDriverClass);
add(DataSourceProperty.USERNAME, SimpleDriverDataSource::getUsername, SimpleDriverDataSource::setUsername); add(DataSourceProperty.USERNAME, SimpleDriverDataSource::getUsername, SimpleDriverDataSource::setUsername);
add(DataSourceProperty.PASSWORD, SimpleDriverDataSource::getPassword, SimpleDriverDataSource::setPassword); add(DataSourceProperty.PASSWORD, SimpleDriverDataSource::getPassword, SimpleDriverDataSource::setPassword);
} }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2021 the original author or authors. * Copyright 2012-2022 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -38,7 +38,7 @@ public class SpringBootPropertySource implements PropertySource {
@Override @Override
public void forEach(BiConsumer<String, String> action) { public void forEach(BiConsumer<String, String> action) {
this.properties.forEach((key, value) -> action.accept(key, value)); this.properties.forEach(action::accept);
} }
@Override @Override

View File

@ -133,7 +133,7 @@ public class Instantiator<T> {
*/ */
public List<T> instantiateTypes(Collection<Class<?>> types) { public List<T> instantiateTypes(Collection<Class<?>> types) {
Assert.notNull(types, "Types must not be null"); Assert.notNull(types, "Types must not be null");
return instantiate(types.stream().map((type) -> TypeSupplier.forType(type))); return instantiate(types.stream().map(TypeSupplier::forType));
} }
private List<T> instantiate(Stream<TypeSupplier> typeSuppliers) { private List<T> instantiate(Stream<TypeSupplier> typeSuppliers) {

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2021 the original author or authors. * Copyright 2012-2022 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -116,8 +116,8 @@ public class NettyWebServer implements WebServer {
private String getStartedOnMessage(DisposableServer server) { private String getStartedOnMessage(DisposableServer server) {
StringBuilder message = new StringBuilder(); StringBuilder message = new StringBuilder();
tryAppend(message, "port %s", () -> server.port()); tryAppend(message, "port %s", server::port);
tryAppend(message, "path %s", () -> server.path()); tryAppend(message, "path %s", server::path);
return (message.length() > 0) ? " on " + message : ""; return (message.length() > 0) ? " on " + message : "";
} }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2021 the original author or authors. * Copyright 2012-2022 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -295,7 +295,7 @@ public class UndertowWebServer implements WebServer {
logger.info("Commencing graceful shutdown. Waiting for active requests to complete"); logger.info("Commencing graceful shutdown. Waiting for active requests to complete");
this.gracefulShutdownCallback.set(callback); this.gracefulShutdownCallback.set(callback);
this.gracefulShutdown.shutdown(); this.gracefulShutdown.shutdown();
this.gracefulShutdown.addShutdownListener((success) -> notifyGracefulCallback(success)); this.gracefulShutdown.addShutdownListener(this::notifyGracefulCallback);
} }
private void notifyGracefulCallback(boolean success) { private void notifyGracefulCallback(boolean success) {