Include all non-snapshot repositories when checking for upgrades
Closes gh-25391
This commit is contained in:
parent
a2c951d173
commit
8cb24a426d
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2012-2020 the original author or authors.
|
* Copyright 2012-2021 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|
@ -18,8 +18,8 @@ package org.springframework.boot.build.bom.bomr;
|
||||||
|
|
||||||
import java.io.StringReader;
|
import java.io.StringReader;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
import java.util.Collection;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.SortedSet;
|
import java.util.SortedSet;
|
||||||
import java.util.TreeSet;
|
import java.util.TreeSet;
|
||||||
|
|
@ -49,13 +49,13 @@ final class MavenMetadataVersionResolver implements VersionResolver {
|
||||||
|
|
||||||
private final RestTemplate rest;
|
private final RestTemplate rest;
|
||||||
|
|
||||||
private final List<String> repositoryUrls;
|
private final Collection<String> repositoryUrls;
|
||||||
|
|
||||||
MavenMetadataVersionResolver(List<String> repositoryUrls) {
|
MavenMetadataVersionResolver(Collection<String> repositoryUrls) {
|
||||||
this(new RestTemplate(Arrays.asList(new StringHttpMessageConverter())), repositoryUrls);
|
this(new RestTemplate(Arrays.asList(new StringHttpMessageConverter())), repositoryUrls);
|
||||||
}
|
}
|
||||||
|
|
||||||
MavenMetadataVersionResolver(RestTemplate restTemplate, List<String> repositoryUrls) {
|
MavenMetadataVersionResolver(RestTemplate restTemplate, Collection<String> repositoryUrls) {
|
||||||
this.rest = restTemplate;
|
this.rest = restTemplate;
|
||||||
this.repositoryUrls = repositoryUrls;
|
this.repositoryUrls = repositoryUrls;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -22,16 +22,18 @@ import java.io.IOException;
|
||||||
import java.io.Reader;
|
import java.io.Reader;
|
||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.LinkedHashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
|
|
||||||
import org.gradle.api.DefaultTask;
|
import org.gradle.api.DefaultTask;
|
||||||
import org.gradle.api.InvalidUserDataException;
|
import org.gradle.api.InvalidUserDataException;
|
||||||
import org.gradle.api.Task;
|
import org.gradle.api.Task;
|
||||||
|
import org.gradle.api.artifacts.repositories.MavenArtifactRepository;
|
||||||
import org.gradle.api.internal.tasks.userinput.UserInputHandler;
|
import org.gradle.api.internal.tasks.userinput.UserInputHandler;
|
||||||
import org.gradle.api.tasks.Input;
|
import org.gradle.api.tasks.Input;
|
||||||
import org.gradle.api.tasks.TaskAction;
|
import org.gradle.api.tasks.TaskAction;
|
||||||
|
|
@ -51,6 +53,8 @@ import org.springframework.util.StringUtils;
|
||||||
*/
|
*/
|
||||||
public class UpgradeBom extends DefaultTask {
|
public class UpgradeBom extends DefaultTask {
|
||||||
|
|
||||||
|
private Set<String> repositoryUrls;
|
||||||
|
|
||||||
private final BomExtension bom;
|
private final BomExtension bom;
|
||||||
|
|
||||||
private String milestone;
|
private String milestone;
|
||||||
|
|
@ -58,6 +62,13 @@ public class UpgradeBom extends DefaultTask {
|
||||||
@Inject
|
@Inject
|
||||||
public UpgradeBom(BomExtension bom) {
|
public UpgradeBom(BomExtension bom) {
|
||||||
this.bom = bom;
|
this.bom = bom;
|
||||||
|
this.repositoryUrls = new LinkedHashSet<>();
|
||||||
|
getProject().getRepositories().withType(MavenArtifactRepository.class, (repository) -> {
|
||||||
|
String repositoryUrl = repository.getUrl().toString();
|
||||||
|
if (!repositoryUrl.endsWith("snapshot")) {
|
||||||
|
this.repositoryUrls.add(repository.getUrl().toString());
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Option(option = "milestone", description = "Milestone to which dependency upgrade issues should be assigned")
|
@Option(option = "milestone", description = "Milestone to which dependency upgrade issues should be assigned")
|
||||||
|
|
@ -83,8 +94,7 @@ public class UpgradeBom extends DefaultTask {
|
||||||
"Unknown label(s): " + StringUtils.collectionToCommaDelimitedString(unknownLabels));
|
"Unknown label(s): " + StringUtils.collectionToCommaDelimitedString(unknownLabels));
|
||||||
}
|
}
|
||||||
Milestone milestone = determineMilestone(repository);
|
Milestone milestone = determineMilestone(repository);
|
||||||
List<Upgrade> upgrades = new InteractiveUpgradeResolver(
|
List<Upgrade> upgrades = new InteractiveUpgradeResolver(new MavenMetadataVersionResolver(this.repositoryUrls),
|
||||||
new MavenMetadataVersionResolver(Arrays.asList("https://repo1.maven.org/maven2/")),
|
|
||||||
this.bom.getUpgrade().getPolicy(), getServices().get(UserInputHandler.class))
|
this.bom.getUpgrade().getPolicy(), getServices().get(UserInputHandler.class))
|
||||||
.resolveUpgrades(this.bom.getLibraries());
|
.resolveUpgrades(this.bom.getLibraries());
|
||||||
Path buildFile = getProject().getBuildFile().toPath();
|
Path buildFile = getProject().getBuildFile().toPath();
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue