use of org.springframework.boot.build.bom.bomr.version.DependencyVersion in project spring-boot by spring-projects.
the class InteractiveUpgradeResolver method determineResolvedVersionOptions.
private List<VersionOption> determineResolvedVersionOptions(Library library) {
Map<String, SortedSet<DependencyVersion>> moduleVersions = new LinkedHashMap<>();
DependencyVersion libraryVersion = library.getVersion().getVersion();
for (Group group : library.getGroups()) {
for (Module module : group.getModules()) {
moduleVersions.put(group.getId() + ":" + module.getName(), getLaterVersionsForModule(group.getId(), module.getName(), libraryVersion));
}
for (String bom : group.getBoms()) {
moduleVersions.put(group.getId() + ":" + bom, getLaterVersionsForModule(group.getId(), bom, libraryVersion));
}
for (String plugin : group.getPlugins()) {
moduleVersions.put(group.getId() + ":" + plugin, getLaterVersionsForModule(group.getId(), plugin, libraryVersion));
}
}
List<DependencyVersion> allVersions = moduleVersions.values().stream().flatMap(SortedSet::stream).distinct().filter((dependencyVersion) -> isPermitted(dependencyVersion, library.getProhibitedVersions())).collect(Collectors.toList());
if (allVersions.isEmpty()) {
return Collections.emptyList();
}
return allVersions.stream().map((version) -> new ResolvedVersionOption(version, getMissingModules(moduleVersions, version))).collect(Collectors.toList());
}
use of org.springframework.boot.build.bom.bomr.version.DependencyVersion in project spring-boot by spring-projects.
the class InteractiveUpgradeResolver method alignedVersionOption.
private VersionOption alignedVersionOption(Library library, Map<String, Library> libraries) {
VersionAlignment versionAlignment = library.getVersion().getVersionAlignment();
Library alignmentLibrary = libraries.get(versionAlignment.getLibraryName());
DependencyVersions dependencyVersions = alignmentLibrary.getDependencyVersions();
if (dependencyVersions == null) {
throw new InvalidUserDataException("Cannot align with library '" + versionAlignment.getLibraryName() + "' as it does not define any dependency versions");
}
if (!dependencyVersions.available()) {
return null;
}
Set<String> versions = new HashSet<>();
for (Group group : library.getGroups()) {
for (Module module : group.getModules()) {
String version = dependencyVersions.getVersion(group.getId(), module.getName());
if (version != null) {
versions.add(version);
}
}
}
if (versions.isEmpty()) {
throw new InvalidUserDataException("Cannot align with library '" + versionAlignment.getLibraryName() + "' as its dependency versions do not include any of this library's modules");
}
if (versions.size() > 1) {
throw new InvalidUserDataException("Cannot align with library '" + versionAlignment.getLibraryName() + "' as it uses multiple different versions of this library's modules");
}
DependencyVersion version = DependencyVersion.parse(versions.iterator().next());
return library.getVersion().getVersion().equals(version) ? null : new AlignedVersionOption(version, alignmentLibrary);
}
Aggregations