From 57c4b20de8e2941f697471513db884b599842fd5 Mon Sep 17 00:00:00 2001 From: Geert Bevin Date: Wed, 22 May 2024 12:25:02 -0400 Subject: [PATCH] Improve artifact not found exception to explicitly mention that no repositories or no artifact locations are defined. --- .../bld/dependencies/DependencyResolver.java | 22 +++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/src/main/java/rife/bld/dependencies/DependencyResolver.java b/src/main/java/rife/bld/dependencies/DependencyResolver.java index 8f61937..5eccd6e 100644 --- a/src/main/java/rife/bld/dependencies/DependencyResolver.java +++ b/src/main/java/rife/bld/dependencies/DependencyResolver.java @@ -365,7 +365,16 @@ public class DependencyResolver { } 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(); @@ -414,7 +423,16 @@ public class DependencyResolver { } 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_);