Skip to content

Commit

Permalink
Improve artifact not found exception to explicitly mention that no re…
Browse files Browse the repository at this point in the history
…positories or no artifact locations are defined.
  • Loading branch information
gbevin committed May 22, 2024
1 parent f0129e7 commit 57c4b20
Showing 1 changed file with 20 additions and 2 deletions.
22 changes: 20 additions & 2 deletions src/main/java/rife/bld/dependencies/DependencyResolver.java
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,16 @@ private MavenMetadata parseMavenMetadata(List<RepositoryArtifact> artifacts) {
}

if (metadata == null) {
throw new ArtifactNotFoundException(dependency_, artifacts.stream().map(RepositoryArtifact::location).collect(Collectors.joining(", ")));
var location = artifacts.stream().map(RepositoryArtifact::location).collect(Collectors.joining(", "));
if (location.isEmpty()) {
if (repositories_.isEmpty()) {
location = "[no repositories defined]";
}
else {
location = "[no metadata locations defined]";
}
}
throw new ArtifactNotFoundException(dependency_, location);
}

var xml = new Xml2MavenMetadata();
Expand Down Expand Up @@ -414,7 +423,16 @@ Xml2MavenPom getMavenPom(Dependency parent) {
}

if (pom == null) {
throw new ArtifactNotFoundException(dependency_, artifacts.stream().map(RepositoryArtifact::location).collect(Collectors.joining(", ")));
var location = artifacts.stream().map(RepositoryArtifact::location).collect(Collectors.joining(", "));
if (location.isEmpty()) {
if (repositories_.isEmpty()) {
location = "[no repositories defined]";
}
else {
location = "[no pom locations defined]";
}
}
throw new ArtifactNotFoundException(dependency_, location);
}

var xml = new Xml2MavenPom(parent, retriever_, repositories_);
Expand Down

0 comments on commit 57c4b20

Please sign in to comment.