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 c4944167168..da86df2bd85 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 @@ -76,6 +76,7 @@ public class MavenPomDownloader { @Nullable private MavenSettings mavenSettings; + private Collection mirrors; @Nullable private List activeProfiles; @@ -97,6 +98,7 @@ public MavenPomDownloader(Map projectPoms, ExecutionContext ctx, @Nullable List activeProfiles) { this(projectPoms, HttpSenderExecutionContextView.view(ctx).getHttpSender(), ctx); this.mavenSettings = mavenSettings; + this.mirrors = this.ctx.getMirrors(mavenSettings); this.activeProfiles = activeProfiles; } @@ -137,6 +139,7 @@ public MavenPomDownloader(Map projectPoms, HttpSender httpSender, Exe this.mavenCache = this.ctx.getPomCache(); this.addCentralRepository = !Boolean.FALSE.equals(MavenExecutionContextView.view(ctx).getAddCentralRepository()); this.addLocalRepository = !Boolean.FALSE.equals(MavenExecutionContextView.view(ctx).getAddLocalRepository()); + this.mirrors = this.ctx.getMirrors(this.ctx.getSettings()); } byte[] sendRequest(HttpSender.Request request) throws IOException, HttpSenderResponseException { @@ -861,7 +864,7 @@ private static boolean hasCredentials(MavenRepository repository) { } private MavenRepository applyMirrors(MavenRepository repository) { - return MavenRepositoryMirror.apply(ctx.getMirrors(mavenSettings), repository); + return MavenRepositoryMirror.apply(mirrors, repository); } @Getter