Search in sources :

Example 1 with OIDC_SDK_NAME

use of org.springframework.security.convention.versions.TransitiveDependencyLookupUtils.OIDC_SDK_NAME in project spring-security by spring-projects.

the class UpdateDependenciesPlugin method updateDependencies.

private void updateDependencies(Result result, Project project, UpdateDependenciesExtension updateDependenciesSettings) {
    SortedSet<DependencyOutdated> dependencies = result.getOutdated().getDependencies();
    if (dependencies.isEmpty()) {
        return;
    }
    Map<String, List<DependencyOutdated>> groups = new LinkedHashMap<>();
    dependencies.forEach(outdated -> {
        groups.computeIfAbsent(outdated.getGroup(), (key) -> new ArrayList<>()).add(outdated);
    });
    List<DependencyOutdated> nimbusds = groups.getOrDefault("com.nimbusds", new ArrayList<>());
    DependencyOutdated oidcSdc = nimbusds.stream().filter(d -> d.getName().equals(OIDC_SDK_NAME)).findFirst().orElseGet(() -> null);
    if (oidcSdc != null) {
        String oidcVersion = updatedVersion(oidcSdc);
        String jwtVersion = TransitiveDependencyLookupUtils.lookupJwtVersion(oidcVersion);
        Dependency nimbusJoseJwtDependency = result.getCurrent().getDependencies().stream().filter(d -> d.getName().equals(NIMBUS_JOSE_JWT_NAME)).findFirst().get();
        DependencyOutdated outdatedJwt = new DependencyOutdated();
        outdatedJwt.setVersion(nimbusJoseJwtDependency.getVersion());
        outdatedJwt.setGroup(oidcSdc.getGroup());
        outdatedJwt.setName(NIMBUS_JOSE_JWT_NAME);
        VersionAvailable available = new VersionAvailable();
        available.setRelease(jwtVersion);
        outdatedJwt.setAvailable(available);
        nimbusds.add(outdatedJwt);
    }
    File gradlePropertiesFile = project.getRootProject().file(Project.GRADLE_PROPERTIES);
    Mono<GitHubApi.FindCreateIssueResult> createIssueResult = createIssueResultMono(updateDependenciesSettings);
    List<File> filesWithDependencies = updateDependenciesSettings.getFiles().get();
    groups.forEach((group, outdated) -> {
        outdated.forEach((dependency) -> {
            String ga = dependency.getGroup() + ":" + dependency.getName() + ":";
            String originalDependency = ga + dependency.getVersion();
            String replacementDependency = ga + updatedVersion(dependency);
            System.out.println("Update " + originalDependency + " to " + replacementDependency);
            filesWithDependencies.forEach((fileWithDependency) -> {
                updateDependencyInlineVersion(fileWithDependency, dependency);
                updateDependencyWithVersionVariable(fileWithDependency, gradlePropertiesFile, dependency);
            });
        });
        // commit
        DependencyOutdated firstDependency = outdated.get(0);
        String updatedVersion = updatedVersion(firstDependency);
        String title = outdated.size() == 1 ? "Update " + firstDependency.getName() + " to " + updatedVersion : "Update " + firstDependency.getGroup() + " to " + updatedVersion;
        afterGroup(updateDependenciesSettings, project.getRootDir(), title, createIssueResult);
    });
}
Also used : DependencyOutdated(com.github.benmanes.gradle.versions.reporter.result.DependencyOutdated) java.util(java.util) ComponentSelectionRulesWithCurrent(com.github.benmanes.gradle.versions.updates.resolutionstrategy.ComponentSelectionRulesWithCurrent) GradleUpdateResult(com.github.benmanes.gradle.versions.updates.gradle.GradleUpdateResult) Closure(groovy.lang.Closure) VersionAvailable(com.github.benmanes.gradle.versions.reporter.result.VersionAvailable) Function(java.util.function.Function) Supplier(java.util.function.Supplier) Result(com.github.benmanes.gradle.versions.reporter.result.Result) Matcher(java.util.regex.Matcher) ComponentSelectionWithCurrent(com.github.benmanes.gradle.versions.updates.resolutionstrategy.ComponentSelectionWithCurrent) Duration(java.time.Duration) Dependency(com.github.benmanes.gradle.versions.reporter.result.Dependency) OIDC_SDK_NAME(org.springframework.security.convention.versions.TransitiveDependencyLookupUtils.OIDC_SDK_NAME) PrintStream(java.io.PrintStream) Action(org.gradle.api.Action) Project(org.gradle.api.Project) Files(java.nio.file.Files) DependencyOutdated(com.github.benmanes.gradle.versions.reporter.result.DependencyOutdated) NIMBUS_JOSE_JWT_NAME(org.springframework.security.convention.versions.TransitiveDependencyLookupUtils.NIMBUS_JOSE_JWT_NAME) Mono(reactor.core.publisher.Mono) IOException(java.io.IOException) File(java.io.File) ModuleComponentIdentifier(org.gradle.api.artifacts.component.ModuleComponentIdentifier) ResolutionStrategyWithCurrent(com.github.benmanes.gradle.versions.updates.resolutionstrategy.ResolutionStrategyWithCurrent) DependencyUpdatesTask(com.github.benmanes.gradle.versions.updates.DependencyUpdatesTask) Pattern(java.util.regex.Pattern) Plugin(org.gradle.api.Plugin) InputStream(java.io.InputStream) VersionAvailable(com.github.benmanes.gradle.versions.reporter.result.VersionAvailable) Dependency(com.github.benmanes.gradle.versions.reporter.result.Dependency) File(java.io.File)

Aggregations

Dependency (com.github.benmanes.gradle.versions.reporter.result.Dependency)1 DependencyOutdated (com.github.benmanes.gradle.versions.reporter.result.DependencyOutdated)1 Result (com.github.benmanes.gradle.versions.reporter.result.Result)1 VersionAvailable (com.github.benmanes.gradle.versions.reporter.result.VersionAvailable)1 DependencyUpdatesTask (com.github.benmanes.gradle.versions.updates.DependencyUpdatesTask)1 GradleUpdateResult (com.github.benmanes.gradle.versions.updates.gradle.GradleUpdateResult)1 ComponentSelectionRulesWithCurrent (com.github.benmanes.gradle.versions.updates.resolutionstrategy.ComponentSelectionRulesWithCurrent)1 ComponentSelectionWithCurrent (com.github.benmanes.gradle.versions.updates.resolutionstrategy.ComponentSelectionWithCurrent)1 ResolutionStrategyWithCurrent (com.github.benmanes.gradle.versions.updates.resolutionstrategy.ResolutionStrategyWithCurrent)1 Closure (groovy.lang.Closure)1 File (java.io.File)1 IOException (java.io.IOException)1 InputStream (java.io.InputStream)1 PrintStream (java.io.PrintStream)1 Files (java.nio.file.Files)1 Duration (java.time.Duration)1 java.util (java.util)1 Function (java.util.function.Function)1 Supplier (java.util.function.Supplier)1 Matcher (java.util.regex.Matcher)1