mirror of
https://github.com/spring-projects/spring-boot.git
synced 2026-09-17 12:09:16 +00:00
Merge branch '3.5.x' into 4.0.x
This commit is contained in:
@@ -94,6 +94,7 @@ dependencies {
|
||||
mavenRepository(project(path: ":module:spring-boot-devtools", configuration: "mavenRepository"))
|
||||
mavenRepository(project(path: ":core:spring-boot-docker-compose", configuration: "mavenRepository"))
|
||||
mavenRepository(project(path: ":starter:spring-boot-starter-parent", configuration: "mavenRepository"))
|
||||
mavenRepository("org.springframework:spring-test")
|
||||
|
||||
versionProperties(project(path: ":platform:spring-boot-dependencies", configuration: "resolvedBom"))
|
||||
}
|
||||
|
||||
@@ -23,8 +23,11 @@ import org.gradle.api.Plugin;
|
||||
import org.gradle.api.Project;
|
||||
import org.gradle.api.Task;
|
||||
import org.gradle.api.artifacts.Configuration;
|
||||
import org.gradle.api.artifacts.Dependency;
|
||||
import org.gradle.api.artifacts.DependencySet;
|
||||
import org.gradle.api.artifacts.ModuleDependency;
|
||||
import org.gradle.api.artifacts.ProjectDependency;
|
||||
import org.gradle.api.attributes.Category;
|
||||
import org.gradle.api.plugins.JavaLibraryPlugin;
|
||||
import org.gradle.api.plugins.JavaPlatformPlugin;
|
||||
import org.gradle.api.plugins.JavaPlugin;
|
||||
@@ -77,19 +80,20 @@ public class MavenRepositoryPlugin implements Plugin<Project> {
|
||||
DependencySet target = projectRepository.getDependencies();
|
||||
project.getPlugins()
|
||||
.withType(JavaPlugin.class)
|
||||
.all((javaPlugin) -> addMavenRepositoryDependencies(project, JavaPlugin.IMPLEMENTATION_CONFIGURATION_NAME,
|
||||
target));
|
||||
.all((javaPlugin) -> addMavenRepositoryProjectDependencies(project,
|
||||
JavaPlugin.IMPLEMENTATION_CONFIGURATION_NAME, target));
|
||||
project.getPlugins()
|
||||
.withType(JavaLibraryPlugin.class)
|
||||
.all((javaLibraryPlugin) -> addMavenRepositoryDependencies(project, JavaPlugin.API_CONFIGURATION_NAME,
|
||||
target));
|
||||
project.getPlugins()
|
||||
.withType(JavaPlatformPlugin.class)
|
||||
.all((javaPlugin) -> addMavenRepositoryDependencies(project, JavaPlatformPlugin.API_CONFIGURATION_NAME,
|
||||
target));
|
||||
.all((javaLibraryPlugin) -> addMavenRepositoryProjectDependencies(project,
|
||||
JavaPlugin.API_CONFIGURATION_NAME, target));
|
||||
project.getPlugins().withType(JavaPlatformPlugin.class).all((javaPlugin) -> {
|
||||
addMavenRepositoryProjectDependencies(project, JavaPlatformPlugin.API_CONFIGURATION_NAME, target);
|
||||
addMavenRepositoryPlatformDependencies(project, JavaPlatformPlugin.API_CONFIGURATION_NAME, target);
|
||||
});
|
||||
}
|
||||
|
||||
private void addMavenRepositoryDependencies(Project project, String sourceConfigurationName, DependencySet target) {
|
||||
private void addMavenRepositoryProjectDependencies(Project project, String sourceConfigurationName,
|
||||
DependencySet target) {
|
||||
project.getConfigurations()
|
||||
.getByName(sourceConfigurationName)
|
||||
.getDependencies()
|
||||
@@ -103,6 +107,23 @@ public class MavenRepositoryPlugin implements Plugin<Project> {
|
||||
});
|
||||
}
|
||||
|
||||
private void addMavenRepositoryPlatformDependencies(Project project, String sourceConfigurationName,
|
||||
DependencySet target) {
|
||||
project.getConfigurations()
|
||||
.getByName(sourceConfigurationName)
|
||||
.getDependencies()
|
||||
.withType(ModuleDependency.class)
|
||||
.matching((dependency) -> {
|
||||
Category category = dependency.getAttributes().getAttribute(Category.CATEGORY_ATTRIBUTE);
|
||||
return Category.REGULAR_PLATFORM.equals(category.getName());
|
||||
})
|
||||
.all((dependency) -> {
|
||||
Dependency pom = project.getDependencies()
|
||||
.create(dependency.getGroup() + ":" + dependency.getName() + ":" + dependency.getVersion());
|
||||
target.add(pom);
|
||||
});
|
||||
}
|
||||
|
||||
private static final class CleanAction implements Action<Task> {
|
||||
|
||||
private final File location;
|
||||
|
||||
+23
-20
@@ -162,22 +162,25 @@ public class MavenPluginPlugin implements Plugin<Project> {
|
||||
}
|
||||
|
||||
private void addPopulateIntTestMavenRepositoryTask(Project project) {
|
||||
Configuration runtimeClasspathWithMetadata = project.getConfigurations().create("runtimeClasspathWithMetadata");
|
||||
runtimeClasspathWithMetadata
|
||||
.extendsFrom(project.getConfigurations().getByName(JavaPlugin.RUNTIME_CLASSPATH_CONFIGURATION_NAME));
|
||||
runtimeClasspathWithMetadata.attributes((attributes) -> attributes.attribute(DocsType.DOCS_TYPE_ATTRIBUTE,
|
||||
project.getObjects().named(DocsType.class, "maven-repository")));
|
||||
TaskProvider<RuntimeClasspathMavenRepository> runtimeClasspathMavenRepository = project.getTasks()
|
||||
.register("runtimeClasspathMavenRepository", RuntimeClasspathMavenRepository.class,
|
||||
(task) -> task.getOutputDir()
|
||||
.set(project.getLayout().getBuildDirectory().dir("runtime-classpath-repository")));
|
||||
Configuration repositoryContents = project.getConfigurations().create("repositoryContents");
|
||||
repositoryContents.extendsFrom(
|
||||
project.getConfigurations().getByName(JavaPlugin.RUNTIME_CLASSPATH_CONFIGURATION_NAME),
|
||||
project.getConfigurations().getByName("mavenRepository"));
|
||||
repositoryContents.setCanBeConsumed(false);
|
||||
TaskProvider<ResolvedConfigurationMavenRepository> populateMavenRepository = project.getTasks()
|
||||
.register("populateResolvedDependenciesMavenRepository", ResolvedConfigurationMavenRepository.class,
|
||||
(task) -> {
|
||||
task.setConfiguration(repositoryContents);
|
||||
task.getOutputDir()
|
||||
.set(project.getLayout().getBuildDirectory().dir("resolved-dependencies-maven-repository"));
|
||||
});
|
||||
project.getDependencies()
|
||||
.components((components) -> components.all(MavenRepositoryComponentMetadataRule.class));
|
||||
TaskProvider<Sync> populateRepository = project.getTasks()
|
||||
.register("populateTestMavenRepository", Sync.class, (task) -> {
|
||||
task.setDestinationDir(
|
||||
project.getLayout().getBuildDirectory().dir("test-maven-repository").get().getAsFile());
|
||||
task.with(copyIntTestMavenRepositoryFiles(project, runtimeClasspathMavenRepository));
|
||||
task.with(copyIntTestMavenRepositoryFiles(project, populateMavenRepository));
|
||||
task.dependsOn(
|
||||
project.getTasks().getByName(MavenRepositoryPlugin.PUBLISH_TO_PROJECT_REPOSITORY_TASK_NAME));
|
||||
});
|
||||
@@ -190,7 +193,7 @@ public class MavenPluginPlugin implements Plugin<Project> {
|
||||
}
|
||||
|
||||
private CopySpec copyIntTestMavenRepositoryFiles(Project project,
|
||||
TaskProvider<RuntimeClasspathMavenRepository> runtimeClasspathMavenRepository) {
|
||||
TaskProvider<ResolvedConfigurationMavenRepository> runtimeClasspathMavenRepository) {
|
||||
CopySpec copySpec = project.copySpec();
|
||||
copySpec.from(project.getConfigurations().getByName(MavenRepositoryPlugin.MAVEN_REPOSITORY_CONFIGURATION_NAME));
|
||||
copySpec.from(project.getLayout().getBuildDirectory().dir("maven-repository"));
|
||||
@@ -434,25 +437,25 @@ public class MavenPluginPlugin implements Plugin<Project> {
|
||||
|
||||
}
|
||||
|
||||
public abstract static class RuntimeClasspathMavenRepository extends DefaultTask {
|
||||
public abstract static class ResolvedConfigurationMavenRepository extends DefaultTask {
|
||||
|
||||
private final Configuration runtimeClasspath;
|
||||
|
||||
public RuntimeClasspathMavenRepository() {
|
||||
this.runtimeClasspath = getProject().getConfigurations().getByName("runtimeClasspathWithMetadata");
|
||||
}
|
||||
private Configuration configuration;
|
||||
|
||||
@OutputDirectory
|
||||
public abstract DirectoryProperty getOutputDir();
|
||||
|
||||
@Classpath
|
||||
public Configuration getRuntimeClasspath() {
|
||||
return this.runtimeClasspath;
|
||||
public Configuration getConfiguration() {
|
||||
return this.configuration;
|
||||
}
|
||||
|
||||
public void setConfiguration(Configuration configuration) {
|
||||
this.configuration = configuration;
|
||||
}
|
||||
|
||||
@TaskAction
|
||||
public void createRepository() {
|
||||
for (ResolvedArtifactResult result : this.runtimeClasspath.getIncoming().getArtifacts()) {
|
||||
for (ResolvedArtifactResult result : this.configuration.getIncoming().getArtifacts()) {
|
||||
if (result.getId().getComponentIdentifier() instanceof ModuleComponentIdentifier identifier) {
|
||||
String fileName = result.getFile()
|
||||
.getName()
|
||||
|
||||
Reference in New Issue
Block a user