From adcec358a89cfdc3823cd88aa14e2f0ff5d38384 Mon Sep 17 00:00:00 2001 From: Tim te Beek Date: Sat, 21 Sep 2024 22:11:44 +0200 Subject: [PATCH] Use alternate metadata local file path --- .../openrewrite/maven/internal/MavenPomDownloader.java | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/rewrite-maven/src/main/java/org/openrewrite/maven/internal/MavenPomDownloader.java b/rewrite-maven/src/main/java/org/openrewrite/maven/internal/MavenPomDownloader.java index 1128692801f..915cf797bf7 100644 --- a/rewrite-maven/src/main/java/org/openrewrite/maven/internal/MavenPomDownloader.java +++ b/rewrite-maven/src/main/java/org/openrewrite/maven/internal/MavenPomDownloader.java @@ -256,15 +256,14 @@ public MavenMetadata downloadMetadata(GroupArtifactVersion gav, @Nullable Resolv boolean cacheEmptyResult = false; try { String scheme = URI.create(repo.getUri()).getScheme(); - String uri = repo.getUri() + (repo.getUri().endsWith("/") ? "" : "/") + + String baseUri = repo.getUri() + (repo.getUri().endsWith("/") ? "" : "/") + requireNonNull(gav.getGroupId()).replace('.', '/') + '/' + gav.getArtifactId() + '/' + - (gav.getVersion() == null ? "" : gav.getVersion() + '/') + - "maven-metadata.xml"; + (gav.getVersion() == null ? "" : gav.getVersion() + '/'); if ("file".equals(scheme)) { // A maven repository can be expressed as a URI with a file scheme - Path path = Paths.get(URI.create(uri)); + Path path = Paths.get(URI.create(baseUri + "maven-metadata-local.xml")); if (Files.exists(path)) { MavenMetadata parsed = MavenMetadata.parse(Files.readAllBytes(path)); if (parsed != null) { @@ -272,7 +271,7 @@ public MavenMetadata downloadMetadata(GroupArtifactVersion gav, @Nullable Resolv } } } else { - byte[] responseBody = requestAsAuthenticatedOrAnonymous(repo, uri); + byte[] responseBody = requestAsAuthenticatedOrAnonymous(repo, baseUri + "maven-metadata.xml"); MavenMetadata parsed = MavenMetadata.parse(responseBody); if (parsed != null) { result = Optional.of(parsed);