mirror of
https://github.com/spring-projects/spring-boot.git
synced 2024-07-15 01:07:30 +08:00
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");
|
||||
* 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.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.SortedSet;
|
||||
import java.util.TreeSet;
|
||||
@ -49,13 +49,13 @@ final class MavenMetadataVersionResolver implements VersionResolver {
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
MavenMetadataVersionResolver(RestTemplate restTemplate, List<String> repositoryUrls) {
|
||||
MavenMetadataVersionResolver(RestTemplate restTemplate, Collection<String> repositoryUrls) {
|
||||
this.rest = restTemplate;
|
||||
this.repositoryUrls = repositoryUrls;
|
||||
}
|
||||
|
@ -22,16 +22,18 @@ import java.io.IOException;
|
||||
import java.io.Reader;
|
||||
import java.nio.file.Path;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.Properties;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import org.gradle.api.DefaultTask;
|
||||
import org.gradle.api.InvalidUserDataException;
|
||||
import org.gradle.api.Task;
|
||||
import org.gradle.api.artifacts.repositories.MavenArtifactRepository;
|
||||
import org.gradle.api.internal.tasks.userinput.UserInputHandler;
|
||||
import org.gradle.api.tasks.Input;
|
||||
import org.gradle.api.tasks.TaskAction;
|
||||
@ -51,6 +53,8 @@ import org.springframework.util.StringUtils;
|
||||
*/
|
||||
public class UpgradeBom extends DefaultTask {
|
||||
|
||||
private Set<String> repositoryUrls;
|
||||
|
||||
private final BomExtension bom;
|
||||
|
||||
private String milestone;
|
||||
@ -58,6 +62,13 @@ public class UpgradeBom extends DefaultTask {
|
||||
@Inject
|
||||
public UpgradeBom(BomExtension 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")
|
||||
@ -83,8 +94,7 @@ public class UpgradeBom extends DefaultTask {
|
||||
"Unknown label(s): " + StringUtils.collectionToCommaDelimitedString(unknownLabels));
|
||||
}
|
||||
Milestone milestone = determineMilestone(repository);
|
||||
List<Upgrade> upgrades = new InteractiveUpgradeResolver(
|
||||
new MavenMetadataVersionResolver(Arrays.asList("https://repo1.maven.org/maven2/")),
|
||||
List<Upgrade> upgrades = new InteractiveUpgradeResolver(new MavenMetadataVersionResolver(this.repositoryUrls),
|
||||
this.bom.getUpgrade().getPolicy(), getServices().get(UserInputHandler.class))
|
||||
.resolveUpgrades(this.bom.getLibraries());
|
||||
Path buildFile = getProject().getBuildFile().toPath();
|
||||
|
Loading…
Reference in New Issue
Block a user