Skip to content

Commit

Permalink
only emit warnings when urls differ
Browse files Browse the repository at this point in the history
  • Loading branch information
kwin committed May 18, 2024
1 parent f32e0cb commit 312983b
Showing 1 changed file with 36 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -799,6 +799,7 @@ public void validateExternalProfiles(
for (Profile profile : activeExternalProfiles.stream()
.map(org.apache.maven.model.Profile::getDelegate)
.collect(Collectors.toList())) {
<<<<<<< Upstream, based on master
for (Repository repository : profile.getRepositories()) {
Optional<Repository> clashingPomRepository = m.getRepositories().stream()
.filter(r -> r.getId().equals(repository.getId()))
Expand All @@ -814,6 +815,41 @@ public void validateExternalProfiles(
+ profile.getId(),
clashingPomRepository.get());
}
=======
String externalRepositoriesSource = "external profile with id '" + profile.getId() + "' in settings.xml";
validateUniqueRepositoryIds(
false, m.getRepositories(), profile.getRepositories(), externalRepositoriesSource, problems);
validateUniqueRepositoryIds(
true,
m.getPluginRepositories(),
profile.getPluginRepositories(),
externalRepositoriesSource,
problems);
}
}

private void validateUniqueRepositoryIds(
boolean isPluginRepository,
Collection<Repository> pomRepositories,
Collection<Repository> externalRepositories,
String externalRepositoriesSource,
ModelProblemCollector problems) {
for (Repository externalRepository : externalRepositories) {
Optional<Repository> clashingPomRepository = pomRepositories.stream()
.filter(r -> Objects.equals(r.getId(), externalRepository.getId()))
.filter(r -> !Objects.equals(r.getUrl(), externalRepository.getUrl()))
.findFirst();
if (clashingPomRepository.isPresent()) {
addViolation(
problems,
Severity.WARNING,
Version.BASE,
isPluginRepository ? "pluginRepositories.repository" : "repositories.repository",
clashingPomRepository.get().getId(),
"is overwritten by the repository with same id but having a different url from "
+ externalRepositoriesSource,
clashingPomRepository.get());
>>>>>>> 885cee2 only emit warnings when urls differ
}
}
}
Expand Down

0 comments on commit 312983b

Please sign in to comment.