Merge branch '3.0.x'

pull/34342/head
Phillip Webb 2 years ago
commit b07269a018

@ -72,7 +72,8 @@ class AsciidoctorConventions {
makeAllWarningsFatal(project); makeAllWarningsFatal(project);
upgradeAsciidoctorJVersion(project); upgradeAsciidoctorJVersion(project);
createAsciidoctorExtensionsConfiguration(project); createAsciidoctorExtensionsConfiguration(project);
project.getTasks().withType(AbstractAsciidoctorTask.class, project.getTasks()
.withType(AbstractAsciidoctorTask.class,
(asciidoctorTask) -> configureAsciidoctorTask(project, asciidoctorTask)); (asciidoctorTask) -> configureAsciidoctorTask(project, asciidoctorTask));
}); });
} }
@ -87,9 +88,11 @@ 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(configuration::extendsFrom); .all(configuration::extendsFrom);
configuration.getDependencies().add(project.getDependencies() configuration.getDependencies()
.add(project.getDependencies()
.create("io.spring.asciidoctor.backends:spring-asciidoctor-backends:0.0.4")); .create("io.spring.asciidoctor.backends:spring-asciidoctor-backends:0.0.4"));
configuration.getDependencies() configuration.getDependencies()
.add(project.getDependencies().create("org.asciidoctor:asciidoctorj-pdf:1.5.3")); .add(project.getDependencies().create("org.asciidoctor:asciidoctorj-pdf:1.5.3"));
@ -145,7 +148,9 @@ class AsciidoctorConventions {
syncDocumentationSource.setDestinationDir(syncedSource); syncDocumentationSource.setDestinationDir(syncedSource);
syncDocumentationSource.from("src/docs/"); syncDocumentationSource.from("src/docs/");
asciidoctorTask.dependsOn(syncDocumentationSource); asciidoctorTask.dependsOn(syncDocumentationSource);
asciidoctorTask.getInputs().dir(syncedSource).withPathSensitivity(PathSensitivity.RELATIVE) asciidoctorTask.getInputs()
.dir(syncedSource)
.withPathSensitivity(PathSensitivity.RELATIVE)
.withPropertyName("synced source"); .withPropertyName("synced source");
asciidoctorTask.setSourceDir(project.relativePath(new File(syncedSource, "asciidoc/"))); asciidoctorTask.setSourceDir(project.relativePath(new File(syncedSource, "asciidoc/")));
return syncDocumentationSource; return syncDocumentationSource;

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2022 the original author or authors. * Copyright 2012-2023 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.
@ -46,12 +46,16 @@ public class DeployedPlugin implements Plugin<Project> {
MavenPublication mavenPublication = publishing.getPublications().create("maven", MavenPublication.class); MavenPublication mavenPublication = publishing.getPublications().create("maven", MavenPublication.class);
project.afterEvaluate((evaluated) -> project.getPlugins().withType(JavaPlugin.class).all((javaPlugin) -> { project.afterEvaluate((evaluated) -> 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(mavenPublication::from);
} }
})); }));
project.getPlugins().withType(JavaPlatformPlugin.class).all((javaPlugin) -> project.getComponents() project.getPlugins()
.matching((component) -> component.getName().equals("javaPlatform")).all(mavenPublication::from)); .withType(JavaPlatformPlugin.class)
.all((javaPlugin) -> project.getComponents()
.matching((component) -> component.getName().equals("javaPlatform"))
.all(mavenPublication::from));
} }
} }

