ResolvedDependencies Class — spring-boot Architecture
Architecture documentation for the ResolvedDependencies class in ResolvedDependencies.java from the spring-boot codebase.
Entity Profile
Source Code
build-plugin/spring-boot-gradle-plugin/src/main/java/org/springframework/boot/gradle/tasks/bundling/ResolvedDependencies.java lines 51–149
class ResolvedDependencies {
private final Map<String, LibraryCoordinates> projectCoordinatesByPath;
private final ListProperty<ComponentArtifactIdentifier> artifactIds;
private final ListProperty<File> artifactFiles;
ResolvedDependencies(Project project) {
this.artifactIds = project.getObjects().listProperty(ComponentArtifactIdentifier.class);
this.artifactFiles = project.getObjects().listProperty(File.class);
this.projectCoordinatesByPath = projectCoordinatesByPath(project);
}
private static Map<String, LibraryCoordinates> projectCoordinatesByPath(Project project) {
return project.getRootProject()
.getAllprojects()
.stream()
.collect(Collectors.toMap(Project::getPath, ResolvedDependencies::libraryCoordinates));
}
private static LibraryCoordinates libraryCoordinates(Project project) {
return LibraryCoordinates.of(Objects.toString(project.getGroup()), project.getName(),
Objects.toString(project.getVersion()));
}
@Input
ListProperty<ComponentArtifactIdentifier> getArtifactIds() {
return this.artifactIds;
}
@Classpath
ListProperty<File> getArtifactFiles() {
return this.artifactFiles;
}
void resolvedArtifacts(Provider<Set<ResolvedArtifactResult>> resolvedArtifacts) {
this.artifactFiles.addAll(
resolvedArtifacts.map((artifacts) -> artifacts.stream().map(ResolvedArtifactResult::getFile).toList()));
this.artifactIds.addAll(
resolvedArtifacts.map((artifacts) -> artifacts.stream().map(ResolvedArtifactResult::getId).toList()));
}
@Nullable DependencyDescriptor find(File file) {
ComponentArtifactIdentifier id = findArtifactIdentifier(file);
if (id == null) {
return null;
}
if (id instanceof ModuleComponentArtifactIdentifier moduleComponentId) {
ModuleComponentIdentifier moduleId = moduleComponentId.getComponentIdentifier();
return new DependencyDescriptor(
LibraryCoordinates.of(moduleId.getGroup(), moduleId.getModule(), moduleId.getVersion()), false);
}
ComponentIdentifier componentIdentifier = id.getComponentIdentifier();
if (componentIdentifier instanceof ProjectComponentIdentifier projectComponentId) {
String projectPath = projectComponentId.getProjectPath();
LibraryCoordinates projectCoordinates = this.projectCoordinatesByPath.get(projectPath);
if (projectCoordinates != null) {
return new DependencyDescriptor(projectCoordinates, true);
}
}
return null;
}
private @Nullable ComponentArtifactIdentifier findArtifactIdentifier(File file) {
List<File> files = this.artifactFiles.get();
for (int i = 0; i < files.size(); i++) {
if (file.equals(files.get(i))) {
return this.artifactIds.get().get(i);
}
}
return null;
}
/**
* Describes a dependency in a {@link ResolvedConfiguration}.
*/
static final class DependencyDescriptor {
private final LibraryCoordinates coordinates;
private final boolean projectDependency;
private DependencyDescriptor(LibraryCoordinates coordinates, boolean projectDependency) {
this.coordinates = coordinates;
this.projectDependency = projectDependency;
}
LibraryCoordinates getCoordinates() {
return this.coordinates;
}
boolean isProjectDependency() {
return this.projectDependency;
}
}
}
Source
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free