Search in sources :

Example 1 with Module

use of org.springframework.boot.build.bom.Library.Module in project spring-boot by spring-projects.

the class BomExtension method addLibrary.

private void addLibrary(Library library) {
    this.libraries.add(library);
    String versionProperty = library.getVersionProperty();
    if (versionProperty != null) {
        this.properties.put(versionProperty, library.getVersion().getVersion());
    }
    for (Group group : library.getGroups()) {
        for (Module module : group.getModules()) {
            putArtifactVersionProperty(group.getId(), module.getName(), versionProperty);
            this.dependencyHandler.getConstraints().add(JavaPlatformPlugin.API_CONFIGURATION_NAME, createDependencyNotation(group.getId(), module.getName(), library.getVersion().getVersion()));
        }
        for (String bomImport : group.getBoms()) {
            putArtifactVersionProperty(group.getId(), bomImport, versionProperty);
            String bomDependency = createDependencyNotation(group.getId(), bomImport, library.getVersion().getVersion());
            this.dependencyHandler.add(JavaPlatformPlugin.API_CONFIGURATION_NAME, this.dependencyHandler.platform(bomDependency));
            this.dependencyHandler.add(BomPlugin.API_ENFORCED_CONFIGURATION_NAME, this.dependencyHandler.enforcedPlatform(bomDependency));
        }
    }
}
Also used : Group(org.springframework.boot.build.bom.Library.Group) Module(org.springframework.boot.build.bom.Library.Module)

Example 2 with Module

use of org.springframework.boot.build.bom.Library.Module 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());
}
Also used : UserInputHandler(org.gradle.api.internal.tasks.userinput.UserInputHandler) Module(org.springframework.boot.build.bom.Library.Module) SortedSet(java.util.SortedSet) DependencyVersions(org.springframework.boot.build.bom.Library.DependencyVersions) DefaultArtifactVersion(org.apache.maven.artifact.versioning.DefaultArtifactVersion) Collection(java.util.Collection) Group(org.springframework.boot.build.bom.Library.Group) Set(java.util.Set) HashMap(java.util.HashMap) Library(org.springframework.boot.build.bom.Library) Collectors(java.util.stream.Collectors) ArrayList(java.util.ArrayList) UpgradePolicy(org.springframework.boot.build.bom.UpgradePolicy) HashSet(java.util.HashSet) LinkedHashMap(java.util.LinkedHashMap) DependencyVersion(org.springframework.boot.build.bom.bomr.version.DependencyVersion) List(java.util.List) Map(java.util.Map) VersionAlignment(org.springframework.boot.build.bom.Library.VersionAlignment) ProhibitedVersion(org.springframework.boot.build.bom.Library.ProhibitedVersion) Collections(java.util.Collections) InvalidUserDataException(org.gradle.api.InvalidUserDataException) StringUtils(org.springframework.util.StringUtils) Group(org.springframework.boot.build.bom.Library.Group) DependencyVersion(org.springframework.boot.build.bom.bomr.version.DependencyVersion) Module(org.springframework.boot.build.bom.Library.Module) SortedSet(java.util.SortedSet) LinkedHashMap(java.util.LinkedHashMap)

Example 3 with Module

use of org.springframework.boot.build.bom.Library.Module 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);
}
Also used : Group(org.springframework.boot.build.bom.Library.Group) DependencyVersions(org.springframework.boot.build.bom.Library.DependencyVersions) InvalidUserDataException(org.gradle.api.InvalidUserDataException) DependencyVersion(org.springframework.boot.build.bom.bomr.version.DependencyVersion) Library(org.springframework.boot.build.bom.Library) VersionAlignment(org.springframework.boot.build.bom.Library.VersionAlignment) Module(org.springframework.boot.build.bom.Library.Module) HashSet(java.util.HashSet)

Aggregations

Group (org.springframework.boot.build.bom.Library.Group)3 Module (org.springframework.boot.build.bom.Library.Module)3 HashSet (java.util.HashSet)2 InvalidUserDataException (org.gradle.api.InvalidUserDataException)2 Library (org.springframework.boot.build.bom.Library)2 DependencyVersions (org.springframework.boot.build.bom.Library.DependencyVersions)2 VersionAlignment (org.springframework.boot.build.bom.Library.VersionAlignment)2 DependencyVersion (org.springframework.boot.build.bom.bomr.version.DependencyVersion)2 ArrayList (java.util.ArrayList)1 Collection (java.util.Collection)1 Collections (java.util.Collections)1 HashMap (java.util.HashMap)1 LinkedHashMap (java.util.LinkedHashMap)1 List (java.util.List)1 Map (java.util.Map)1 Set (java.util.Set)1 SortedSet (java.util.SortedSet)1 Collectors (java.util.stream.Collectors)1 DefaultArtifactVersion (org.apache.maven.artifact.versioning.DefaultArtifactVersion)1 UserInputHandler (org.gradle.api.internal.tasks.userinput.UserInputHandler)1