@ -121,15 +121,17 @@ class JavaConventions {
} }
private void configureJarManifestConventions(Project project) { private void configureJarManifestConventions(Project project) {
ExtractResources extractLegalResources = project.getTasks().create("extractLegalResources", ExtractResources extractLegalResources = project.getTasks()
ExtractResources.class); .create("extractLegalResources", ExtractResources.class);
extractLegalResources.getDestinationDirectory().set(project.getLayout().getBuildDirectory().dir("legal")); extractLegalResources.getDestinationDirectory().set(project.getLayout().getBuildDirectory().dir("legal"));
extractLegalResources.setResourcesNames(Arrays.asList("LICENSE.txt", "NOTICE.txt")); extractLegalResources.setResourcesNames(Arrays.asList("LICENSE.txt", "NOTICE.txt"));
extractLegalResources.property("version", project.getVersion().toString()); extractLegalResources.property("version", project.getVersion().toString());
SourceSetContainer sourceSets = project.getExtensions().getByType(SourceSetContainer.class); SourceSetContainer sourceSets = project.getExtensions().getByType(SourceSetContainer.class);
Set<String> sourceJarTaskNames = sourceSets.stream().map(SourceSet::getSourcesJarTaskName) Set<String> sourceJarTaskNames = sourceSets.stream()
.map(SourceSet::getSourcesJarTaskName)
.collect(Collectors.toSet()); .collect(Collectors.toSet());
Set<String> javadocJarTaskNames = sourceSets.stream().map(SourceSet::getJavadocJarTaskName) Set<String> javadocJarTaskNames = sourceSets.stream()
.map(SourceSet::getJavadocJarTaskName)
.collect(Collectors.toSet()); .collect(Collectors.toSet());
project.getTasks().withType(Jar.class, (jar) -> project.afterEvaluate((evaluated) -> { project.getTasks().withType(Jar.class, (jar) -> project.afterEvaluate((evaluated) -> {
jar.metaInf((metaInf) -> metaInf.from(extractLegalResources)); jar.metaInf((metaInf) -> metaInf.from(extractLegalResources));
@ -167,7 +169,8 @@ class JavaConventions {
testRetry.getFailOnPassedAfterRetry().set(true); testRetry.getFailOnPassedAfterRetry().set(true);
testRetry.getMaxRetries().set(isCi() ? 3 : 0); testRetry.getMaxRetries().set(isCi() ? 3 : 0);
}); });
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"));
} }
@ -234,11 +237,15 @@ class JavaConventions {
.matching((configuration) -> configuration.getName().endsWith("Classpath") .matching((configuration) -> configuration.getName().endsWith("Classpath")
|| JavaPlugin.ANNOTATION_PROCESSOR_CONFIGURATION_NAME.equals(configuration.getName())) || JavaPlugin.ANNOTATION_PROCESSOR_CONFIGURATION_NAME.equals(configuration.getName()))
.all((configuration) -> configuration.extendsFrom(dependencyManagement)); .all((configuration) -> configuration.extendsFrom(dependencyManagement));
Dependency springBootParent = project.getDependencies().enforcedPlatform(project.getDependencies() Dependency springBootParent = project.getDependencies()
.enforcedPlatform(project.getDependencies()
.project(Collections.singletonMap("path", ":spring-boot-project:spring-boot-parent"))); .project(Collections.singletonMap("path", ":spring-boot-project:spring-boot-parent")));
dependencyManagement.getDependencies().add(springBootParent); dependencyManagement.getDependencies().add(springBootParent);
project.getPlugins().withType(OptionalDependenciesPlugin.class, (optionalDependencies) -> configurations project.getPlugins()
.getByName(OptionalDependenciesPlugin.OPTIONAL_CONFIGURATION_NAME).extendsFrom(dependencyManagement)); .withType(OptionalDependenciesPlugin.class,
(optionalDependencies) -> configurations
.getByName(OptionalDependenciesPlugin.OPTIONAL_CONFIGURATION_NAME)
.extendsFrom(dependencyManagement));
} }
private void configureToolchain(Project project) { private void configureToolchain(Project project) {
@ -260,8 +267,8 @@ class JavaConventions {
} }
private void createProhibitedDependenciesCheck(Configuration classpath, Project project) { private void createProhibitedDependenciesCheck(Configuration classpath, Project project) {
CheckClasspathForProhibitedDependencies checkClasspathForProhibitedDependencies = project.getTasks().create( CheckClasspathForProhibitedDependencies checkClasspathForProhibitedDependencies = project.getTasks()
"check" + StringUtils.capitalize(classpath.getName() + "ForProhibitedDependencies"), .create("check" + StringUtils.capitalize(classpath.getName() + "ForProhibitedDependencies"),
CheckClasspathForProhibitedDependencies.class); CheckClasspathForProhibitedDependencies.class);
checkClasspathForProhibitedDependencies.setClasspath(classpath); checkClasspathForProhibitedDependencies.setClasspath(classpath);
project.getTasks().getByName(JavaBasePlugin.CHECK_TASK_NAME).dependsOn(checkClasspathForProhibitedDependencies); project.getTasks().getByName(JavaBasePlugin.CHECK_TASK_NAME).dependsOn(checkClasspathForProhibitedDependencies);

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2022 the original author or authors. * Copyright 2012-2023 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,7 +44,8 @@ import org.jetbrains.kotlin.gradle.tasks.KotlinCompile;
class KotlinConventions { class KotlinConventions {
void apply(Project project) { void apply(Project project) {
project.getPlugins().withId("org.jetbrains.kotlin.jvm", project.getPlugins()
.withId("org.jetbrains.kotlin.jvm",
(plugin) -> project.getTasks().withType(KotlinCompile.class, this::configure)); (plugin) -> project.getTasks().withType(KotlinCompile.class, this::configure));
} }

@ -67,7 +67,8 @@ class MavenPublishingConventions {
mavenRepository.setName("deployment"); mavenRepository.setName("deployment");
}); });
} }
publishing.getPublications().withType(MavenPublication.class) publishing.getPublications()
.withType(MavenPublication.class)
.all((mavenPublication) -> customizeMavenPublication(mavenPublication, project)); .all((mavenPublication) -> customizeMavenPublication(mavenPublication, project));
project.getPlugins().withType(JavaPlugin.class).all((javaPlugin) -> { project.getPlugins().withType(JavaPlugin.class).all((javaPlugin) -> {
JavaPluginExtension extension = project.getExtensions().getByType(JavaPluginExtension.class); JavaPluginExtension extension = project.getExtensions().getByType(JavaPluginExtension.class);
@ -79,7 +80,8 @@ class MavenPublishingConventions {
private void customizeMavenPublication(MavenPublication publication, Project project) { private void customizeMavenPublication(MavenPublication publication, Project project) {
customizePom(publication.getPom(), project); customizePom(publication.getPom(), project);
project.getPlugins().withType(JavaPlugin.class) project.getPlugins()
.withType(JavaPlugin.class)
.all((javaPlugin) -> customizeJavaMavenPublication(publication, project)); .all((javaPlugin) -> customizeJavaMavenPublication(publication, project));
suppressMavenOptionalFeatureWarnings(publication); suppressMavenOptionalFeatureWarnings(publication);
} }

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2020 the original author or authors. * Copyright 2012-2023 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.
@ -61,31 +61,40 @@ public class MavenRepositoryPlugin implements Plugin<Project> {
mavenRepository.setName("project"); mavenRepository.setName("project");
mavenRepository.setUrl(repositoryLocation.toURI()); mavenRepository.setUrl(repositoryLocation.toURI());
}); });
project.getTasks().matching((task) -> task.getName().equals(PUBLISH_TO_PROJECT_REPOSITORY_TASK_NAME)) project.getTasks()
.matching((task) -> task.getName().equals(PUBLISH_TO_PROJECT_REPOSITORY_TASK_NAME))
.all((task) -> setUpProjectRepository(project, task, repositoryLocation)); .all((task) -> setUpProjectRepository(project, task, repositoryLocation));
project.getTasks().matching((task) -> task.getName().equals("publishPluginMavenPublicationToProjectRepository")) project.getTasks()
.matching((task) -> task.getName().equals("publishPluginMavenPublicationToProjectRepository"))
.all((task) -> setUpProjectRepository(project, task, repositoryLocation)); .all((task) -> setUpProjectRepository(project, task, repositoryLocation));
} }
private void setUpProjectRepository(Project project, Task publishTask, File repositoryLocation) { private void setUpProjectRepository(Project project, Task publishTask, File repositoryLocation) {
publishTask.doFirst(new CleanAction(repositoryLocation)); publishTask.doFirst(new CleanAction(repositoryLocation));
Configuration projectRepository = project.getConfigurations().create(MAVEN_REPOSITORY_CONFIGURATION_NAME); Configuration projectRepository = project.getConfigurations().create(MAVEN_REPOSITORY_CONFIGURATION_NAME);
project.getArtifacts().add(projectRepository.getName(), repositoryLocation, project.getArtifacts()
(artifact) -> artifact.builtBy(publishTask)); .add(projectRepository.getName(), repositoryLocation, (artifact) -> artifact.builtBy(publishTask));
DependencySet target = projectRepository.getDependencies(); DependencySet target = projectRepository.getDependencies();
project.getPlugins().withType(JavaPlugin.class).all((javaPlugin) -> addMavenRepositoryDependencies(project, project.getPlugins()
JavaPlugin.IMPLEMENTATION_CONFIGURATION_NAME, target)); .withType(JavaPlugin.class)
project.getPlugins().withType(JavaLibraryPlugin.class) .all((javaPlugin) -> addMavenRepositoryDependencies(project, JavaPlugin.IMPLEMENTATION_CONFIGURATION_NAME,
target));
project.getPlugins()
.withType(JavaLibraryPlugin.class)
.all((javaLibraryPlugin) -> addMavenRepositoryDependencies(project, JavaPlugin.API_CONFIGURATION_NAME, .all((javaLibraryPlugin) -> addMavenRepositoryDependencies(project, JavaPlugin.API_CONFIGURATION_NAME,
target)); target));
project.getPlugins().withType(JavaPlatformPlugin.class) project.getPlugins()
.withType(JavaPlatformPlugin.class)
.all((javaPlugin) -> addMavenRepositoryDependencies(project, JavaPlatformPlugin.API_CONFIGURATION_NAME, .all((javaPlugin) -> addMavenRepositoryDependencies(project, JavaPlatformPlugin.API_CONFIGURATION_NAME,
target)); target));
} }
private void addMavenRepositoryDependencies(Project project, String sourceConfigurationName, DependencySet target) { private void addMavenRepositoryDependencies(Project project, String sourceConfigurationName, DependencySet target) {
project.getConfigurations().getByName(sourceConfigurationName).getDependencies() project.getConfigurations()
.withType(ProjectDependency.class).all((dependency) -> { .getByName(sourceConfigurationName)
.getDependencies()
.withType(ProjectDependency.class)
.all((dependency) -> {
Map<String, String> dependencyDescriptor = new HashMap<>(); Map<String, String> dependencyDescriptor = new HashMap<>();
dependencyDescriptor.put("path", dependency.getDependencyProject().getPath()); dependencyDescriptor.put("path", dependency.getDependencyProject().getPath());
dependencyDescriptor.put("configuration", MAVEN_REPOSITORY_CONFIGURATION_NAME); dependencyDescriptor.put("configuration", MAVEN_REPOSITORY_CONFIGURATION_NAME);

@ -1,5 +1,5 @@
/* /*
* Copyright 2021-2021 the original author or authors. * Copyright 2021-2023 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.

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2022 the original author or authors. * Copyright 2012-2023 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.
@ -46,9 +46,9 @@ public class ArchitecturePlugin implements Plugin<Project> {
JavaPluginExtension javaPluginExtension = project.getExtensions().getByType(JavaPluginExtension.class); JavaPluginExtension javaPluginExtension = project.getExtensions().getByType(JavaPluginExtension.class);
List<TaskProvider<PackageTangleCheck>> packageTangleChecks = new ArrayList<>(); List<TaskProvider<PackageTangleCheck>> packageTangleChecks = new ArrayList<>();
for (SourceSet sourceSet : javaPluginExtension.getSourceSets()) { for (SourceSet sourceSet : javaPluginExtension.getSourceSets()) {
TaskProvider<PackageTangleCheck> checkPackageTangles = project.getTasks().register( TaskProvider<PackageTangleCheck> checkPackageTangles = project.getTasks()
"checkForPackageTangles" + StringUtils.capitalize(sourceSet.getName()), PackageTangleCheck.class, .register("checkForPackageTangles" + StringUtils.capitalize(sourceSet.getName()),
(task) -> { PackageTangleCheck.class, (task) -> {
task.setClasses(sourceSet.getOutput().getClassesDirs()); task.setClasses(sourceSet.getOutput().getClassesDirs());
task.setDescription("Checks the classes of the " + sourceSet.getName() task.setDescription("Checks the classes of the " + sourceSet.getName()
+ " source set for package tangles."); + " source set for package tangles.");

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2022 the original author or authors. * Copyright 2012-2023 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.

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2022 the original author or authors. * Copyright 2012-2023 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.
@ -60,19 +60,25 @@ public class AutoConfigurationPlugin implements Plugin<Project> {
Configuration annotationProcessors = project.getConfigurations() Configuration annotationProcessors = project.getConfigurations()
.getByName(JavaPlugin.ANNOTATION_PROCESSOR_CONFIGURATION_NAME); .getByName(JavaPlugin.ANNOTATION_PROCESSOR_CONFIGURATION_NAME);
annotationProcessors.getDependencies() annotationProcessors.getDependencies()
.add(project.getDependencies().project(Collections.singletonMap("path", .add(project.getDependencies()
.project(Collections.singletonMap("path",
":spring-boot-project:spring-boot-tools:spring-boot-autoconfigure-processor"))); ":spring-boot-project:spring-boot-tools:spring-boot-autoconfigure-processor")));
annotationProcessors.getDependencies() annotationProcessors.getDependencies()
.add(project.getDependencies().project(Collections.singletonMap("path", .add(project.getDependencies()
.project(Collections.singletonMap("path",
":spring-boot-project:spring-boot-tools:spring-boot-configuration-processor"))); ":spring-boot-project:spring-boot-tools:spring-boot-configuration-processor")));
project.getTasks().create("autoConfigurationMetadata", AutoConfigurationMetadata.class, (task) -> { project.getTasks().create("autoConfigurationMetadata", AutoConfigurationMetadata.class, (task) -> {
SourceSet main = project.getExtensions().getByType(JavaPluginExtension.class).getSourceSets() SourceSet main = project.getExtensions()
.getByType(JavaPluginExtension.class)
.getSourceSets()
.getByName(SourceSet.MAIN_SOURCE_SET_NAME); .getByName(SourceSet.MAIN_SOURCE_SET_NAME);
task.setSourceSet(main); task.setSourceSet(main);
task.dependsOn(main.getClassesTaskName()); task.dependsOn(main.getClassesTaskName());
task.setOutputFile(new File(project.getBuildDir(), "auto-configuration-metadata.properties")); task.setOutputFile(new File(project.getBuildDir(), "auto-configuration-metadata.properties"));
project.getArtifacts().add(AutoConfigurationPlugin.AUTO_CONFIGURATION_METADATA_CONFIGURATION_NAME, project.getArtifacts()
project.provider((Callable<File>) task::getOutputFile), (artifact) -> artifact.builtBy(task)); .add(AutoConfigurationPlugin.AUTO_CONFIGURATION_METADATA_CONFIGURATION_NAME,
project.provider((Callable<File>) task::getOutputFile),
(artifact) -> artifact.builtBy(task));
}); });
}); });
} }

@ -125,7 +125,8 @@ public class BomExtension {
public void effectiveBomArtifact() { public void effectiveBomArtifact() {
Configuration effectiveBomConfiguration = this.project.getConfigurations().create("effectiveBom"); Configuration effectiveBomConfiguration = this.project.getConfigurations().create("effectiveBom");
this.project.getTasks().matching((task) -> task.getName().equals(DeployedPlugin.GENERATE_POM_TASK_NAME)) this.project.getTasks()
.matching((task) -> task.getName().equals(DeployedPlugin.GENERATE_POM_TASK_NAME))
.all((task) -> { .all((task) -> {
Sync syncBom = this.project.getTasks().create("syncBom", Sync.class); Sync syncBom = this.project.getTasks().create("syncBom", Sync.class);
syncBom.dependsOn(task); syncBom.dependsOn(task);
@ -145,8 +146,8 @@ public class BomExtension {
catch (IOException ex) { catch (IOException ex) {
throw new GradleException("Failed to prepare settings.xml", ex); throw new GradleException("Failed to prepare settings.xml", ex);
} }
MavenExec generateEffectiveBom = this.project.getTasks().create("generateEffectiveBom", MavenExec generateEffectiveBom = this.project.getTasks()
MavenExec.class); .create("generateEffectiveBom", MavenExec.class);
generateEffectiveBom.setProjectDir(generatedBomDir); generateEffectiveBom.setProjectDir(generatedBomDir);
File effectiveBom = new File(this.project.getBuildDir(), File effectiveBom = new File(this.project.getBuildDir(),
"generated/effective-bom/" + this.project.getName() + "-effective-bom.xml"); "generated/effective-bom/" + this.project.getName() + "-effective-bom.xml");
@ -155,7 +156,8 @@ public class BomExtension {
generateEffectiveBom.dependsOn(syncBom); generateEffectiveBom.dependsOn(syncBom);
generateEffectiveBom.getOutputs().file(effectiveBom); generateEffectiveBom.getOutputs().file(effectiveBom);
generateEffectiveBom.doLast(new StripUnrepeatableOutputAction(effectiveBom)); generateEffectiveBom.doLast(new StripUnrepeatableOutputAction(effectiveBom));
this.project.getArtifacts().add(effectiveBomConfiguration.getName(), effectiveBom, this.project.getArtifacts()
.add(effectiveBomConfiguration.getName(), effectiveBom,
(artifact) -> artifact.builtBy(generateEffectiveBom)); (artifact) -> artifact.builtBy(generateEffectiveBom));
}); });
} }
@ -196,8 +198,9 @@ public class BomExtension {
for (Group group : library.getGroups()) { for (Group group : library.getGroups()) {
for (Module module : group.getModules()) { for (Module module : group.getModules()) {
putArtifactVersionProperty(group.getId(), module.getName(), module.getClassifier(), versionProperty); putArtifactVersionProperty(group.getId(), module.getName(), module.getClassifier(), versionProperty);
this.dependencyHandler.getConstraints().add(JavaPlatformPlugin.API_CONFIGURATION_NAME, this.dependencyHandler.getConstraints()
createDependencyNotation(group.getId(), module.getName(), library.getVersion().getVersion())); .add(JavaPlatformPlugin.API_CONFIGURATION_NAME, createDependencyNotation(group.getId(),
module.getName(), library.getVersion().getVersion()));
} }
for (String bomImport : group.getBoms()) { for (String bomImport : group.getBoms()) {
putArtifactVersionProperty(group.getId(), bomImport, versionProperty); putArtifactVersionProperty(group.getId(), bomImport, versionProperty);
@ -530,8 +533,9 @@ public class BomExtension {
org.w3c.dom.Node reporting = (org.w3c.dom.Node) xpath.evaluate("/project/reporting", document, org.w3c.dom.Node reporting = (org.w3c.dom.Node) xpath.evaluate("/project/reporting", document,
XPathConstants.NODE); XPathConstants.NODE);
reporting.getParentNode().removeChild(reporting); reporting.getParentNode().removeChild(reporting);
TransformerFactory.newInstance().newTransformer().transform(new DOMSource(document), TransformerFactory.newInstance()
new StreamResult(this.effectiveBom)); .newTransformer()
.transform(new DOMSource(document), new StreamResult(this.effectiveBom));
} }
catch (Exception ex) { catch (Exception ex) {
throw new TaskExecutionException(task, ex); throw new TaskExecutionException(task, ex);

@ -60,8 +60,8 @@ public class BomPlugin implements Plugin<Project> {
JavaPlatformExtension javaPlatform = project.getExtensions().getByType(JavaPlatformExtension.class); JavaPlatformExtension javaPlatform = project.getExtensions().getByType(JavaPlatformExtension.class);
javaPlatform.allowDependencies(); javaPlatform.allowDependencies();
createApiEnforcedConfiguration(project); createApiEnforcedConfiguration(project);
BomExtension bom = project.getExtensions().create("bom", BomExtension.class, project.getDependencies(), BomExtension bom = project.getExtensions()
project); .create("bom", BomExtension.class, project.getDependencies(), project);
project.getTasks().create("bomrCheck", CheckBom.class, bom); project.getTasks().create("bomrCheck", CheckBom.class, bom);
project.getTasks().create("bomrUpgrade", UpgradeBom.class, bom); project.getTasks().create("bomrUpgrade", UpgradeBom.class, bom);
project.getTasks().create("moveToSnapshots", MoveToSnapshots.class, bom); project.getTasks().create("moveToSnapshots", MoveToSnapshots.class, bom);
@ -70,15 +70,17 @@ public class BomPlugin implements Plugin<Project> {
} }
private void createApiEnforcedConfiguration(Project project) { private void createApiEnforcedConfiguration(Project project) {
Configuration apiEnforced = project.getConfigurations().create(API_ENFORCED_CONFIGURATION_NAME, Configuration apiEnforced = project.getConfigurations()
(configuration) -> { .create(API_ENFORCED_CONFIGURATION_NAME, (configuration) -> {
configuration.setCanBeConsumed(false); configuration.setCanBeConsumed(false);
configuration.setCanBeResolved(false); configuration.setCanBeResolved(false);
configuration.setVisible(false); configuration.setVisible(false);
}); });
project.getConfigurations().getByName(JavaPlatformPlugin.ENFORCED_API_ELEMENTS_CONFIGURATION_NAME) project.getConfigurations()
.getByName(JavaPlatformPlugin.ENFORCED_API_ELEMENTS_CONFIGURATION_NAME)
.extendsFrom(apiEnforced); .extendsFrom(apiEnforced);
project.getConfigurations().getByName(JavaPlatformPlugin.ENFORCED_RUNTIME_ELEMENTS_CONFIGURATION_NAME) project.getConfigurations()
.getByName(JavaPlatformPlugin.ENFORCED_RUNTIME_ELEMENTS_CONFIGURATION_NAME)
.extendsFrom(apiEnforced); .extendsFrom(apiEnforced);
} }
@ -155,11 +157,14 @@ public class BomPlugin implements Plugin<Project> {
for (Node dependency : findChildren(dependencies, "dependency")) { for (Node dependency : findChildren(dependencies, "dependency")) {
String groupId = findChild(dependency, "groupId").text(); String groupId = findChild(dependency, "groupId").text();
String artifactId = findChild(dependency, "artifactId").text(); String artifactId = findChild(dependency, "artifactId").text();
this.bom.getLibraries().stream().flatMap((library) -> library.getGroups().stream()) this.bom.getLibraries()
.stream()
.flatMap((library) -> library.getGroups().stream())
.filter((group) -> group.getId().equals(groupId)) .filter((group) -> group.getId().equals(groupId))
.flatMap((group) -> group.getModules().stream()) .flatMap((group) -> group.getModules().stream())
.filter((module) -> module.getName().equals(artifactId)) .filter((module) -> module.getName().equals(artifactId))
.flatMap((module) -> module.getExclusions().stream()).forEach((exclusion) -> { .flatMap((module) -> module.getExclusions().stream())
.forEach((exclusion) -> {
Node exclusions = findOrCreateNode(dependency, "exclusions"); Node exclusions = findOrCreateNode(dependency, "exclusions");
Node node = new Node(exclusions, "exclusion"); Node node = new Node(exclusions, "exclusion");
node.appendNode("groupId", exclusion.getGroupId()); node.appendNode("groupId", exclusion.getGroupId());
@ -175,12 +180,15 @@ public class BomPlugin implements Plugin<Project> {
for (Node dependency : findChildren(dependencies, "dependency")) { for (Node dependency : findChildren(dependencies, "dependency")) {
String groupId = findChild(dependency, "groupId").text(); String groupId = findChild(dependency, "groupId").text();
String artifactId = findChild(dependency, "artifactId").text(); String artifactId = findChild(dependency, "artifactId").text();
Set<String> types = this.bom.getLibraries().stream() Set<String> types = this.bom.getLibraries()
.stream()
.flatMap((library) -> library.getGroups().stream()) .flatMap((library) -> library.getGroups().stream())
.filter((group) -> group.getId().equals(groupId)) .filter((group) -> group.getId().equals(groupId))
.flatMap((group) -> group.getModules().stream()) .flatMap((group) -> group.getModules().stream())
.filter((module) -> module.getName().equals(artifactId)).map(Module::getType) .filter((module) -> module.getName().equals(artifactId))
.filter(Objects::nonNull).collect(Collectors.toSet()); .map(Module::getType)
.filter(Objects::nonNull)
.collect(Collectors.toSet());
if (types.size() > 1) { if (types.size() > 1) {
throw new IllegalStateException( throw new IllegalStateException(
"Multiple types for " + groupId + ":" + artifactId + ": " + types); "Multiple types for " + groupId + ":" + artifactId + ": " + types);
@ -201,12 +209,15 @@ public class BomPlugin implements Plugin<Project> {
String groupId = findChild(dependency, "groupId").text(); String groupId = findChild(dependency, "groupId").text();
String artifactId = findChild(dependency, "artifactId").text(); String artifactId = findChild(dependency, "artifactId").text();
String version = findChild(dependency, "version").text(); String version = findChild(dependency, "version").text();
Set<String> classifiers = this.bom.getLibraries().stream() Set<String> classifiers = this.bom.getLibraries()
.stream()
.flatMap((library) -> library.getGroups().stream()) .flatMap((library) -> library.getGroups().stream())
.filter((group) -> group.getId().equals(groupId)) .filter((group) -> group.getId().equals(groupId))
.flatMap((group) -> group.getModules().stream()) .flatMap((group) -> group.getModules().stream())
.filter((module) -> module.getName().equals(artifactId)).map(Module::getClassifier) .filter((module) -> module.getName().equals(artifactId))
.filter(Objects::nonNull).collect(Collectors.toSet()); .map(Module::getClassifier)
.filter(Objects::nonNull)
.collect(Collectors.toSet());
Node target = dependency; Node target = dependency;
for (String classifier : classifiers) { for (String classifier : classifiers) {
if (classifier.length() > 0) { if (classifier.length() > 0) {

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2021 the original author or authors. * Copyright 2012-2023 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.
@ -61,10 +61,14 @@ public class CheckBom extends DefaultTask {
Set<String> resolved = getProject().getConfigurations() Set<String> resolved = getProject().getConfigurations()
.detachedConfiguration( .detachedConfiguration(
getProject().getDependencies().create(groupId + ":" + module.getName() + ":" + version)) getProject().getDependencies().create(groupId + ":" + module.getName() + ":" + version))
.getResolvedConfiguration().getResolvedArtifacts().stream() .getResolvedConfiguration()
.getResolvedArtifacts()
.stream()
.map((artifact) -> artifact.getModuleVersion().getId()) .map((artifact) -> artifact.getModuleVersion().getId())
.map((id) -> id.getGroup() + ":" + id.getModule().getName()).collect(Collectors.toSet()); .map((id) -> id.getGroup() + ":" + id.getModule().getName())
Set<String> exclusions = module.getExclusions().stream() .collect(Collectors.toSet());
Set<String> exclusions = module.getExclusions()
.stream()
.map((exclusion) -> exclusion.getGroupId() + ":" + exclusion.getArtifactId()) .map((exclusion) -> exclusion.getGroupId() + ":" + exclusion.getArtifactId())
.collect(Collectors.toSet()); .collect(Collectors.toSet());
Set<String> unused = new TreeSet<>(); Set<String> unused = new TreeSet<>();

@ -75,9 +75,11 @@ final class MavenMetadataVersionResolver implements VersionResolver {
URI url = repositoryUrl.resolve(groupId.replace('.', '/') + "/" + artifactId + "/maven-metadata.xml"); URI url = repositoryUrl.resolve(groupId.replace('.', '/') + "/" + artifactId + "/maven-metadata.xml");
try { try {
String metadata = this.rest.getForObject(url, String.class); String metadata = this.rest.getForObject(url, String.class);
Document metadataDocument = DocumentBuilderFactory.newInstance().newDocumentBuilder() Document metadataDocument = DocumentBuilderFactory.newInstance()
.newDocumentBuilder()
.parse(new InputSource(new StringReader(metadata))); .parse(new InputSource(new StringReader(metadata)));
NodeList versionNodes = (NodeList) XPathFactory.newInstance().newXPath() NodeList versionNodes = (NodeList) XPathFactory.newInstance()
.newXPath()
.evaluate("/metadata/versioning/versions/version", metadataDocument, XPathConstants.NODESET); .evaluate("/metadata/versioning/versions/version", metadataDocument, XPathConstants.NODESET);
for (int i = 0; i < versionNodes.getLength(); i++) { for (int i = 0; i < versionNodes.getLength(); i++) {
versions.add(versionNodes.item(i).getTextContent()); versions.add(versionNodes.item(i).getTextContent());

@ -106,14 +106,19 @@ class StandardLibraryUpdateResolver implements LibraryUpdateResolver {
getLaterVersionsForModule(group.getId(), plugin, libraryVersion)); getLaterVersionsForModule(group.getId(), plugin, libraryVersion));
} }
} }
List<DependencyVersion> allVersions = moduleVersions.values().stream().flatMap(SortedSet::stream).distinct() List<DependencyVersion> allVersions = moduleVersions.values()
.stream()
.flatMap(SortedSet::stream)
.distinct()
.filter((dependencyVersion) -> isPermitted(dependencyVersion, library.getProhibitedVersions())) .filter((dependencyVersion) -> isPermitted(dependencyVersion, library.getProhibitedVersions()))
.collect(Collectors.toList()); .collect(Collectors.toList());
if (allVersions.isEmpty()) { if (allVersions.isEmpty()) {
return Collections.emptyList(); return Collections.emptyList();
} }
return allVersions.stream().map((version) -> new VersionOption.ResolvedVersionOption(version, return allVersions.stream()
getMissingModules(moduleVersions, version))).collect(Collectors.toList()); .map((version) -> new VersionOption.ResolvedVersionOption(version,
getMissingModules(moduleVersions, version)))
.collect(Collectors.toList());
} }
private List<VersionOption> determineAlignedVersionOption(Library library, Map<String, Library> libraries) { private List<VersionOption> determineAlignedVersionOption(Library library, Map<String, Library> libraries) {

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2022 the original author or authors. * Copyright 2012-2023 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.

@ -129,11 +129,13 @@ public abstract class UpgradeDependencies extends DefaultTask {
existingUpgradeIssue.label(Arrays.asList("type: task", "status: superseded")); existingUpgradeIssue.label(Arrays.asList("type: task", "status: superseded"));
} }
} }
if (new ProcessBuilder().command("git", "add", modified.toFile().getAbsolutePath()).start() if (new ProcessBuilder().command("git", "add", modified.toFile().getAbsolutePath())
.start()
.waitFor() != 0) { .waitFor() != 0) {
throw new IllegalStateException("git add failed"); throw new IllegalStateException("git add failed");
} }
if (new ProcessBuilder().command("git", "commit", "-m", commitMessage(upgrade, issueNumber)).start() if (new ProcessBuilder().command("git", "commit", "-m", commitMessage(upgrade, issueNumber))
.start()
.waitFor() != 0) { .waitFor() != 0) {
throw new IllegalStateException("git commit failed"); throw new IllegalStateException("git commit failed");
} }
@ -175,7 +177,8 @@ public abstract class UpgradeDependencies extends DefaultTask {
private Milestone determineMilestone(GitHubRepository repository) { private Milestone determineMilestone(GitHubRepository repository) {
List<Milestone> milestones = repository.getMilestones(); List<Milestone> milestones = repository.getMilestones();
java.util.Optional<Milestone> matchingMilestone = milestones.stream() java.util.Optional<Milestone> matchingMilestone = milestones.stream()
.filter((milestone) -> milestone.getName().equals(getMilestone().get())).findFirst(); .filter((milestone) -> milestone.getName().equals(getMilestone().get()))
.findFirst();
if (!matchingMilestone.isPresent()) { if (!matchingMilestone.isPresent()) {
throw new InvalidUserDataException("Unknown milestone: " + getMilestone().get()); throw new InvalidUserDataException("Unknown milestone: " + getMilestone().get());
} }
@ -185,7 +188,8 @@ public abstract class UpgradeDependencies extends DefaultTask {
private Issue findExistingUpgradeIssue(List<Issue> existingUpgradeIssues, Upgrade upgrade) { private Issue findExistingUpgradeIssue(List<Issue> existingUpgradeIssues, Upgrade upgrade) {
String toMatch = "Upgrade to " + upgrade.getLibrary().getName(); String toMatch = "Upgrade to " + upgrade.getLibrary().getName();
for (Issue existingUpgradeIssue : existingUpgradeIssues) { for (Issue existingUpgradeIssue : existingUpgradeIssues) {
if (existingUpgradeIssue.getTitle().substring(0, existingUpgradeIssue.getTitle().lastIndexOf(' ')) if (existingUpgradeIssue.getTitle()
.substring(0, existingUpgradeIssue.getTitle().lastIndexOf(' '))
.equals(toMatch)) { .equals(toMatch)) {
return existingUpgradeIssue; return existingUpgradeIssue;
} }
@ -197,8 +201,8 @@ public abstract class UpgradeDependencies extends DefaultTask {
private List<Upgrade> resolveUpgrades() { private List<Upgrade> resolveUpgrades() {
List<Upgrade> upgrades = new InteractiveUpgradeResolver(getServices().get(UserInputHandler.class), List<Upgrade> upgrades = new InteractiveUpgradeResolver(getServices().get(UserInputHandler.class),
new MultithreadedLibraryUpdateResolver(new MavenMetadataVersionResolver(getRepositoryUris().get()), new MultithreadedLibraryUpdateResolver(new MavenMetadataVersionResolver(getRepositoryUris().get()),
this.bom.getUpgrade().getPolicy(), getThreads().get())).resolveUpgrades( this.bom.getUpgrade().getPolicy(), getThreads().get()))
matchingLibraries(getLibraries().getOrNull()), this.bom.getLibraries()); .resolveUpgrades(matchingLibraries(getLibraries().getOrNull()), this.bom.getLibraries());
return upgrades; return upgrades;
} }
@ -207,8 +211,10 @@ public abstract class UpgradeDependencies extends DefaultTask {
return this.bom.getLibraries(); return this.bom.getLibraries();
} }
Predicate<String> libraryPredicate = Pattern.compile(pattern).asPredicate(); Predicate<String> libraryPredicate = Pattern.compile(pattern).asPredicate();
List<Library> matchingLibraries = this.bom.getLibraries().stream() List<Library> matchingLibraries = this.bom.getLibraries()
.filter((library) -> libraryPredicate.test(library.getName())).toList(); .stream()
.filter((library) -> libraryPredicate.test(library.getName()))
.toList();
if (matchingLibraries.isEmpty()) { if (matchingLibraries.isEmpty()) {
throw new InvalidUserDataException("No libraries matched '" + pattern + "'"); throw new InvalidUserDataException("No libraries matched '" + pattern + "'");
} }

@ -49,7 +49,8 @@ final class StandardGitHub implements GitHub {
Collections.singletonList(new MappingJackson2HttpMessageConverter(new ObjectMapper()))); Collections.singletonList(new MappingJackson2HttpMessageConverter(new ObjectMapper())));
restTemplate.getInterceptors().add((request, body, execution) -> { restTemplate.getInterceptors().add((request, body, execution) -> {
request.getHeaders().add("User-Agent", StandardGitHub.this.username); request.getHeaders().add("User-Agent", StandardGitHub.this.username);
request.getHeaders().add("Authorization", "Basic " + Base64.getEncoder() request.getHeaders()
.add("Authorization", "Basic " + Base64.getEncoder()
.encodeToString((StandardGitHub.this.username + ":" + StandardGitHub.this.password).getBytes())); .encodeToString((StandardGitHub.this.username + ":" + StandardGitHub.this.password).getBytes()));
request.getHeaders().add("Accept", MediaType.APPLICATION_JSON_VALUE); request.getHeaders().add("Accept", MediaType.APPLICATION_JSON_VALUE);
return execution.execute(request, body); return execution.execute(request, body);

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2022 the original author or authors. * Copyright 2012-2023 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.
@ -70,8 +70,8 @@ public class CheckClasspathForConflicts extends DefaultTask {
if (file.isDirectory()) { if (file.isDirectory()) {
Path root = file.toPath(); Path root = file.toPath();
try (Stream<Path> pathStream = Files.walk(root)) { try (Stream<Path> pathStream = Files.walk(root)) {
pathStream.filter(Files::isRegularFile).forEach( pathStream.filter(Files::isRegularFile)
(entry) -> classpathContents.add(root.relativize(entry).toString(), root.toString())); .forEach((entry) -> classpathContents.add(root.relativize(entry).toString(), root.toString()));
} }
} }
else { else {
@ -111,7 +111,9 @@ public class CheckClasspathForConflicts extends DefaultTask {
} }
private Map<String, List<String>> getConflicts(List<Predicate<String>> ignores) { private Map<String, List<String>> getConflicts(List<Predicate<String>> ignores) {
return this.classpathContents.entrySet().stream().filter((entry) -> entry.getValue().size() > 1) return this.classpathContents.entrySet()
.stream()
.filter((entry) -> entry.getValue().size() > 1)
.filter((entry) -> canConflict(entry.getKey(), ignores)) .filter((entry) -> canConflict(entry.getKey(), ignores))
.collect(Collectors.toMap(Entry::getKey, Entry::getValue, (v1, v2) -> v1, TreeMap::new)); .collect(Collectors.toMap(Entry::getKey, Entry::getValue, (v1, v2) -> v1, TreeMap::new));
} }

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2022 the original author or authors. * Copyright 2012-2023 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.
@ -52,9 +52,13 @@ public class CheckClasspathForProhibitedDependencies extends DefaultTask {
@TaskAction @TaskAction
public void checkForProhibitedDependencies() { public void checkForProhibitedDependencies() {
TreeSet<String> prohibited = this.classpath.getResolvedConfiguration().getResolvedArtifacts().stream() TreeSet<String> prohibited = this.classpath.getResolvedConfiguration()
.map((artifact) -> artifact.getModuleVersion().getId()).filter(this::prohibited) .getResolvedArtifacts()
.map((id) -> id.getGroup() + ":" + id.getName()).collect(Collectors.toCollection(TreeSet::new)); .stream()
.map((artifact) -> artifact.getModuleVersion().getId())
.filter(this::prohibited)
.map((id) -> id.getGroup() + ":" + id.getName())
.collect(Collectors.toCollection(TreeSet::new));
if (!prohibited.isEmpty()) { if (!prohibited.isEmpty()) {
StringBuilder message = new StringBuilder(String.format("Found prohibited dependencies:%n")); StringBuilder message = new StringBuilder(String.format("Found prohibited dependencies:%n"));
for (String dependency : prohibited) { for (String dependency : prohibited) {

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2022 the original author or authors. * Copyright 2012-2023 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.
@ -67,8 +67,8 @@ public class CheckClasspathForUnnecessaryExclusions extends DefaultTask {
ConfigurationContainer configurations) { ConfigurationContainer configurations) {
this.dependencyHandler = getProject().getDependencies(); this.dependencyHandler = getProject().getDependencies();
this.configurations = getProject().getConfigurations(); this.configurations = getProject().getConfigurations();
this.platform = this.dependencyHandler.create( this.platform = this.dependencyHandler
this.dependencyHandler.platform(this.dependencyHandler.project(SPRING_BOOT_DEPENDENCIES_PROJECT))); .create(this.dependencyHandler.platform(this.dependencyHandler.project(SPRING_BOOT_DEPENDENCIES_PROJECT)));
getOutputs().upToDateWhen((task) -> true); getOutputs().upToDateWhen((task) -> true);
} }
@ -86,7 +86,9 @@ public class CheckClasspathForUnnecessaryExclusions extends DefaultTask {
private void processDependency(ModuleDependency dependency) { private void processDependency(ModuleDependency dependency) {
String dependencyId = getId(dependency); String dependencyId = getId(dependency);
TreeSet<String> exclusions = dependency.getExcludeRules().stream().map(this::getId) TreeSet<String> exclusions = dependency.getExcludeRules()
.stream()
.map(this::getId)
.collect(Collectors.toCollection(TreeSet::new)); .collect(Collectors.toCollection(TreeSet::new));
this.exclusionsByDependencyId.put(dependencyId, exclusions); this.exclusionsByDependencyId.put(dependencyId, exclusions);
if (!exclusions.isEmpty()) { if (!exclusions.isEmpty()) {
@ -106,7 +108,12 @@ public class CheckClasspathForUnnecessaryExclusions extends DefaultTask {
if (!exclusions.isEmpty()) { if (!exclusions.isEmpty()) {
Dependency toCheck = this.dependencyById.get(dependencyId); Dependency toCheck = this.dependencyById.get(dependencyId);
List<String> dependencies = this.configurations.detachedConfiguration(toCheck, this.platform) List<String> dependencies = this.configurations.detachedConfiguration(toCheck, this.platform)
.getIncoming().getArtifacts().getArtifacts().stream().map(this::getId).toList(); .getIncoming()
.getArtifacts()
.getArtifacts()
.stream()
.map(this::getId)
.toList();
exclusions.removeAll(dependencies); exclusions.removeAll(dependencies);
removeProfileExclusions(dependencyId, exclusions); removeProfileExclusions(dependencyId, exclusions);
if (!exclusions.isEmpty()) { if (!exclusions.isEmpty()) {

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2020 the original author or authors. * Copyright 2012-2023 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.
@ -64,7 +64,9 @@ public class ExtractVersionConstraints extends DefaultTask {
} }
public void enforcedPlatform(String projectPath) { public void enforcedPlatform(String projectPath) {
this.configuration.getDependencies().add(getProject().getDependencies().enforcedPlatform( this.configuration.getDependencies()
.add(getProject().getDependencies()
.enforcedPlatform(
getProject().getDependencies().project(Collections.singletonMap("path", projectPath)))); getProject().getDependencies().project(Collections.singletonMap("path", projectPath))));
this.projectPaths.add(projectPath); this.projectPaths.add(projectPath);
} }
@ -89,8 +91,10 @@ public class ExtractVersionConstraints extends DefaultTask {
this.configuration.resolve(); this.configuration.resolve();
for (String projectPath : this.projectPaths) { for (String projectPath : this.projectPaths) {
extractVersionProperties(projectPath); extractVersionProperties(projectPath);
for (DependencyConstraint constraint : getProject().project(projectPath).getConfigurations() for (DependencyConstraint constraint : getProject().project(projectPath)
.getByName("apiElements").getAllDependencyConstraints()) { .getConfigurations()
.getByName("apiElements")
.getAllDependencyConstraints()) {
this.versionConstraints.put(constraint.getGroup() + ":" + constraint.getName(), this.versionConstraints.put(constraint.getGroup() + ":" + constraint.getName(),
constraint.getVersionConstraint().toString()); constraint.getVersionConstraint().toString());
this.constrainedVersions.add(new ConstrainedVersion(constraint.getGroup(), constraint.getName(), this.constrainedVersions.add(new ConstrainedVersion(constraint.getGroup(), constraint.getName(),

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2022 the original author or authors. * Copyright 2012-2023 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.
@ -88,40 +88,59 @@ public class ConfigurationPropertiesPlugin implements Plugin<Project> {
private void configureConfigurationPropertiesAnnotationProcessor(Project project) { private void configureConfigurationPropertiesAnnotationProcessor(Project project) {
Configuration annotationProcessors = project.getConfigurations() Configuration annotationProcessors = project.getConfigurations()
.getByName(JavaPlugin.ANNOTATION_PROCESSOR_CONFIGURATION_NAME); .getByName(JavaPlugin.ANNOTATION_PROCESSOR_CONFIGURATION_NAME);
annotationProcessors.getDependencies().add(project.getDependencies().project(Collections.singletonMap("path", annotationProcessors.getDependencies()
.add(project.getDependencies()
.project(Collections.singletonMap("path",
":spring-boot-project:spring-boot-tools:spring-boot-configuration-processor"))); ":spring-boot-project:spring-boot-tools:spring-boot-configuration-processor")));
project.getPlugins().apply(ProcessedAnnotationsPlugin.class); project.getPlugins().apply(ProcessedAnnotationsPlugin.class);
} }
private void disableIncrementalCompilation(Project project) { private void disableIncrementalCompilation(Project project) {
SourceSet mainSourceSet = project.getExtensions().getByType(JavaPluginExtension.class).getSourceSets() SourceSet mainSourceSet = project.getExtensions()
.getByType(JavaPluginExtension.class)
.getSourceSets()
.getByName(SourceSet.MAIN_SOURCE_SET_NAME); .getByName(SourceSet.MAIN_SOURCE_SET_NAME);
project.getTasks().named(mainSourceSet.getCompileJavaTaskName(), JavaCompile.class) project.getTasks()
.named(mainSourceSet.getCompileJavaTaskName(), JavaCompile.class)
.configure((compileJava) -> compileJava.getOptions().setIncremental(false)); .configure((compileJava) -> compileJava.getOptions().setIncremental(false));
} }
private void addMetadataArtifact(Project project) { private void addMetadataArtifact(Project project) {
SourceSet mainSourceSet = project.getExtensions().getByType(JavaPluginExtension.class).getSourceSets() SourceSet mainSourceSet = project.getExtensions()
.getByType(JavaPluginExtension.class)
.getSourceSets()
.getByName(SourceSet.MAIN_SOURCE_SET_NAME); .getByName(SourceSet.MAIN_SOURCE_SET_NAME);
project.getConfigurations().maybeCreate(CONFIGURATION_PROPERTIES_METADATA_CONFIGURATION_NAME); project.getConfigurations().maybeCreate(CONFIGURATION_PROPERTIES_METADATA_CONFIGURATION_NAME);
project.afterEvaluate((evaluatedProject) -> evaluatedProject.getArtifacts().add( project.afterEvaluate((evaluatedProject) -> evaluatedProject.getArtifacts()
CONFIGURATION_PROPERTIES_METADATA_CONFIGURATION_NAME, .add(CONFIGURATION_PROPERTIES_METADATA_CONFIGURATION_NAME,
mainSourceSet.getJava().getDestinationDirectory().dir("META-INF/spring-configuration-metadata.json"), mainSourceSet.getJava()
.getDestinationDirectory()
.dir("META-INF/spring-configuration-metadata.json"),
(artifact) -> artifact (artifact) -> artifact
.builtBy(evaluatedProject.getTasks().getByName(mainSourceSet.getClassesTaskName())))); .builtBy(evaluatedProject.getTasks().getByName(mainSourceSet.getClassesTaskName()))));
} }
private void configureAdditionalMetadataLocationsCompilerArgument(Project project) { private void configureAdditionalMetadataLocationsCompilerArgument(Project project) {
JavaCompile compileJava = project.getTasks().withType(JavaCompile.class) JavaCompile compileJava = project.getTasks()
.withType(JavaCompile.class)
.getByName(JavaPlugin.COMPILE_JAVA_TASK_NAME); .getByName(JavaPlugin.COMPILE_JAVA_TASK_NAME);
((Task) compileJava).getInputs().files(project.getTasks().getByName(JavaPlugin.PROCESS_RESOURCES_TASK_NAME)) ((Task) compileJava).getInputs()
.withPathSensitivity(PathSensitivity.RELATIVE).withPropertyName("processed resources"); .files(project.getTasks().getByName(JavaPlugin.PROCESS_RESOURCES_TASK_NAME))
SourceSet mainSourceSet = project.getExtensions().getByType(JavaPluginExtension.class).getSourceSets() .withPathSensitivity(PathSensitivity.RELATIVE)
.withPropertyName("processed resources");
SourceSet mainSourceSet = project.getExtensions()
.getByType(JavaPluginExtension.class)
.getSourceSets()
.getByName(SourceSet.MAIN_SOURCE_SET_NAME); .getByName(SourceSet.MAIN_SOURCE_SET_NAME);
compileJava.getOptions().getCompilerArgs() compileJava.getOptions()
.add("-Aorg.springframework.boot.configurationprocessor.additionalMetadataLocations=" + StringUtils .getCompilerArgs()
.collectionToCommaDelimitedString(mainSourceSet.getResources().getSourceDirectories().getFiles() .add("-Aorg.springframework.boot.configurationprocessor.additionalMetadataLocations="
.stream().map(project.getRootProject()::relativePath).collect(Collectors.toSet()))); + StringUtils.collectionToCommaDelimitedString(mainSourceSet.getResources()
.getSourceDirectories()
.getFiles()
.stream()
.map(project.getRootProject()::relativePath)
.collect(Collectors.toSet())));
} }
private void registerCheckAdditionalMetadataTask(Project project) { private void registerCheckAdditionalMetadataTask(Project project) {
@ -129,14 +148,19 @@ public class ConfigurationPropertiesPlugin implements Plugin<Project> {
.register(CHECK_ADDITIONAL_SPRING_CONFIGURATION_METADATA_TASK_NAME, .register(CHECK_ADDITIONAL_SPRING_CONFIGURATION_METADATA_TASK_NAME,
CheckAdditionalSpringConfigurationMetadata.class); CheckAdditionalSpringConfigurationMetadata.class);
checkConfigurationMetadata.configure((check) -> { checkConfigurationMetadata.configure((check) -> {
SourceSet mainSourceSet = project.getExtensions().getByType(JavaPluginExtension.class).getSourceSets() SourceSet mainSourceSet = project.getExtensions()
.getByType(JavaPluginExtension.class)
.getSourceSets()
.getByName(SourceSet.MAIN_SOURCE_SET_NAME); .getByName(SourceSet.MAIN_SOURCE_SET_NAME);
check.setSource(mainSourceSet.getResources()); check.setSource(mainSourceSet.getResources());
check.include("META-INF/additional-spring-configuration-metadata.json"); check.include("META-INF/additional-spring-configuration-metadata.json");
check.getReportLocation().set(project.getLayout().getBuildDirectory() check.getReportLocation()
.set(project.getLayout()
.getBuildDirectory()
.file("reports/additional-spring-configuration-metadata/check.txt")); .file("reports/additional-spring-configuration-metadata/check.txt"));
}); });
project.getTasks().named(LifecycleBasePlugin.CHECK_TASK_NAME) project.getTasks()
.named(LifecycleBasePlugin.CHECK_TASK_NAME)
.configure((check) -> check.dependsOn(checkConfigurationMetadata)); .configure((check) -> check.dependsOn(checkConfigurationMetadata));
} }
@ -144,17 +168,20 @@ public class ConfigurationPropertiesPlugin implements Plugin<Project> {
TaskProvider<CheckSpringConfigurationMetadata> checkConfigurationMetadata = project.getTasks() TaskProvider<CheckSpringConfigurationMetadata> checkConfigurationMetadata = project.getTasks()
.register(CHECK_SPRING_CONFIGURATION_METADATA_TASK_NAME, CheckSpringConfigurationMetadata.class); .register(CHECK_SPRING_CONFIGURATION_METADATA_TASK_NAME, CheckSpringConfigurationMetadata.class);
checkConfigurationMetadata.configure((check) -> { checkConfigurationMetadata.configure((check) -> {
SourceSet mainSourceSet = project.getExtensions().getByType(JavaPluginExtension.class).getSourceSets() SourceSet mainSourceSet = project.getExtensions()
.getByType(JavaPluginExtension.class)
.getSourceSets()
.getByName(SourceSet.MAIN_SOURCE_SET_NAME); .getByName(SourceSet.MAIN_SOURCE_SET_NAME);
Provider<RegularFile> metadataLocation = project.getTasks() Provider<RegularFile> metadataLocation = project.getTasks()
.named(mainSourceSet.getCompileJavaTaskName(), JavaCompile.class) .named(mainSourceSet.getCompileJavaTaskName(), JavaCompile.class)
.flatMap((javaCompile) -> javaCompile.getDestinationDirectory() .flatMap((javaCompile) -> javaCompile.getDestinationDirectory()
.file("META-INF/spring-configuration-metadata.json")); .file("META-INF/spring-configuration-metadata.json"));
check.getMetadataLocation().set(metadataLocation); check.getMetadataLocation().set(metadataLocation);
check.getReportLocation().set( check.getReportLocation()
project.getLayout().getBuildDirectory().file("reports/spring-configuration-metadata/check.txt")); .set(project.getLayout().getBuildDirectory().file("reports/spring-configuration-metadata/check.txt"));
}); });
project.getTasks().named(LifecycleBasePlugin.CHECK_TASK_NAME) project.getTasks()
.named(LifecycleBasePlugin.CHECK_TASK_NAME)
.configure((check) -> check.dependsOn(checkConfigurationMetadata)); .configure((check) -> check.dependsOn(checkConfigurationMetadata));
} }

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2021 the original author or authors. * Copyright 2012-2023 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.
@ -45,7 +45,8 @@ class SingleRow extends Row {
return null; return null;
} }
if (defaultValue.getClass().isArray()) { if (defaultValue.getClass().isArray()) {
return Arrays.stream((Object[]) defaultValue).map(Object::toString) return Arrays.stream((Object[]) defaultValue)
.map(Object::toString)
.collect(Collectors.joining("," + System.lineSeparator())); .collect(Collectors.joining("," + System.lineSeparator()));
} }
return defaultValue.toString(); return defaultValue.toString();

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2022 the original author or authors. * Copyright 2012-2023 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.
@ -52,8 +52,10 @@ class Snippets {
void writeTo(Path outputDirectory) throws IOException { void writeTo(Path outputDirectory) throws IOException {
createDirectory(outputDirectory); createDirectory(outputDirectory);
Set<String> remaining = this.properties.stream().filter((property) -> !property.isDeprecated()) Set<String> remaining = this.properties.stream()
.map(ConfigurationProperty::getName).collect(Collectors.toSet()); .filter((property) -> !property.isDeprecated())
.map(ConfigurationProperty::getName)
.collect(Collectors.toSet());
for (Snippet snippet : this.snippets) { for (Snippet snippet : this.snippets) {
Set<String> written = writeSnippet(outputDirectory, snippet, remaining); Set<String> written = writeSnippet(outputDirectory, snippet, remaining);
remaining.removeAll(written); remaining.removeAll(written);

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2022 the original author or authors. * Copyright 2012-2023 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.
@ -48,7 +48,8 @@ public class DocumentDevtoolsPropertyDefaults extends DefaultTask {
public DocumentDevtoolsPropertyDefaults() { public DocumentDevtoolsPropertyDefaults() {
this.devtools = getProject().getConfigurations().create("devtools"); this.devtools = getProject().getConfigurations().create("devtools");
this.outputFile = getProject().getObjects().fileProperty(); this.outputFile = getProject().getObjects().fileProperty();
this.outputFile.convention(getProject().getLayout().getBuildDirectory() this.outputFile.convention(getProject().getLayout()
.getBuildDirectory()
.file("docs/generated/using/devtools-property-defaults.adoc")); .file("docs/generated/using/devtools-property-defaults.adoc"));
Map<String, String> dependency = new HashMap<>(); Map<String, String> dependency = new HashMap<>();
dependency.put("path", ":spring-boot-project:spring-boot-devtools"); dependency.put("path", ":spring-boot-project:spring-boot-devtools");

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2022 the original author or authors. * Copyright 2012-2023 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.
@ -57,7 +57,8 @@ public class ApplicationRunner extends DefaultTask {
private final Property<String> expectedLogging = getProject().getObjects().property(String.class); private final Property<String> expectedLogging = getProject().getObjects().property(String.class);
private final Property<String> applicationJar = getProject().getObjects().property(String.class) private final Property<String> applicationJar = getProject().getObjects()
.property(String.class)
.convention("/opt/apps/myapp.jar"); .convention("/opt/apps/myapp.jar");
private final Map<String, String> normalizations = new HashMap<>(); private final Map<String, String> normalizations = new HashMap<>();
@ -118,12 +119,16 @@ public class ApplicationRunner extends DefaultTask {
File executable = Jvm.current().getExecutable("java"); File executable = Jvm.current().getExecutable("java");
command.add(executable.getAbsolutePath()); command.add(executable.getAbsolutePath());
command.add("-cp"); command.add("-cp");
command.add(this.classpath.getFiles().stream().map(File::getAbsolutePath) command.add(this.classpath.getFiles()
.stream()
.map(File::getAbsolutePath)
.collect(Collectors.joining(File.pathSeparator))); .collect(Collectors.joining(File.pathSeparator)));
command.add(this.mainClass.get()); command.add(this.mainClass.get());
command.addAll(this.args.get()); command.addAll(this.args.get());
File outputFile = this.output.getAsFile().get(); File outputFile = this.output.getAsFile().get();
Process process = new ProcessBuilder().redirectOutput(outputFile).redirectError(outputFile).command(command) Process process = new ProcessBuilder().redirectOutput(outputFile)
.redirectError(outputFile)
.command(command)
.start(); .start();
awaitLogging(process); awaitLogging(process);
process.destroy(); process.destroy();

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2022 the original author or authors. * Copyright 2012-2023 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.
@ -108,7 +108,8 @@ public class DocumentPluginGoals extends DefaultTask {
writer.println("== Required parameters"); writer.println("== Required parameters");
writeParametersTable(writer, detailsSectionId, requiredParameters); writeParametersTable(writer, detailsSectionId, requiredParameters);
} }
List<Parameter> optionalParameters = parameters.stream().filter((parameter) -> !parameter.isRequired()) List<Parameter> optionalParameters = parameters.stream()
.filter((parameter) -> !parameter.isRequired())
.toList(); .toList();
if (!optionalParameters.isEmpty()) { if (!optionalParameters.isEmpty()) {
writer.println(); writer.println();

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2022 the original author or authors. * Copyright 2012-2023 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.
@ -51,7 +51,8 @@ public class MavenExec extends JavaExec {
public void setProjectDir(File projectDir) { public void setProjectDir(File projectDir) {
this.projectDir = projectDir; this.projectDir = projectDir;
getInputs().file(new File(projectDir, "pom.xml")).withPathSensitivity(PathSensitivity.RELATIVE) getInputs().file(new File(projectDir, "pom.xml"))
.withPathSensitivity(PathSensitivity.RELATIVE)
.withPropertyName("pom"); .withPropertyName("pom");
} }
@ -88,10 +89,11 @@ public class MavenExec extends JavaExec {
maven.getDependencies().add(project.getDependencies().create("org.apache.maven:maven-embedder:3.6.2")); maven.getDependencies().add(project.getDependencies().create("org.apache.maven:maven-embedder:3.6.2"));
maven.getDependencies().add(project.getDependencies().create("org.apache.maven:maven-compat:3.6.2")); maven.getDependencies().add(project.getDependencies().create("org.apache.maven:maven-compat:3.6.2"));
maven.getDependencies().add(project.getDependencies().create("org.slf4j:slf4j-simple:1.7.5")); maven.getDependencies().add(project.getDependencies().create("org.slf4j:slf4j-simple:1.7.5"));
maven.getDependencies().add( maven.getDependencies()
project.getDependencies().create("org.apache.maven.resolver:maven-resolver-connector-basic:1.4.1")); .add(project.getDependencies()
maven.getDependencies().add( .create("org.apache.maven.resolver:maven-resolver-connector-basic:1.4.1"));
project.getDependencies().create("org.apache.maven.resolver:maven-resolver-transport-http:1.4.1")); maven.getDependencies()
.add(project.getDependencies().create("org.apache.maven.resolver:maven-resolver-transport-http:1.4.1"));
}); });
} }

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2022 the original author or authors. * Copyright 2012-2023 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.
@ -219,8 +219,8 @@ public class MavenPluginPlugin implements Plugin<Project> {
private FormatHelpMojoSource createFormatHelpMojoSource(Project project, MavenExec generateHelpMojoTask, private FormatHelpMojoSource createFormatHelpMojoSource(Project project, MavenExec generateHelpMojoTask,
File generatedHelpMojoDir) { File generatedHelpMojoDir) {
FormatHelpMojoSource formatHelpMojoSource = project.getTasks().create("formatHelpMojoSource", FormatHelpMojoSource formatHelpMojoSource = project.getTasks()
FormatHelpMojoSource.class); .create("formatHelpMojoSource", FormatHelpMojoSource.class);
formatHelpMojoSource.setGenerator(generateHelpMojoTask); formatHelpMojoSource.setGenerator(generateHelpMojoTask);
formatHelpMojoSource.setOutputDir(generatedHelpMojoDir); formatHelpMojoSource.setOutputDir(generatedHelpMojoDir);
return formatHelpMojoSource; return formatHelpMojoSource;
@ -241,8 +241,10 @@ public class MavenPluginPlugin implements Plugin<Project> {
MavenExec generatePluginDescriptor = project.getTasks().create("generatePluginDescriptor", MavenExec.class); MavenExec generatePluginDescriptor = project.getTasks().create("generatePluginDescriptor", MavenExec.class);
generatePluginDescriptor.args("org.apache.maven.plugins:maven-plugin-plugin:3.6.1:descriptor"); generatePluginDescriptor.args("org.apache.maven.plugins:maven-plugin-plugin:3.6.1:descriptor");
generatePluginDescriptor.getOutputs().dir(new File(mavenDir, "target/classes/META-INF/maven")); generatePluginDescriptor.getOutputs().dir(new File(mavenDir, "target/classes/META-INF/maven"));
generatePluginDescriptor.getInputs().dir(new File(mavenDir, "target/classes/org")) generatePluginDescriptor.getInputs()
.withPathSensitivity(PathSensitivity.RELATIVE).withPropertyName("plugin classes"); .dir(new File(mavenDir, "target/classes/org"))
.withPathSensitivity(PathSensitivity.RELATIVE)
.withPropertyName("plugin classes");
generatePluginDescriptor.setProjectDir(mavenDir); generatePluginDescriptor.setProjectDir(mavenDir);
return generatePluginDescriptor; return generatePluginDescriptor;
} }
@ -267,10 +269,13 @@ public class MavenPluginPlugin implements Plugin<Project> {
} }
private void addExtractVersionPropertiesTask(Project project) { private void addExtractVersionPropertiesTask(Project project) {
ExtractVersionProperties extractVersionProperties = project.getTasks().create("extractVersionProperties", ExtractVersionProperties extractVersionProperties = project.getTasks()
ExtractVersionProperties.class); .create("extractVersionProperties", ExtractVersionProperties.class);
extractVersionProperties.setEffectiveBoms(project.getConfigurations().create("versionProperties")); extractVersionProperties.setEffectiveBoms(project.getConfigurations().create("versionProperties"));
extractVersionProperties.getDestination().set(project.getLayout().getBuildDirectory().dir("generated-resources") extractVersionProperties.getDestination()
.set(project.getLayout()
.getBuildDirectory()
.dir("generated-resources")
.map((dir) -> dir.file("extracted-versions.properties"))); .map((dir) -> dir.file("extracted-versions.properties")));
} }
@ -282,7 +287,8 @@ public class MavenPluginPlugin implements Plugin<Project> {
void setGenerator(Task generator) { void setGenerator(Task generator) {
this.generator = generator; this.generator = generator;
getInputs().files(this.generator).withPathSensitivity(PathSensitivity.RELATIVE) getInputs().files(this.generator)
.withPathSensitivity(PathSensitivity.RELATIVE)
.withPropertyName("generated source"); .withPropertyName("generated source");
} }
@ -329,9 +335,10 @@ public class MavenPluginPlugin implements Plugin<Project> {
@Override @Override
public void execute(ComponentMetadataContext context) { public void execute(ComponentMetadataContext context) {
context.getDetails().maybeAddVariant("compileWithMetadata", "compile", context.getDetails()
(variant) -> configureVariant(context, variant)); .maybeAddVariant("compileWithMetadata", "compile", (variant) -> configureVariant(context, variant));
context.getDetails().maybeAddVariant("apiElementsWithMetadata", "apiElements", context.getDetails()
.maybeAddVariant("apiElementsWithMetadata", "apiElements",
(variant) -> configureVariant(context, variant)); (variant) -> configureVariant(context, variant));
} }
@ -374,10 +381,13 @@ public class MavenPluginPlugin implements Plugin<Project> {
public void createRepository() { public void createRepository() {
for (ResolvedArtifactResult result : this.runtimeClasspath.getIncoming().getArtifacts()) { for (ResolvedArtifactResult result : this.runtimeClasspath.getIncoming().getArtifacts()) {
if (result.getId().getComponentIdentifier() instanceof ModuleComponentIdentifier identifier) { if (result.getId().getComponentIdentifier() instanceof ModuleComponentIdentifier identifier) {
String fileName = result.getFile().getName() String fileName = result.getFile()
.getName()
.replace(identifier.getVersion() + "-" + identifier.getVersion(), identifier.getVersion()); .replace(identifier.getVersion() + "-" + identifier.getVersion(), identifier.getVersion());
File repositoryLocation = this.outputDirectory.dir(identifier.getGroup().replace('.', '/') + "/" File repositoryLocation = this.outputDirectory
+ identifier.getModule() + "/" + identifier.getVersion() + "/" + fileName).get() .dir(identifier.getGroup().replace('.', '/') + "/" + identifier.getModule() + "/"
+ identifier.getVersion() + "/" + fileName)
.get()
.getAsFile(); .getAsFile();
repositoryLocation.getParentFile().mkdirs(); repositoryLocation.getParentFile().mkdirs();
try { try {
@ -487,8 +497,8 @@ public class MavenPluginPlugin implements Plugin<Project> {
private String get(String expression) { private String get(String expression) {
try { try {
Node node = (Node) this.xpath.compile("/project/" + expression).evaluate(this.document, Node node = (Node) this.xpath.compile("/project/" + expression)
XPathConstants.NODE); .evaluate(this.document, XPathConstants.NODE);
String text = (node != null) ? node.getTextContent() : null; String text = (node != null) ? node.getTextContent() : null;
Assert.hasLength(text, () -> "No result for expression " + expression); Assert.hasLength(text, () -> "No result for expression " + expression);
return text; return text;

@ -111,9 +111,16 @@ class PluginXmlParser {
} }
private String format(String input) { private String format(String input) {
return input.replace("<code>", "`").replace("</code>", "`").replace("&lt;", "<").replace("&gt;", ">") return input.replace("<code>", "`")
.replace("<br>", " ").replace("\n", " ").replace("&quot;", "\"").replaceAll("\\{@code (.*?)}", "`$1`") .replace("</code>", "`")
.replaceAll("\\{@link (.*?)}", "`$1`").replaceAll("\\{@literal (.*?)}", "`$1`") .replace("&lt;", "<")
.replace("&gt;", ">")
.replace("<br>", " ")
.replace("\n", " ")
.replace("&quot;", "\"")
.replaceAll("\\{@code (.*?)}", "`$1`")
.replaceAll("\\{@link (.*?)}", "`$1`")
.replaceAll("\\{@literal (.*?)}", "`$1`")
.replaceAll("<a href=.\"(.*?)\".>(.*?)</a>", "$1[$2]"); .replaceAll("<a href=.\"(.*?)\".>(.*?)</a>", "$1[$2]");
} }

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2022 the original author or authors. * Copyright 2012-2023 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.
@ -60,10 +60,11 @@ public class PrepareMavenBinaries extends DefaultTask {
@TaskAction @TaskAction
public void prepareBinaries() { public void prepareBinaries() {
for (String version : this.versions) { for (String version : this.versions) {
Configuration configuration = getProject().getConfigurations().detachedConfiguration( Configuration configuration = getProject().getConfigurations()
.detachedConfiguration(
getProject().getDependencies().create("org.apache.maven:apache-maven:" + version + ":bin@zip")); getProject().getDependencies().create("org.apache.maven:apache-maven:" + version + ":bin@zip"));
getProject().copy( getProject()
(copy) -> copy.into(this.outputDir).from(getProject().zipTree(configuration.getSingleFile()))); .copy((copy) -> copy.into(this.outputDir).from(getProject().zipTree(configuration.getSingleFile())));
} }
} }

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2022 the original author or authors. * Copyright 2012-2023 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,12 +44,15 @@ public class OptionalDependenciesPlugin implements Plugin<Project> {
optional.setCanBeConsumed(false); optional.setCanBeConsumed(false);
optional.setCanBeResolved(false); optional.setCanBeResolved(false);
project.getPlugins().withType(JavaPlugin.class, (javaPlugin) -> { project.getPlugins().withType(JavaPlugin.class, (javaPlugin) -> {
SourceSetContainer sourceSets = project.getExtensions().getByType(JavaPluginExtension.class) SourceSetContainer sourceSets = project.getExtensions()
.getByType(JavaPluginExtension.class)
.getSourceSets(); .getSourceSets();
sourceSets.all((sourceSet) -> { sourceSets.all((sourceSet) -> {
project.getConfigurations().getByName(sourceSet.getCompileClasspathConfigurationName()) project.getConfigurations()
.getByName(sourceSet.getCompileClasspathConfigurationName())
.extendsFrom(optional); .extendsFrom(optional);
project.getConfigurations().getByName(sourceSet.getRuntimeClasspathConfigurationName()) project.getConfigurations()
.getByName(sourceSet.getRuntimeClasspathConfigurationName())
.extendsFrom(optional); .extendsFrom(optional);
}); });
}); });

@ -1,5 +1,5 @@
/* /*
* Copyright 2022-2022 the original author or authors. * Copyright 2022-2023 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.
@ -31,8 +31,9 @@ public class ProcessedAnnotationsPlugin implements Plugin<Project> {
@Override @Override
public void apply(Project project) { public void apply(Project project) {
project.getPlugins().apply(AptEclipsePlugin.class); project.getPlugins().apply(AptEclipsePlugin.class);
project.getExtensions().getByType(EclipseModel.class).synchronizationTasks("eclipseJdtApt", "eclipseJdt", project.getExtensions()
"eclipseFactorypath"); .getByType(EclipseModel.class)
.synchronizationTasks("eclipseJdtApt", "eclipseJdt", "eclipseFactorypath");
} }
} }

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2021 the original author or authors. * Copyright 2012-2023 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.
@ -84,7 +84,9 @@ public class DocumentStarters extends DefaultTask {
@TaskAction @TaskAction
void documentStarters() { void documentStarters() {
Set<Starter> starters = this.starters.getFiles().stream().map(this::loadStarter) Set<Starter> starters = this.starters.getFiles()
.stream()
.map(this::loadStarter)
.collect(Collectors.toCollection(TreeSet::new)); .collect(Collectors.toCollection(TreeSet::new));
writeTable("application-starters", starters.stream().filter(Starter::isApplication)); writeTable("application-starters", starters.stream().filter(Starter::isApplication));
writeTable("production-starters", starters.stream().filter(Starter::isProduction)); writeTable("production-starters", starters.stream().filter(Starter::isProduction));

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2020 the original author or authors. * Copyright 2012-2023 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.
@ -73,8 +73,13 @@ public class StarterMetadata extends DefaultTask {
Properties properties = CollectionFactory.createSortedProperties(true); Properties properties = CollectionFactory.createSortedProperties(true);
properties.setProperty("name", getProject().getName()); properties.setProperty("name", getProject().getName());
properties.setProperty("description", getProject().getDescription()); properties.setProperty("description", getProject().getDescription());
properties.setProperty("dependencies", String.join(",", this.dependencies.getResolvedConfiguration() properties.setProperty("dependencies",
.getResolvedArtifacts().stream().map(ResolvedArtifact::getName).collect(Collectors.toSet()))); String.join(",",
this.dependencies.getResolvedConfiguration()
.getResolvedArtifacts()
.stream()
.map(ResolvedArtifact::getName)
.collect(Collectors.toSet())));
this.destination.getParentFile().mkdirs(); this.destination.getParentFile().mkdirs();
try (FileWriter writer = new FileWriter(this.destination)) { try (FileWriter writer = new FileWriter(this.destination)) {
properties.store(writer, null); properties.store(writer, null);

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2021 the original author or authors. * Copyright 2012-2023 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.
@ -58,7 +58,8 @@ public class StarterPlugin implements Plugin<Project> {
File destination = new File(project.getBuildDir(), "starter-metadata.properties"); File destination = new File(project.getBuildDir(), "starter-metadata.properties");
starterMetadata.setDestination(destination); starterMetadata.setDestination(destination);
configurations.create("starterMetadata"); configurations.create("starterMetadata");
project.getArtifacts().add("starterMetadata", project.provider(starterMetadata::getDestination), project.getArtifacts()
.add("starterMetadata", project.provider(starterMetadata::getDestination),
(artifact) -> artifact.builtBy(starterMetadata)); (artifact) -> artifact.builtBy(starterMetadata));
createClasspathConflictsCheck(runtimeClasspath, project); createClasspathConflictsCheck(runtimeClasspath, project);
createUnnecessaryExclusionsCheck(runtimeClasspath, project); createUnnecessaryExclusionsCheck(runtimeClasspath, project);
@ -66,16 +67,16 @@ public class StarterPlugin implements Plugin<Project> {
} }
private void createClasspathConflictsCheck(Configuration classpath, Project project) { private void createClasspathConflictsCheck(Configuration classpath, Project project) {
CheckClasspathForConflicts checkClasspathForConflicts = project.getTasks().create( CheckClasspathForConflicts checkClasspathForConflicts = project.getTasks()
"check" + StringUtils.capitalize(classpath.getName() + "ForConflicts"), .create("check" + StringUtils.capitalize(classpath.getName() + "ForConflicts"),
CheckClasspathForConflicts.class); CheckClasspathForConflicts.class);
checkClasspathForConflicts.setClasspath(classpath); checkClasspathForConflicts.setClasspath(classpath);
project.getTasks().getByName(JavaBasePlugin.CHECK_TASK_NAME).dependsOn(checkClasspathForConflicts); project.getTasks().getByName(JavaBasePlugin.CHECK_TASK_NAME).dependsOn(checkClasspathForConflicts);
} }
private void createUnnecessaryExclusionsCheck(Configuration classpath, Project project) { private void createUnnecessaryExclusionsCheck(Configuration classpath, Project project) {
CheckClasspathForUnnecessaryExclusions checkClasspathForUnnecessaryExclusions = project.getTasks().create( CheckClasspathForUnnecessaryExclusions checkClasspathForUnnecessaryExclusions = project.getTasks()
"check" + StringUtils.capitalize(classpath.getName() + "ForUnnecessaryExclusions"), .create("check" + StringUtils.capitalize(classpath.getName() + "ForUnnecessaryExclusions"),
CheckClasspathForUnnecessaryExclusions.class); CheckClasspathForUnnecessaryExclusions.class);
checkClasspathForUnnecessaryExclusions.setClasspath(classpath); checkClasspathForUnnecessaryExclusions.setClasspath(classpath);
project.getTasks().getByName(JavaBasePlugin.CHECK_TASK_NAME).dependsOn(checkClasspathForUnnecessaryExclusions); project.getTasks().getByName(JavaBasePlugin.CHECK_TASK_NAME).dependsOn(checkClasspathForUnnecessaryExclusions);

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2022 the original author or authors. * Copyright 2012-2023 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.
@ -55,8 +55,8 @@ public class IntegrationTestPlugin implements Plugin<Project> {
project.getTasks().getByName(LifecycleBasePlugin.CHECK_TASK_NAME).dependsOn(intTest); project.getTasks().getByName(LifecycleBasePlugin.CHECK_TASK_NAME).dependsOn(intTest);
project.getPlugins().withType(EclipsePlugin.class, (eclipsePlugin) -> { project.getPlugins().withType(EclipsePlugin.class, (eclipsePlugin) -> {
EclipseModel eclipse = project.getExtensions().getByType(EclipseModel.class); EclipseModel eclipse = project.getExtensions().getByType(EclipseModel.class);
eclipse.classpath((classpath) -> classpath.getPlusConfigurations().add( eclipse.classpath((classpath) -> classpath.getPlusConfigurations()
project.getConfigurations().getByName(intTestSourceSet.getRuntimeClasspathConfigurationName()))); .add(project.getConfigurations().getByName(intTestSourceSet.getRuntimeClasspathConfigurationName())));
}); });
} }

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2022 the original author or authors. * Copyright 2012-2023 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.
@ -59,8 +59,9 @@ public class SystemTestPlugin implements Plugin<Project> {
createTestTask(project, systemTestSourceSet); createTestTask(project, systemTestSourceSet);
project.getPlugins().withType(EclipsePlugin.class, (eclipsePlugin) -> { project.getPlugins().withType(EclipsePlugin.class, (eclipsePlugin) -> {
EclipseModel eclipse = project.getExtensions().getByType(EclipseModel.class); EclipseModel eclipse = project.getExtensions().getByType(EclipseModel.class);
eclipse.classpath((classpath) -> classpath.getPlusConfigurations().add( eclipse.classpath((classpath) -> classpath.getPlusConfigurations()
project.getConfigurations().getByName(systemTestSourceSet.getRuntimeClasspathConfigurationName()))); .add(project.getConfigurations()
.getByName(systemTestSourceSet.getRuntimeClasspathConfigurationName())));
}); });
} }

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2022 the original author or authors. * Copyright 2012-2023 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.
@ -67,9 +67,11 @@ public class TestSliceMetadata extends DefaultTask {
public TestSliceMetadata() { public TestSliceMetadata() {
getInputs().dir((Callable<File>) () -> this.sourceSet.getOutput().getResourcesDir()) getInputs().dir((Callable<File>) () -> this.sourceSet.getOutput().getResourcesDir())
.withPathSensitivity(PathSensitivity.RELATIVE).withPropertyName("resources"); .withPathSensitivity(PathSensitivity.RELATIVE)
.withPropertyName("resources");
getInputs().files((Callable<FileCollection>) () -> this.sourceSet.getOutput().getClassesDirs()) getInputs().files((Callable<FileCollection>) () -> this.sourceSet.getOutput().getClassesDirs())
.withPathSensitivity(PathSensitivity.RELATIVE).withPropertyName("classes"); .withPathSensitivity(PathSensitivity.RELATIVE)
.withPropertyName("classes");
} }
public void setSourceSet(SourceSet sourceSet) { public void setSourceSet(SourceSet sourceSet) {
@ -84,8 +86,9 @@ public class TestSliceMetadata extends DefaultTask {
public void setOutputFile(File outputFile) { public void setOutputFile(File outputFile) {
this.outputFile = outputFile; this.outputFile = outputFile;
Configuration testSliceMetadata = getProject().getConfigurations().maybeCreate("testSliceMetadata"); Configuration testSliceMetadata = getProject().getConfigurations().maybeCreate("testSliceMetadata");
getProject().getArtifacts().add(testSliceMetadata.getName(), getProject().getArtifacts()
getProject().provider((Callable<File>) this::getOutputFile), (artifact) -> artifact.builtBy(this)); .add(testSliceMetadata.getName(), getProject().provider((Callable<File>) this::getOutputFile),
(artifact) -> artifact.builtBy(this));
} }
@TaskAction @TaskAction
@ -100,7 +103,8 @@ public class TestSliceMetadata extends DefaultTask {
private Properties readTestSlices() throws IOException { private Properties readTestSlices() throws IOException {
Properties testSlices = CollectionFactory.createSortedProperties(true); Properties testSlices = CollectionFactory.createSortedProperties(true);
try (URLClassLoader classLoader = new URLClassLoader( try (URLClassLoader classLoader = new URLClassLoader(
StreamSupport.stream(this.sourceSet.getRuntimeClasspath().spliterator(), false).map(this::toURL) StreamSupport.stream(this.sourceSet.getRuntimeClasspath().spliterator(), false)
.map(this::toURL)
.toArray(URL[]::new))) { .toArray(URL[]::new))) {
MetadataReaderFactory metadataReaderFactory = new SimpleMetadataReaderFactory(classLoader); MetadataReaderFactory metadataReaderFactory = new SimpleMetadataReaderFactory(classLoader);
Properties springFactories = readSpringFactories( Properties springFactories = readSpringFactories(
@ -129,8 +133,8 @@ public class TestSliceMetadata extends DefaultTask {
for (File file : files) { for (File file : files) {
try { try {
List<String> lines = removeComments(Files.readAllLines(file.toPath())); List<String> lines = removeComments(Files.readAllLines(file.toPath()));
String fileNameWithoutExtension = file.getName().substring(0, String fileNameWithoutExtension = file.getName()
file.getName().length() - ".imports".length()); .substring(0, file.getName().length() - ".imports".length());
springFactories.setProperty(fileNameWithoutExtension, springFactories.setProperty(fileNameWithoutExtension,
StringUtils.collectionToCommaDelimitedString(lines)); StringUtils.collectionToCommaDelimitedString(lines));
} }
@ -204,13 +208,14 @@ public class TestSliceMetadata extends DefaultTask {
if (annotationMetadata.isAnnotated("org.springframework.boot.autoconfigure.ImportAutoConfiguration")) { if (annotationMetadata.isAnnotated("org.springframework.boot.autoconfigure.ImportAutoConfiguration")) {
importers = Stream.concat(importers, Stream.of(annotationMetadata.getClassName())); importers = Stream.concat(importers, Stream.of(annotationMetadata.getClassName()));
} }
return importers.flatMap( return importers
(importer) -> StringUtils.commaDelimitedListToSet(springFactories.getProperty(importer)).stream()) .flatMap((importer) -> StringUtils.commaDelimitedListToSet(springFactories.getProperty(importer)).stream())
.collect(Collectors.toCollection(TreeSet::new)); .collect(Collectors.toCollection(TreeSet::new));
} }
private Stream<String> findMetaImporters(AnnotationMetadata annotationMetadata) { private Stream<String> findMetaImporters(AnnotationMetadata annotationMetadata) {
return annotationMetadata.getAnnotationTypes().stream() return annotationMetadata.getAnnotationTypes()
.stream()
.filter((annotationType) -> isAutoConfigurationImporter(annotationType, annotationMetadata)); .filter((annotationType) -> isAutoConfigurationImporter(annotationType, annotationMetadata));
} }

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2021 the original author or authors. * Copyright 2012-2023 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.
@ -36,10 +36,12 @@ public class TestFailuresPlugin implements Plugin<Project> {
@Override @Override
public void apply(Project project) { public void apply(Project project) {
Provider<TestResultsOverview> testResultsOverview = project.getGradle().getSharedServices() Provider<TestResultsOverview> testResultsOverview = project.getGradle()
.getSharedServices()
.registerIfAbsent("testResultsOverview", TestResultsOverview.class, (spec) -> { .registerIfAbsent("testResultsOverview", TestResultsOverview.class, (spec) -> {
}); });
project.getTasks().withType(Test.class, project.getTasks()
.withType(Test.class,
(test) -> test.addTestListener(new FailureRecordingTestListener(testResultsOverview, test))); (test) -> test.addTestListener(new FailureRecordingTestListener(testResultsOverview, test)));
} }

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2022 the original author or authors. * Copyright 2012-2023 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.
@ -52,7 +52,8 @@ public class ToolchainPlugin implements Plugin<Project> {
disableToolchainTasks(project); disableToolchainTasks(project);
} }
else { else {
JavaToolchainSpec toolchainSpec = project.getExtensions().getByType(JavaPluginExtension.class) JavaToolchainSpec toolchainSpec = project.getExtensions()
.getByType(JavaPluginExtension.class)
.getToolchain(); .getToolchain();
toolchainSpec.getLanguageVersion().set(toolchain.getJavaVersion()); toolchainSpec.getLanguageVersion().set(toolchain.getJavaVersion());
configureTestToolchain(project, toolchain); configureTestToolchain(project, toolchain);
@ -60,7 +61,8 @@ public class ToolchainPlugin implements Plugin<Project> {
} }
private boolean isJavaVersionSupported(ToolchainExtension toolchain, JavaLanguageVersion toolchainVersion) { private boolean isJavaVersionSupported(ToolchainExtension toolchain, JavaLanguageVersion toolchainVersion) {
return toolchain.getMaximumCompatibleJavaVersion().map((version) -> version.canCompileOrRun(toolchainVersion)) return toolchain.getMaximumCompatibleJavaVersion()
.map((version) -> version.canCompileOrRun(toolchainVersion))
.getOrElse(true); .getOrElse(true);
} }

@ -186,7 +186,8 @@ class ConventionsPluginTests {
out.println("}"); out.println("}");
} }
assertThat(runGradle(Collections.singletonMap("CI", "true"), "retryConfig", "--stacktrace").getOutput()) assertThat(runGradle(Collections.singletonMap("CI", "true"), "retryConfig", "--stacktrace").getOutput())
.contains("maxRetries: 3").contains("failOnPassedAfterRetry: true"); .contains("maxRetries: 3")
.contains("failOnPassedAfterRetry: true");
} }
@Test @Test
@ -207,7 +208,8 @@ class ConventionsPluginTests {
out.println("}"); out.println("}");
} }
assertThat(runGradle(Collections.singletonMap("CI", "local"), "retryConfig", "--stacktrace").getOutput()) assertThat(runGradle(Collections.singletonMap("CI", "local"), "retryConfig", "--stacktrace").getOutput())
.contains("maxRetries: 0").contains("failOnPassedAfterRetry: true"); .contains("maxRetries: 0")
.contains("failOnPassedAfterRetry: true");
} }
private BuildResult runGradle(String... args) { private BuildResult runGradle(String... args) {
@ -215,8 +217,12 @@ class ConventionsPluginTests {
} }
private BuildResult runGradle(Map<String, String> environment, String... args) { private BuildResult runGradle(Map<String, String> environment, String... args) {
return GradleRunner.create().withProjectDir(this.projectDir).withEnvironment(environment).withArguments(args) return GradleRunner.create()
.withPluginClasspath().build(); .withProjectDir(this.projectDir)
.withEnvironment(environment)
.withArguments(args)
.withPluginClasspath()
.build();
} }
} }

@ -48,7 +48,8 @@ class PackageTangleCheckTests {
assertThatExceptionOfType(GradleException.class).isThrownBy(packageTangleCheck::checkForPackageTangles); assertThatExceptionOfType(GradleException.class).isThrownBy(packageTangleCheck::checkForPackageTangles);
assertThat( assertThat(
new File(packageTangleCheck.getProject().getBuildDir(), "checkForPackageTangles/failure-report.txt") new File(packageTangleCheck.getProject().getBuildDir(), "checkForPackageTangles/failure-report.txt")
.length()).isGreaterThan(0); .length())
.isGreaterThan(0);
}); });
} }
@ -58,7 +59,8 @@ class PackageTangleCheckTests {
packageTangleCheck.checkForPackageTangles(); packageTangleCheck.checkForPackageTangles();
assertThat( assertThat(
new File(packageTangleCheck.getProject().getBuildDir(), "checkForPackageTangles/failure-report.txt") new File(packageTangleCheck.getProject().getBuildDir(), "checkForPackageTangles/failure-report.txt")
.length()).isEqualTo(0); .length())
.isEqualTo(0);
}); });
} }
@ -67,8 +69,9 @@ class PackageTangleCheckTests {
projectDir.mkdirs(); projectDir.mkdirs();
copyClasses(classes, projectDir); copyClasses(classes, projectDir);
Project project = ProjectBuilder.builder().withProjectDir(projectDir).build(); Project project = ProjectBuilder.builder().withProjectDir(projectDir).build();
PackageTangleCheck packageTangleCheck = project.getTasks().create("checkForPackageTangles", PackageTangleCheck packageTangleCheck = project.getTasks()
PackageTangleCheck.class, (task) -> task.setClasses(project.files("classes"))); .create("checkForPackageTangles", PackageTangleCheck.class,
(task) -> task.setClasses(project.files("classes")));
callback.accept(packageTangleCheck); callback.accept(packageTangleCheck);
} }

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2021 the original author or authors. * Copyright 2012-2023 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.

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2022 the original author or authors. * Copyright 2012-2023 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.
@ -319,8 +319,12 @@ class BomPluginIntegrationTests {
// } // }
private BuildResult runGradle(String... args) { private BuildResult runGradle(String... args) {
return GradleRunner.create().withDebug(true).withProjectDir(this.projectDir).withArguments(args) return GradleRunner.create()
.withPluginClasspath().build(); .withDebug(true)
.withProjectDir(this.projectDir)
.withArguments(args)
.withPluginClasspath()
.build();
} }
private void generatePom(Consumer<NodeAssert> consumer) { private void generatePom(Consumer<NodeAssert> consumer) {

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2021 the original author or authors. * Copyright 2012-2023 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.

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2022 the original author or authors. * Copyright 2012-2023 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.
@ -50,7 +50,8 @@ class PluginXmlParserTests {
@Test @Test
void parseNonExistingFileThrowException() { void parseNonExistingFileThrowException() {
assertThatThrownBy(() -> this.parser.parse(new File("src/test/resources/nonexistent.xml"))) assertThatThrownBy(() -> this.parser.parse(new File("src/test/resources/nonexistent.xml")))
.isInstanceOf(RuntimeException.class).hasCauseInstanceOf(FileNotFoundException.class); .isInstanceOf(RuntimeException.class)
.hasCauseInstanceOf(FileNotFoundException.class);
} }
} }

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2022 the original author or authors. * Copyright 2012-2023 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.
@ -50,8 +50,12 @@ class TestFailuresPluginIntegrationTests {
@Test @Test
void singleProject() { void singleProject() {
createProject(this.projectDir); createProject(this.projectDir);
BuildResult result = GradleRunner.create().withDebug(true).withProjectDir(this.projectDir) BuildResult result = GradleRunner.create()
.withArguments("build").withPluginClasspath().buildAndFail(); .withDebug(true)
.withProjectDir(this.projectDir)
.withArguments("build")
.withPluginClasspath()
.buildAndFail();
assertThat(readLines(result.getOutput())).containsSequence("Found test failures in 1 test task:", "", ":test", assertThat(readLines(result.getOutput())).containsSequence("Found test failures in 1 test task:", "", ":test",
" example.ExampleTests > bad()", " example.ExampleTests > fail()", " example.ExampleTests > bad()", " example.ExampleTests > fail()",
" example.MoreTests > bad()", " example.MoreTests > fail()", ""); " example.MoreTests > bad()", " example.MoreTests > fail()", "");
@ -60,8 +64,12 @@ class TestFailuresPluginIntegrationTests {
@Test @Test
void multiProject() { void multiProject() {
createMultiProjectBuild(); createMultiProjectBuild();
BuildResult result = GradleRunner.create().withDebug(true).withProjectDir(this.projectDir) BuildResult result = GradleRunner.create()
.withArguments("build").withPluginClasspath().buildAndFail(); .withDebug(true)
.withProjectDir(this.projectDir)
.withArguments("build")
.withPluginClasspath()
.buildAndFail();
assertThat(readLines(result.getOutput())).containsSequence("Found test failures in 1 test task:", "", assertThat(readLines(result.getOutput())).containsSequence("Found test failures in 1 test task:", "",
":project-one:test", " example.ExampleTests > bad()", " example.ExampleTests > fail()", ":project-one:test", " example.ExampleTests > bad()", " example.ExampleTests > fail()",
" example.MoreTests > bad()", " example.MoreTests > fail()", ""); " example.MoreTests > bad()", " example.MoreTests > fail()", "");
@ -70,8 +78,12 @@ class TestFailuresPluginIntegrationTests {
@Test @Test
void multiProjectContinue() { void multiProjectContinue() {
createMultiProjectBuild(); createMultiProjectBuild();
BuildResult result = GradleRunner.create().withDebug(true).withProjectDir(this.projectDir) BuildResult result = GradleRunner.create()
.withArguments("build", "--continue").withPluginClasspath().buildAndFail(); .withDebug(true)
.withProjectDir(this.projectDir)
.withArguments("build", "--continue")
.withPluginClasspath()
.buildAndFail();
assertThat(readLines(result.getOutput())).containsSequence("Found test failures in 2 test tasks:", "", assertThat(readLines(result.getOutput())).containsSequence("Found test failures in 2 test tasks:", "",
":project-one:test", " example.ExampleTests > bad()", " example.ExampleTests > fail()", ":project-one:test", " example.ExampleTests > bad()", " example.ExampleTests > fail()",
" example.MoreTests > bad()", " example.MoreTests > fail()", "", ":project-two:test", " example.MoreTests > bad()", " example.MoreTests > fail()", "", ":project-two:test",
@ -82,8 +94,12 @@ class TestFailuresPluginIntegrationTests {
@Test @Test
void multiProjectParallel() { void multiProjectParallel() {
createMultiProjectBuild(); createMultiProjectBuild();
BuildResult result = GradleRunner.create().withDebug(true).withProjectDir(this.projectDir) BuildResult result = GradleRunner.create()
.withArguments("build", "--parallel", "--stacktrace").withPluginClasspath().buildAndFail(); .withDebug(true)
.withProjectDir(this.projectDir)
.withArguments("build", "--parallel", "--stacktrace")
.withPluginClasspath()
.buildAndFail();
assertThat(readLines(result.getOutput())).containsSequence("Found test failures in 2 test tasks:", "", assertThat(readLines(result.getOutput())).containsSequence("Found test failures in 2 test tasks:", "",
":project-one:test", " example.ExampleTests > bad()", " example.ExampleTests > fail()", ":project-one:test", " example.ExampleTests > bad()", " example.ExampleTests > fail()",
" example.MoreTests > bad()", " example.MoreTests > fail()", "", ":project-two:test", " example.MoreTests > bad()", " example.MoreTests > fail()", "", ":project-two:test",

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2022 the original author or authors. * Copyright 2012-2023 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.

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2022 the original author or authors. * Copyright 2012-2023 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.
@ -73,8 +73,11 @@ public class CloudFoundryWebEndpointDiscoverer extends WebEndpointDiscoverer {
} }
private boolean isHealthEndpointExtension(Class<?> extensionBeanType) { private boolean isHealthEndpointExtension(Class<?> extensionBeanType) {
return MergedAnnotations.from(extensionBeanType).get(EndpointWebExtension.class) return MergedAnnotations.from(extensionBeanType)
.getValue("endpoint", Class.class).map(HealthEndpoint.class::isAssignableFrom).orElse(false); .get(EndpointWebExtension.class)
.getValue("endpoint", Class.class)
.map(HealthEndpoint.class::isAssignableFrom)
.orElse(false);
} }
private boolean isCloudFoundryHealthEndpointExtension(Class<?> extensionBeanType) { private boolean isCloudFoundryHealthEndpointExtension(Class<?> extensionBeanType) {
@ -85,8 +88,8 @@ public class CloudFoundryWebEndpointDiscoverer extends WebEndpointDiscoverer {
@Override @Override
public void registerHints(RuntimeHints hints, ClassLoader classLoader) { public void registerHints(RuntimeHints hints, ClassLoader classLoader) {
hints.reflection().registerType(CloudFoundryEndpointFilter.class, hints.reflection()
MemberCategory.INVOKE_DECLARED_CONSTRUCTORS); .registerType(CloudFoundryEndpointFilter.class, MemberCategory.INVOKE_DECLARED_CONSTRUCTORS);
} }
} }

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2022 the original author or authors. * Copyright 2012-2023 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.

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2022 the original author or authors. * Copyright 2012-2023 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.
@ -99,8 +99,7 @@ class CloudFoundryWebFluxEndpointHandlerMapping extends AbstractWebFluxEndpointH
Map<String, Link> links = CloudFoundryWebFluxEndpointHandlerMapping.this.linksResolver Map<String, Link> links = CloudFoundryWebFluxEndpointHandlerMapping.this.linksResolver
.resolveLinks(request.getURI().toString()); .resolveLinks(request.getURI().toString());
return new ResponseEntity<>( return new ResponseEntity<>(
Collections.singletonMap("_links", getAccessibleLinks(accessLevel, links)), Collections.singletonMap("_links", getAccessibleLinks(accessLevel, links)), HttpStatus.OK);
HttpStatus.OK);
}); });
} }
@ -108,7 +107,8 @@ class CloudFoundryWebFluxEndpointHandlerMapping extends AbstractWebFluxEndpointH
if (accessLevel == null) { if (accessLevel == null) {
return new LinkedHashMap<>(); return new LinkedHashMap<>();
} }
return links.entrySet().stream() return links.entrySet()
.stream()
.filter((entry) -> entry.getKey().equals("self") || accessLevel.isAccessAllowed(entry.getKey())) .filter((entry) -> entry.getKey().equals("self") || accessLevel.isAccessAllowed(entry.getKey()))
.collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue)); .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue));
} }

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2022 the original author or authors. * Copyright 2012-2023 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.
@ -143,8 +143,8 @@ public class ReactiveCloudFoundryActuatorAutoConfiguration {
CorsConfiguration corsConfiguration = new CorsConfiguration(); CorsConfiguration corsConfiguration = new CorsConfiguration();
corsConfiguration.addAllowedOrigin(CorsConfiguration.ALL); corsConfiguration.addAllowedOrigin(CorsConfiguration.ALL);
corsConfiguration.setAllowedMethods(Arrays.asList(HttpMethod.GET.name(), HttpMethod.POST.name())); corsConfiguration.setAllowedMethods(Arrays.asList(HttpMethod.GET.name(), HttpMethod.POST.name()));
corsConfiguration.setAllowedHeaders( corsConfiguration
Arrays.asList(HttpHeaders.AUTHORIZATION, "X-Cf-App-Instance", HttpHeaders.CONTENT_TYPE)); .setAllowedHeaders(Arrays.asList(HttpHeaders.AUTHORIZATION, "X-Cf-App-Instance", HttpHeaders.CONTENT_TYPE));
return corsConfiguration; return corsConfiguration;
} }

@ -72,8 +72,9 @@ class ReactiveCloudFoundrySecurityService {
} }
private Http11SslContextSpec createSslContextSpec() { private Http11SslContextSpec createSslContextSpec() {
return Http11SslContextSpec.forClient().configure( return Http11SslContextSpec.forClient()
(builder) -> builder.sslProvider(SslProvider.JDK).trustManager(InsecureTrustManagerFactory.INSTANCE)); .configure((builder) -> builder.sslProvider(SslProvider.JDK)
.trustManager(InsecureTrustManagerFactory.INSTANCE));
} }
/** /**
@ -85,8 +86,13 @@ class ReactiveCloudFoundrySecurityService {
*/ */
Mono<AccessLevel> getAccessLevel(String token, String applicationId) throws CloudFoundryAuthorizationException { Mono<AccessLevel> getAccessLevel(String token, String applicationId) throws CloudFoundryAuthorizationException {
String uri = getPermissionsUri(applicationId); String uri = getPermissionsUri(applicationId);
return this.webClient.get().uri(uri).header("Authorization", "bearer " + token).retrieve().bodyToMono(Map.class) return this.webClient.get()
.map(this::getAccessLevel).onErrorMap(this::mapError); .uri(uri)
.header("Authorization", "bearer " + token)
.retrieve()
.bodyToMono(Map.class)
.map(this::getAccessLevel)
.onErrorMap(this::mapError);
} }
private Throwable mapError(Throwable throwable) { private Throwable mapError(Throwable throwable) {
@ -123,8 +129,10 @@ class ReactiveCloudFoundrySecurityService {
private Mono<? extends Map<String, String>> fetchTokenKeys(String url) { private Mono<? extends Map<String, String>> fetchTokenKeys(String url) {
RequestHeadersSpec<?> uri = this.webClient.get().uri(url + "/token_keys"); RequestHeadersSpec<?> uri = this.webClient.get().uri(url + "/token_keys");
return uri.retrieve().bodyToMono(STRING_OBJECT_MAP).map(this::extractTokenKeys).onErrorMap( return uri.retrieve()
((ex) -> new CloudFoundryAuthorizationException(Reason.SERVICE_UNAVAILABLE, ex.getMessage()))); .bodyToMono(STRING_OBJECT_MAP)
.map(this::extractTokenKeys)
.onErrorMap(((ex) -> new CloudFoundryAuthorizationException(Reason.SERVICE_UNAVAILABLE, ex.getMessage())));
} }
private Map<String, String> extractTokenKeys(Map<String, Object> response) { private Map<String, String> extractTokenKeys(Map<String, Object> response) {
@ -141,8 +149,12 @@ class ReactiveCloudFoundrySecurityService {
* @return the UAA url Mono * @return the UAA url Mono
*/ */
Mono<String> getUaaUrl() { Mono<String> getUaaUrl() {
this.uaaUrl = this.webClient.get().uri(this.cloudControllerUrl + "/info").retrieve().bodyToMono(Map.class) this.uaaUrl = this.webClient.get()
.map((response) -> (String) response.get("token_endpoint")).cache() .uri(this.cloudControllerUrl + "/info")
.retrieve()
.bodyToMono(Map.class)
.map((response) -> (String) response.get("token_endpoint"))
.cache()
.onErrorMap((ex) -> new CloudFoundryAuthorizationException(Reason.SERVICE_UNAVAILABLE, .onErrorMap((ex) -> new CloudFoundryAuthorizationException(Reason.SERVICE_UNAVAILABLE,
"Unable to fetch token keys from UAA.")); "Unable to fetch token keys from UAA."));
return this.uaaUrl; return this.uaaUrl;

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2019 the original author or authors. * Copyright 2012-2023 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.
@ -51,8 +51,10 @@ class ReactiveTokenValidator {
} }
Mono<Void> validate(Token token) { Mono<Void> validate(Token token) {
return validateAlgorithm(token).then(validateKeyIdAndSignature(token)).then(validateExpiry(token)) return validateAlgorithm(token).then(validateKeyIdAndSignature(token))
.then(validateIssuer(token)).then(validateAudience(token)); .then(validateExpiry(token))
.then(validateIssuer(token))
.then(validateAudience(token));
} }
private Mono<Void> validateAlgorithm(Token token) { private Mono<Void> validateAlgorithm(Token token) {
@ -81,8 +83,10 @@ class ReactiveTokenValidator {
if (cached != null) { if (cached != null) {
return Mono.just(cached); return Mono.just(cached);
} }
return this.securityService.fetchTokenKeys().doOnSuccess(this::cacheTokenKeys) return this.securityService.fetchTokenKeys()
.filter((tokenKeys) -> tokenKeys.containsKey(keyId)).map((tokenKeys) -> tokenKeys.get(keyId)) .doOnSuccess(this::cacheTokenKeys)
.filter((tokenKeys) -> tokenKeys.containsKey(keyId))
.map((tokenKeys) -> tokenKeys.get(keyId))
.switchIfEmpty(Mono.error(new CloudFoundryAuthorizationException(Reason.INVALID_KEY_ID, .switchIfEmpty(Mono.error(new CloudFoundryAuthorizationException(Reason.INVALID_KEY_ID,
"Key Id present in token header does not match"))); "Key Id present in token header does not match")));
} }
@ -122,10 +126,11 @@ class ReactiveTokenValidator {
} }
private Mono<Void> validateIssuer(Token token) { private Mono<Void> validateIssuer(Token token) {
return this.securityService.getUaaUrl().map((uaaUrl) -> String.format("%s/oauth/token", uaaUrl)) return this.securityService.getUaaUrl()
.map((uaaUrl) -> String.format("%s/oauth/token", uaaUrl))
.filter((issuerUri) -> issuerUri.equals(token.getIssuer())) .filter((issuerUri) -> issuerUri.equals(token.getIssuer()))
.switchIfEmpty(Mono.error( .switchIfEmpty(Mono
new CloudFoundryAuthorizationException(Reason.INVALID_ISSUER, "Token issuer does not match"))) .error(new CloudFoundryAuthorizationException(Reason.INVALID_ISSUER, "Token issuer does not match")))
.then(); .then();
} }

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2022 the original author or authors. * Copyright 2012-2023 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.
@ -147,8 +147,8 @@ public class CloudFoundryActuatorAutoConfiguration {
CorsConfiguration corsConfiguration = new CorsConfiguration(); CorsConfiguration corsConfiguration = new CorsConfiguration();
corsConfiguration.addAllowedOrigin(CorsConfiguration.ALL); corsConfiguration.addAllowedOrigin(CorsConfiguration.ALL);
corsConfiguration.setAllowedMethods(Arrays.asList(HttpMethod.GET.name(), HttpMethod.POST.name())); corsConfiguration.setAllowedMethods(Arrays.asList(HttpMethod.GET.name(), HttpMethod.POST.name()));
corsConfiguration.setAllowedHeaders( corsConfiguration
Arrays.asList(HttpHeaders.AUTHORIZATION, "X-Cf-App-Instance", HttpHeaders.CONTENT_TYPE)); .setAllowedHeaders(Arrays.asList(HttpHeaders.AUTHORIZATION, "X-Cf-App-Instance", HttpHeaders.CONTENT_TYPE));
return corsConfiguration; return corsConfiguration;
} }

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2022 the original author or authors. * Copyright 2012-2023 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.
@ -105,7 +105,8 @@ class CloudFoundryWebEndpointServletHandlerMapping extends AbstractWebMvcEndpoin
} }
Map<String, Link> links = CloudFoundryWebEndpointServletHandlerMapping.this.linksResolver Map<String, Link> links = CloudFoundryWebEndpointServletHandlerMapping.this.linksResolver
.resolveLinks(request.getRequestURL().toString()); .resolveLinks(request.getRequestURL().toString());
filteredLinks = links.entrySet().stream() filteredLinks = links.entrySet()
.stream()
.filter((e) -> e.getKey().equals("self") || accessLevel.isAccessAllowed(e.getKey())) .filter((e) -> e.getKey().equals("self") || accessLevel.isAccessAllowed(e.getKey()))
.collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue)); .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue));
return Collections.singletonMap("_links", filteredLinks); return Collections.singletonMap("_links", filteredLinks);

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2022 the original author or authors. * Copyright 2012-2023 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.
@ -134,8 +134,8 @@ class OnAvailableEndpointCondition extends SpringBootCondition {
} }
Boolean userDefinedDefault = isEnabledByDefault(environment); Boolean userDefinedDefault = isEnabledByDefault(environment);
if (userDefinedDefault != null) { if (userDefinedDefault != null) {
return new ConditionOutcome(userDefinedDefault, message.because( return new ConditionOutcome(userDefinedDefault, message
"no property " + key + " found so using user defined default from " + ENABLED_BY_DEFAULT_KEY)); .because("no property " + key + " found so using user defined default from " + ENABLED_BY_DEFAULT_KEY));
} }
boolean endpointDefault = endpointAnnotation.getBoolean("enableByDefault"); boolean endpointDefault = endpointAnnotation.getBoolean("enableByDefault");
return new ConditionOutcome(endpointDefault, return new ConditionOutcome(endpointDefault,

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2022 the original author or authors. * Copyright 2012-2023 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.
@ -47,7 +47,8 @@ public class JacksonEndpointAutoConfiguration {
ObjectMapper objectMapper = Jackson2ObjectMapperBuilder.json() ObjectMapper objectMapper = Jackson2ObjectMapperBuilder.json()
.featuresToDisable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, .featuresToDisable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS,
SerializationFeature.WRITE_DURATIONS_AS_TIMESTAMPS) SerializationFeature.WRITE_DURATIONS_AS_TIMESTAMPS)
.serializationInclusion(Include.NON_NULL).build(); .serializationInclusion(Include.NON_NULL)
.build();
return () -> objectMapper; return () -> objectMapper;
} }

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2022 the original author or authors. * Copyright 2012-2023 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.

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2022 the original author or authors. * Copyright 2012-2023 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.
@ -101,7 +101,9 @@ class JerseyWebEndpointManagementContextConfiguration {
WebEndpointsSupplier webEndpointsSupplier, HealthEndpointGroups healthEndpointGroups) { WebEndpointsSupplier webEndpointsSupplier, HealthEndpointGroups healthEndpointGroups) {
Collection<ExposableWebEndpoint> webEndpoints = webEndpointsSupplier.getEndpoints(); Collection<ExposableWebEndpoint> webEndpoints = webEndpointsSupplier.getEndpoints();
ExposableWebEndpoint health = webEndpoints.stream() ExposableWebEndpoint health = webEndpoints.stream()
.filter((endpoint) -> endpoint.getEndpointId().equals(HEALTH_ENDPOINT_ID)).findFirst().get(); .filter((endpoint) -> endpoint.getEndpointId().equals(HEALTH_ENDPOINT_ID))
.findFirst()
.get();
return new JerseyAdditionalHealthEndpointPathsManagementResourcesRegistrar(health, healthEndpointGroups); return new JerseyAdditionalHealthEndpointPathsManagementResourcesRegistrar(health, healthEndpointGroups);
} }
@ -196,7 +198,9 @@ class JerseyWebEndpointManagementContextConfiguration {
WebServerNamespace.MANAGEMENT, this.groups); WebServerNamespace.MANAGEMENT, this.groups);
Collection<Resource> endpointResources = resourceFactory Collection<Resource> endpointResources = resourceFactory
.createEndpointResources(mapping, Collections.singletonList(this.endpoint), null, null, false) .createEndpointResources(mapping, Collections.singletonList(this.endpoint), null, null, false)
.stream().filter(Objects::nonNull).toList(); .stream()
.filter(Objects::nonNull)
.toList();
register(endpointResources, config); register(endpointResources, config);
} }

@ -118,7 +118,9 @@ public class WebFluxEndpointManagementContextConfiguration {
WebEndpointsSupplier webEndpointsSupplier, HealthEndpointGroups groups) { WebEndpointsSupplier webEndpointsSupplier, HealthEndpointGroups groups) {
Collection<ExposableWebEndpoint> webEndpoints = webEndpointsSupplier.getEndpoints(); Collection<ExposableWebEndpoint> webEndpoints = webEndpointsSupplier.getEndpoints();
ExposableWebEndpoint health = webEndpoints.stream() ExposableWebEndpoint health = webEndpoints.stream()
.filter((endpoint) -> endpoint.getEndpointId().equals(HealthEndpoint.ID)).findFirst().get(); .filter((endpoint) -> endpoint.getEndpointId().equals(HealthEndpoint.ID))
.findFirst()
.get();
return new AdditionalHealthEndpointPathsWebFluxHandlerMapping(new EndpointMapping(""), health, return new AdditionalHealthEndpointPathsWebFluxHandlerMapping(new EndpointMapping(""), health,
groups.getAllWithAdditionalPath(WebServerNamespace.MANAGEMENT)); groups.getAllWithAdditionalPath(WebServerNamespace.MANAGEMENT));
} }

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2022 the original author or authors. * Copyright 2012-2023 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.
@ -113,7 +113,9 @@ public class WebMvcEndpointManagementContextConfiguration {
WebEndpointsSupplier webEndpointsSupplier, HealthEndpointGroups groups) { WebEndpointsSupplier webEndpointsSupplier, HealthEndpointGroups groups) {
Collection<ExposableWebEndpoint> webEndpoints = webEndpointsSupplier.getEndpoints(); Collection<ExposableWebEndpoint> webEndpoints = webEndpointsSupplier.getEndpoints();
ExposableWebEndpoint health = webEndpoints.stream() ExposableWebEndpoint health = webEndpoints.stream()
.filter((endpoint) -> endpoint.getEndpointId().equals(HealthEndpoint.ID)).findFirst().get(); .filter((endpoint) -> endpoint.getEndpointId().equals(HealthEndpoint.ID))
.findFirst()
.get();
return new AdditionalHealthEndpointPathsWebMvcHandlerMapping(health, return new AdditionalHealthEndpointPathsWebMvcHandlerMapping(health,
groups.getAllWithAdditionalPath(WebServerNamespace.MANAGEMENT)); groups.getAllWithAdditionalPath(WebServerNamespace.MANAGEMENT));
} }

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2022 the original author or authors. * Copyright 2012-2023 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.

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2022 the original author or authors. * Copyright 2012-2023 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,9 @@ class HealthEndpointReactiveWebExtensionConfiguration {
WebEndpointsSupplier webEndpointsSupplier, HealthEndpointGroups groups) { WebEndpointsSupplier webEndpointsSupplier, HealthEndpointGroups groups) {
Collection<ExposableWebEndpoint> webEndpoints = webEndpointsSupplier.getEndpoints(); Collection<ExposableWebEndpoint> webEndpoints = webEndpointsSupplier.getEndpoints();
ExposableWebEndpoint health = webEndpoints.stream() ExposableWebEndpoint health = webEndpoints.stream()
.filter((endpoint) -> endpoint.getEndpointId().equals(HealthEndpoint.ID)).findFirst().get(); .filter((endpoint) -> endpoint.getEndpointId().equals(HealthEndpoint.ID))
.findFirst()
.get();
return new AdditionalHealthEndpointPathsWebFluxHandlerMapping(new EndpointMapping(""), health, return new AdditionalHealthEndpointPathsWebFluxHandlerMapping(new EndpointMapping(""), health,
groups.getAllWithAdditionalPath(WebServerNamespace.SERVER)); groups.getAllWithAdditionalPath(WebServerNamespace.SERVER));
} }

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2022 the original author or authors. * Copyright 2012-2023 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.
@ -78,8 +78,10 @@ class HealthEndpointWebExtensionConfiguration {
private static ExposableWebEndpoint getHealthEndpoint(WebEndpointsSupplier webEndpointsSupplier) { private static ExposableWebEndpoint getHealthEndpoint(WebEndpointsSupplier webEndpointsSupplier) {
Collection<ExposableWebEndpoint> webEndpoints = webEndpointsSupplier.getEndpoints(); Collection<ExposableWebEndpoint> webEndpoints = webEndpointsSupplier.getEndpoints();
return webEndpoints.stream().filter((endpoint) -> endpoint.getEndpointId().equals(HealthEndpoint.ID)) return webEndpoints.stream()
.findFirst().get(); .filter((endpoint) -> endpoint.getEndpointId().equals(HealthEndpoint.ID))
.findFirst()
.get();
} }
@ConditionalOnBean(DispatcherServlet.class) @ConditionalOnBean(DispatcherServlet.class)
@ -161,7 +163,9 @@ class HealthEndpointWebExtensionConfiguration {
WebServerNamespace.SERVER, this.groups); WebServerNamespace.SERVER, this.groups);
Collection<Resource> endpointResources = resourceFactory Collection<Resource> endpointResources = resourceFactory
.createEndpointResources(mapping, Collections.singletonList(this.endpoint), null, null, false) .createEndpointResources(mapping, Collections.singletonList(this.endpoint), null, null, false)
.stream().filter(Objects::nonNull).toList(); .stream()
.filter(Objects::nonNull)
.toList();
register(endpointResources, config); register(endpointResources, config);
} }

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2021 the original author or authors. * Copyright 2012-2023 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.

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2022 the original author or authors. * Copyright 2012-2023 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.
@ -86,7 +86,8 @@ public class DataSourceHealthContributorAutoConfiguration implements Initializin
public HealthContributor dbHealthContributor(Map<String, DataSource> dataSources, public HealthContributor dbHealthContributor(Map<String, DataSource> dataSources,
DataSourceHealthIndicatorProperties dataSourceHealthIndicatorProperties) { DataSourceHealthIndicatorProperties dataSourceHealthIndicatorProperties) {
if (dataSourceHealthIndicatorProperties.isIgnoreRoutingDataSources()) { if (dataSourceHealthIndicatorProperties.isIgnoreRoutingDataSources()) {
Map<String, DataSource> filteredDatasources = dataSources.entrySet().stream() Map<String, DataSource> filteredDatasources = dataSources.entrySet()
.stream()
.filter((e) -> !(e.getValue() instanceof AbstractRoutingDataSource)) .filter((e) -> !(e.getValue() instanceof AbstractRoutingDataSource))
.collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue)); .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue));
return createContributor(filteredDatasources); return createContributor(filteredDatasources);
@ -127,7 +128,9 @@ public class DataSourceHealthContributorAutoConfiguration implements Initializin
RoutingDataSourceHealthContributor(AbstractRoutingDataSource routingDataSource, RoutingDataSourceHealthContributor(AbstractRoutingDataSource routingDataSource,
Function<DataSource, HealthContributor> contributorFunction) { Function<DataSource, HealthContributor> contributorFunction) {
Map<String, DataSource> routedDataSources = routingDataSource.getResolvedDataSources().entrySet().stream() Map<String, DataSource> routedDataSources = routingDataSource.getResolvedDataSources()
.entrySet()
.stream()
.collect(Collectors.toMap((e) -> Objects.toString(e.getKey(), UNNAMED_DATASOURCE_KEY), .collect(Collectors.toMap((e) -> Objects.toString(e.getKey(), UNNAMED_DATASOURCE_KEY),
Map.Entry::getValue)); Map.Entry::getValue));
this.delegate = CompositeHealthContributor.fromMap(routedDataSources, contributorFunction); this.delegate = CompositeHealthContributor.fromMap(routedDataSources, contributorFunction);

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2022 the original author or authors. * Copyright 2012-2023 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.
@ -59,8 +59,8 @@ public class LoggersEndpointAutoConfiguration {
ConditionMessage.Builder message = ConditionMessage.forCondition("Logging System"); ConditionMessage.Builder message = ConditionMessage.forCondition("Logging System");
String loggingSystem = System.getProperty(LoggingSystem.SYSTEM_PROPERTY); String loggingSystem = System.getProperty(LoggingSystem.SYSTEM_PROPERTY);
if (LoggingSystem.NONE.equals(loggingSystem)) { if (LoggingSystem.NONE.equals(loggingSystem)) {
return ConditionOutcome.noMatch( return ConditionOutcome
message.because("system property " + LoggingSystem.SYSTEM_PROPERTY + " is set to none")); .noMatch(message.because("system property " + LoggingSystem.SYSTEM_PROPERTY + " is set to none"));
} }
return ConditionOutcome.match(message.because("enabled")); return ConditionOutcome.match(message.because("enabled"));
} }

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2022 the original author or authors. * Copyright 2012-2023 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.

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2022 the original author or authors. * Copyright 2012-2023 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.

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2022 the original author or authors. * Copyright 2012-2023 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.

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2022 the original author or authors. * Copyright 2012-2023 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.
@ -93,15 +93,20 @@ public class PropertiesMeterFilter implements MeterFilter {
.maximumExpectedValue( .maximumExpectedValue(
convertMeterValue(id.getType(), lookup(distribution.getMaximumExpectedValue(), id, null))) convertMeterValue(id.getType(), lookup(distribution.getMaximumExpectedValue(), id, null)))
.expiry(lookupWithFallbackToAll(distribution.getExpiry(), id, null)) .expiry(lookupWithFallbackToAll(distribution.getExpiry(), id, null))
.bufferLength(lookupWithFallbackToAll(distribution.getBufferLength(), id, null)).build().merge(config); .bufferLength(lookupWithFallbackToAll(distribution.getBufferLength(), id, null))
.build()
.merge(config);
} }
private double[] convertServiceLevelObjectives(Meter.Type meterType, ServiceLevelObjectiveBoundary[] slo) { private double[] convertServiceLevelObjectives(Meter.Type meterType, ServiceLevelObjectiveBoundary[] slo) {
if (slo == null) { if (slo == null) {
return null; return null;
} }
double[] converted = Arrays.stream(slo).map((candidate) -> candidate.getValue(meterType)) double[] converted = Arrays.stream(slo)
.filter(Objects::nonNull).mapToDouble(Double::doubleValue).toArray(); .map((candidate) -> candidate.getValue(meterType))
.filter(Objects::nonNull)
.mapToDouble(Double::doubleValue)
.toArray();
return (converted.length != 0) ? converted : null; return (converted.length != 0) ? converted : null;
} }

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2022 the original author or authors. * Copyright 2012-2023 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.

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2022 the original author or authors. * Copyright 2012-2023 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.

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2022 the original author or authors. * Copyright 2012-2023 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.
@ -64,7 +64,9 @@ public class AppOpticsMetricsExportAutoConfiguration {
@Bean @Bean
@ConditionalOnMissingBean @ConditionalOnMissingBean
public AppOpticsMeterRegistry appOpticsMeterRegistry(AppOpticsConfig config, Clock clock) { public AppOpticsMeterRegistry appOpticsMeterRegistry(AppOpticsConfig config, Clock clock) {
return AppOpticsMeterRegistry.builder(config).clock(clock).httpClient( return AppOpticsMeterRegistry.builder(config)
.clock(clock)
.httpClient(
new HttpUrlConnectionSender(this.properties.getConnectTimeout(), this.properties.getReadTimeout())) new HttpUrlConnectionSender(this.properties.getConnectTimeout(), this.properties.getReadTimeout()))
.build(); .build();
} }

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2022 the original author or authors. * Copyright 2012-2023 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.
@ -64,7 +64,9 @@ public class DatadogMetricsExportAutoConfiguration {
@Bean @Bean
@ConditionalOnMissingBean @ConditionalOnMissingBean
public DatadogMeterRegistry datadogMeterRegistry(DatadogConfig datadogConfig, Clock clock) { public DatadogMeterRegistry datadogMeterRegistry(DatadogConfig datadogConfig, Clock clock) {
return DatadogMeterRegistry.builder(datadogConfig).clock(clock).httpClient( return DatadogMeterRegistry.builder(datadogConfig)
.clock(clock)
.httpClient(
new HttpUrlConnectionSender(this.properties.getConnectTimeout(), this.properties.getReadTimeout())) new HttpUrlConnectionSender(this.properties.getConnectTimeout(), this.properties.getReadTimeout()))
.build(); .build();
} }

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2022 the original author or authors. * Copyright 2012-2023 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.
@ -64,7 +64,9 @@ public class DynatraceMetricsExportAutoConfiguration {
@Bean @Bean
@ConditionalOnMissingBean @ConditionalOnMissingBean
public DynatraceMeterRegistry dynatraceMeterRegistry(DynatraceConfig dynatraceConfig, Clock clock) { public DynatraceMeterRegistry dynatraceMeterRegistry(DynatraceConfig dynatraceConfig, Clock clock) {
return DynatraceMeterRegistry.builder(dynatraceConfig).clock(clock).httpClient( return DynatraceMeterRegistry.builder(dynatraceConfig)
.clock(clock)
.httpClient(
new HttpUrlConnectionSender(this.properties.getConnectTimeout(), this.properties.getReadTimeout())) new HttpUrlConnectionSender(this.properties.getConnectTimeout(), this.properties.getReadTimeout()))
.build(); .build();
} }

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2022 the original author or authors. * Copyright 2012-2023 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.
@ -73,7 +73,9 @@ public class ElasticMetricsExportAutoConfiguration {
@Bean @Bean
@ConditionalOnMissingBean @ConditionalOnMissingBean
public ElasticMeterRegistry elasticMeterRegistry(ElasticConfig elasticConfig, Clock clock) { public ElasticMeterRegistry elasticMeterRegistry(ElasticConfig elasticConfig, Clock clock) {
return ElasticMeterRegistry.builder(elasticConfig).clock(clock).httpClient( return ElasticMeterRegistry.builder(elasticConfig)
.clock(clock)
.httpClient(
new HttpUrlConnectionSender(this.properties.getConnectTimeout(), this.properties.getReadTimeout())) new HttpUrlConnectionSender(this.properties.getConnectTimeout(), this.properties.getReadTimeout()))
.build(); .build();
} }

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2022 the original author or authors. * Copyright 2012-2023 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.
@ -64,7 +64,9 @@ public class HumioMetricsExportAutoConfiguration {
@Bean @Bean
@ConditionalOnMissingBean @ConditionalOnMissingBean
public HumioMeterRegistry humioMeterRegistry(HumioConfig humioConfig, Clock clock) { public HumioMeterRegistry humioMeterRegistry(HumioConfig humioConfig, Clock clock) {
return HumioMeterRegistry.builder(humioConfig).clock(clock).httpClient( return HumioMeterRegistry.builder(humioConfig)
.clock(clock)
.httpClient(
new HttpUrlConnectionSender(this.properties.getConnectTimeout(), this.properties.getReadTimeout())) new HttpUrlConnectionSender(this.properties.getConnectTimeout(), this.properties.getReadTimeout()))
.build(); .build();

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2022 the original author or authors. * Copyright 2012-2023 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.
@ -64,7 +64,9 @@ public class InfluxMetricsExportAutoConfiguration {
@Bean @Bean
@ConditionalOnMissingBean @ConditionalOnMissingBean
public InfluxMeterRegistry influxMeterRegistry(InfluxConfig influxConfig, Clock clock) { public InfluxMeterRegistry influxMeterRegistry(InfluxConfig influxConfig, Clock clock) {
return InfluxMeterRegistry.builder(influxConfig).clock(clock).httpClient( return InfluxMeterRegistry.builder(influxConfig)
.clock(clock)
.httpClient(
new HttpUrlConnectionSender(this.properties.getConnectTimeout(), this.properties.getReadTimeout())) new HttpUrlConnectionSender(this.properties.getConnectTimeout(), this.properties.getReadTimeout()))
.build(); .build();

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2022 the original author or authors. * Copyright 2012-2023 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.
@ -64,7 +64,9 @@ public class KairosMetricsExportAutoConfiguration {
@Bean @Bean
@ConditionalOnMissingBean @ConditionalOnMissingBean
public KairosMeterRegistry kairosMeterRegistry(KairosConfig kairosConfig, Clock clock) { public KairosMeterRegistry kairosMeterRegistry(KairosConfig kairosConfig, Clock clock) {
return KairosMeterRegistry.builder(kairosConfig).clock(clock).httpClient( return KairosMeterRegistry.builder(kairosConfig)
.clock(clock)
.httpClient(
new HttpUrlConnectionSender(this.properties.getConnectTimeout(), this.properties.getReadTimeout())) new HttpUrlConnectionSender(this.properties.getConnectTimeout(), this.properties.getReadTimeout()))
.build(); .build();

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2022 the original author or authors. * Copyright 2012-2023 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.
@ -81,7 +81,9 @@ public class NewRelicMetricsExportAutoConfiguration {
@ConditionalOnMissingBean @ConditionalOnMissingBean
public NewRelicMeterRegistry newRelicMeterRegistry(NewRelicConfig newRelicConfig, Clock clock, public NewRelicMeterRegistry newRelicMeterRegistry(NewRelicConfig newRelicConfig, Clock clock,
NewRelicClientProvider newRelicClientProvider) { NewRelicClientProvider newRelicClientProvider) {
return NewRelicMeterRegistry.builder(newRelicConfig).clock(clock).clientProvider(newRelicClientProvider) return NewRelicMeterRegistry.builder(newRelicConfig)
.clock(clock)
.clientProvider(newRelicClientProvider)
.build(); .build();
} }

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2022 the original author or authors. * Copyright 2012-2023 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.

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2022 the original author or authors. * Copyright 2012-2023 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.

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2022 the original author or authors. * Copyright 2012-2023 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.
@ -78,7 +78,8 @@ public class HibernateMetricsAutoConfiguration implements SmartInitializingSingl
String entityManagerFactoryName = getEntityManagerFactoryName(beanName); String entityManagerFactoryName = getEntityManagerFactoryName(beanName);
try { try {
new HibernateMetrics(entityManagerFactory.unwrap(SessionFactory.class), entityManagerFactoryName, new HibernateMetrics(entityManagerFactory.unwrap(SessionFactory.class), entityManagerFactoryName,
Collections.emptyList()).bindTo(registry); Collections.emptyList())
.bindTo(registry);
} }
catch (PersistenceException ex) { catch (PersistenceException ex) {
// Continue // Continue

@ -93,7 +93,8 @@ class ObservationRegistryConfigurer {
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
private void customize(ObservationRegistry registry) { private void customize(ObservationRegistry registry) {
LambdaSafe.callbacks(ObservationRegistryCustomizer.class, asOrderedList(this.customizers), registry) LambdaSafe.callbacks(ObservationRegistryCustomizer.class, asOrderedList(this.customizers), registry)
.withLogger(ObservationRegistryConfigurer.class).invoke((customizer) -> customizer.customize(registry)); .withLogger(ObservationRegistryConfigurer.class)
.invoke((customizer) -> customizer.customize(registry));
} }
private <T> List<T> asOrderedList(ObjectProvider<T> provider) { private <T> List<T> asOrderedList(ObjectProvider<T> provider) {

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2022 the original author or authors. * Copyright 2012-2023 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.

@ -246,7 +246,9 @@ public final class EndpointRequest {
} }
private String toString(List<Object> endpoints, String emptyValue) { private String toString(List<Object> endpoints, String emptyValue) {
return (!endpoints.isEmpty()) ? endpoints.stream().map(this::getEndpointId).map(Object::toString) return (!endpoints.isEmpty()) ? endpoints.stream()
.map(this::getEndpointId)
.map(Object::toString)
.collect(Collectors.joining(", ", "[", "]")) : emptyValue; .collect(Collectors.joining(", ", "[", "]")) : emptyValue;
} }

@ -250,7 +250,8 @@ public final class EndpointRequest {
private List<RequestMatcher> getDelegateMatchers(RequestMatcherFactory requestMatcherFactory, private List<RequestMatcher> getDelegateMatchers(RequestMatcherFactory requestMatcherFactory,
RequestMatcherProvider matcherProvider, Set<String> paths) { RequestMatcherProvider matcherProvider, Set<String> paths) {
return paths.stream().map((path) -> requestMatcherFactory.antPath(matcherProvider, path, "/**")) return paths.stream()
.map((path) -> requestMatcherFactory.antPath(matcherProvider, path, "/**"))
.collect(Collectors.toCollection(ArrayList::new)); .collect(Collectors.toCollection(ArrayList::new));
} }
@ -261,7 +262,9 @@ public final class EndpointRequest {
} }
private String toString(List<Object> endpoints, String emptyValue) { private String toString(List<Object> endpoints, String emptyValue) {
return (!endpoints.isEmpty()) ? endpoints.stream().map(this::getEndpointId).map(Object::toString) return (!endpoints.isEmpty()) ? endpoints.stream()
.map(this::getEndpointId)
.map(Object::toString)
.collect(Collectors.joining(", ", "[", "]")) : emptyValue; .collect(Collectors.joining(", ", "[", "]")) : emptyValue;
} }

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2022 the original author or authors. * Copyright 2012-2023 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.
@ -62,8 +62,8 @@ public class StartupEndpointAutoConfiguration {
ConditionMessage.Builder message = ConditionMessage.forCondition("ApplicationStartup"); ConditionMessage.Builder message = ConditionMessage.forCondition("ApplicationStartup");
ApplicationStartup applicationStartup = context.getBeanFactory().getApplicationStartup(); ApplicationStartup applicationStartup = context.getBeanFactory().getApplicationStartup();
if (applicationStartup instanceof BufferingApplicationStartup) { if (applicationStartup instanceof BufferingApplicationStartup) {
return ConditionOutcome.match( return ConditionOutcome
message.because("configured applicationStartup is of type BufferingApplicationStartup.")); .match(message.because("configured applicationStartup is of type BufferingApplicationStartup."));
} }
return ConditionOutcome.noMatch(message.because("configured applicationStartup is of type " return ConditionOutcome.noMatch(message.because("configured applicationStartup is of type "
+ applicationStartup.getClass() + ", expected BufferingApplicationStartup.")); + applicationStartup.getClass() + ", expected BufferingApplicationStartup."));

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2022 the original author or authors. * Copyright 2012-2023 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.
@ -101,8 +101,12 @@ public class BraveAutoConfiguration {
List<TracingCustomizer> tracingCustomizers, CurrentTraceContext currentTraceContext, List<TracingCustomizer> tracingCustomizers, CurrentTraceContext currentTraceContext,
Factory propagationFactory, Sampler sampler) { Factory propagationFactory, Sampler sampler) {
String applicationName = environment.getProperty("spring.application.name", DEFAULT_APPLICATION_NAME); String applicationName = environment.getProperty("spring.application.name", DEFAULT_APPLICATION_NAME);
Builder builder = Tracing.newBuilder().currentTraceContext(currentTraceContext).traceId128Bit(true) Builder builder = Tracing.newBuilder()
.supportsJoin(false).propagationFactory(propagationFactory).sampler(sampler) .currentTraceContext(currentTraceContext)
.traceId128Bit(true)
.supportsJoin(false)
.propagationFactory(propagationFactory)
.sampler(sampler)
.localServiceName(applicationName); .localServiceName(applicationName);
spanHandlers.forEach(builder::addSpanHandler); spanHandlers.forEach(builder::addSpanHandler);
for (TracingCustomizer tracingCustomizer : tracingCustomizers) { for (TracingCustomizer tracingCustomizer : tracingCustomizers) {
@ -234,7 +238,8 @@ public class BraveAutoConfiguration {
List<String> correlationFields = this.tracingProperties.getBaggage().getCorrelation().getFields(); List<String> correlationFields = this.tracingProperties.getBaggage().getCorrelation().getFields();
for (String field : correlationFields) { for (String field : correlationFields) {
builder.add(CorrelationScopeConfig.SingleCorrelationField.newBuilder(BaggageField.create(field)) builder.add(CorrelationScopeConfig.SingleCorrelationField.newBuilder(BaggageField.create(field))
.flushOnUpdate().build()); .flushOnUpdate()
.build());
} }
}; };
} }

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2022 the original author or authors. * Copyright 2012-2023 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.
@ -92,7 +92,9 @@ public class OpenTelemetryAutoConfiguration {
@Bean @Bean
@ConditionalOnMissingBean @ConditionalOnMissingBean
OpenTelemetry openTelemetry(SdkTracerProvider sdkTracerProvider, ContextPropagators contextPropagators) { OpenTelemetry openTelemetry(SdkTracerProvider sdkTracerProvider, ContextPropagators contextPropagators) {
return OpenTelemetrySdk.builder().setTracerProvider(sdkTracerProvider).setPropagators(contextPropagators) return OpenTelemetrySdk.builder()
.setTracerProvider(sdkTracerProvider)
.setPropagators(contextPropagators)
.build(); .build();
} }
@ -101,7 +103,8 @@ public class OpenTelemetryAutoConfiguration {
SdkTracerProvider otelSdkTracerProvider(Environment environment, ObjectProvider<SpanProcessor> spanProcessors, SdkTracerProvider otelSdkTracerProvider(Environment environment, ObjectProvider<SpanProcessor> spanProcessors,
Sampler sampler) { Sampler sampler) {
String applicationName = environment.getProperty("spring.application.name", DEFAULT_APPLICATION_NAME); String applicationName = environment.getProperty("spring.application.name", DEFAULT_APPLICATION_NAME);
SdkTracerProviderBuilder builder = SdkTracerProvider.builder().setSampler(sampler) SdkTracerProviderBuilder builder = SdkTracerProvider.builder()
.setSampler(sampler)
.setResource(Resource.create(Attributes.of(ResourceAttributes.SERVICE_NAME, applicationName))); .setResource(Resource.create(Attributes.of(ResourceAttributes.SERVICE_NAME, applicationName)));
spanProcessors.orderedStream().forEach(builder::addSpanProcessor); spanProcessors.orderedStream().forEach(builder::addSpanProcessor);
return builder.build(); return builder.build();
@ -124,9 +127,11 @@ public class OpenTelemetryAutoConfiguration {
SpanProcessor otelSpanProcessor(ObjectProvider<SpanExporter> spanExporters, SpanProcessor otelSpanProcessor(ObjectProvider<SpanExporter> spanExporters,
ObjectProvider<SpanExportingPredicate> spanExportingPredicates, ObjectProvider<SpanReporter> spanReporters, ObjectProvider<SpanExportingPredicate> spanExportingPredicates, ObjectProvider<SpanReporter> spanReporters,
ObjectProvider<SpanFilter> spanFilters) { ObjectProvider<SpanFilter> spanFilters) {
return BatchSpanProcessor.builder(new CompositeSpanExporter(spanExporters.orderedStream().toList(), return BatchSpanProcessor
.builder(new CompositeSpanExporter(spanExporters.orderedStream().toList(),
spanExportingPredicates.orderedStream().toList(), spanReporters.orderedStream().toList(), spanExportingPredicates.orderedStream().toList(), spanReporters.orderedStream().toList(),
spanFilters.orderedStream().toList())).build(); spanFilters.orderedStream().toList()))
.build();
} }
@Bean @Bean

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2022 the original author or authors. * Copyright 2012-2023 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.
@ -79,7 +79,8 @@ class ZipkinConfigurations {
ZipkinRestTemplateSender restTemplateSender(ZipkinProperties properties, ZipkinRestTemplateSender restTemplateSender(ZipkinProperties properties,
ObjectProvider<ZipkinRestTemplateBuilderCustomizer> customizers) { ObjectProvider<ZipkinRestTemplateBuilderCustomizer> customizers) {
RestTemplateBuilder restTemplateBuilder = new RestTemplateBuilder() RestTemplateBuilder restTemplateBuilder = new RestTemplateBuilder()
.setConnectTimeout(properties.getConnectTimeout()).setReadTimeout(properties.getReadTimeout()); .setConnectTimeout(properties.getConnectTimeout())
.setReadTimeout(properties.getReadTimeout());
restTemplateBuilder = applyCustomizers(restTemplateBuilder, customizers); restTemplateBuilder = applyCustomizers(restTemplateBuilder, customizers);
return new ZipkinRestTemplateSender(properties.getEndpoint(), restTemplateBuilder.build()); return new ZipkinRestTemplateSender(properties.getEndpoint(), restTemplateBuilder.build());
} }

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2022 the original author or authors. * Copyright 2012-2023 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.
@ -74,8 +74,12 @@ class ZipkinWebClientSender extends HttpSender {
} }
private Mono<ResponseEntity<Void>> sendRequest() { private Mono<ResponseEntity<Void>> sendRequest() {
return this.webClient.post().uri(this.endpoint).headers(this::addDefaultHeaders).bodyValue(getBody()) return this.webClient.post()
.retrieve().toBodilessEntity(); .uri(this.endpoint)
.headers(this::addDefaultHeaders)
.bodyValue(getBody())
.retrieve()
.toBodilessEntity();
} }
private void addDefaultHeaders(HttpHeaders headers) { private void addDefaultHeaders(HttpHeaders headers) {

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2022 the original author or authors. * Copyright 2012-2023 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.

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2022 the original author or authors. * Copyright 2012-2023 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.
@ -163,7 +163,8 @@ class ChildManagementContextInitializer
GenerationContext managementGenerationContext = generationContext.withName("Management"); GenerationContext managementGenerationContext = generationContext.withName("Management");
ClassName generatedInitializerClassName = new ApplicationContextAotGenerator() ClassName generatedInitializerClassName = new ApplicationContextAotGenerator()
.processAheadOfTime(this.managementContext, managementGenerationContext); .processAheadOfTime(this.managementContext, managementGenerationContext);
GeneratedMethod postProcessorMethod = beanRegistrationCode.getMethods().add("addManagementInitializer", GeneratedMethod postProcessorMethod = beanRegistrationCode.getMethods()
.add("addManagementInitializer",
(method) -> method.addJavadoc("Use AOT management context initialization") (method) -> method.addJavadoc("Use AOT management context initialization")
.addModifiers(Modifier.PRIVATE, Modifier.STATIC) .addModifiers(Modifier.PRIVATE, Modifier.STATIC)
.addParameter(RegisteredBean.class, "registeredBean") .addParameter(RegisteredBean.class, "registeredBean")

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2022 the original author or authors. * Copyright 2012-2023 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.
@ -55,7 +55,8 @@ class ManagementContextConfigurationImportSelector implements DeferredImportSele
@Override @Override
public String[] selectImports(AnnotationMetadata metadata) { public String[] selectImports(AnnotationMetadata metadata) {
ManagementContextType contextType = (ManagementContextType) metadata ManagementContextType contextType = (ManagementContextType) metadata
.getAnnotationAttributes(EnableManagementContext.class.getName()).get("value"); .getAnnotationAttributes(EnableManagementContext.class.getName())
.get("value");
// Find all management context configuration classes, filtering duplicates // Find all management context configuration classes, filtering duplicates
List<ManagementConfiguration> configurations = getConfigurations(); List<ManagementConfiguration> configurations = getConfigurations();
OrderComparator.sort(configurations); OrderComparator.sort(configurations);

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2022 the original author or authors. * Copyright 2012-2023 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.

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save