From 3141aae26e62680447196b7faf34ff112ca437cf Mon Sep 17 00:00:00 2001 From: Tim te Beek Date: Fri, 5 Jul 2024 14:39:17 +0200 Subject: [PATCH] Further cascading changes --- .../maven/MavenExecutionContextView.java | 4 +- .../openrewrite/maven/UpdateMavenModel.java | 1 - .../maven/internal/MavenPomDownloader.java | 4 +- .../openrewrite/maven/internal/RawPom.java | 2 +- .../maven/tree/MavenRepository.java | 40 +++++++------------ .../maven/tree/MavenRepositoryMirror.java | 3 +- .../openrewrite/maven/tree/ResolvedPom.java | 3 +- 7 files changed, 20 insertions(+), 37 deletions(-) diff --git a/rewrite-maven/src/main/java/org/openrewrite/maven/MavenExecutionContextView.java b/rewrite-maven/src/main/java/org/openrewrite/maven/MavenExecutionContextView.java index ef1760dafa8..b06eb709499 100644 --- a/rewrite-maven/src/main/java/org/openrewrite/maven/MavenExecutionContextView.java +++ b/rewrite-maven/src/main/java/org/openrewrite/maven/MavenExecutionContextView.java @@ -278,8 +278,7 @@ private List mapRepositories(MavenSettings settings, List mapRepositories(MavenSettings settings, List s.getChildValue("enabled")).orElse(null), null, null, - null, null )).collect(Collectors.toList())); } else { 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 c0ea0cc06e0..2a175305548 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 @@ -824,8 +824,8 @@ public MavenRepository normalizeRepository(MavenRepository originalRepository, M private byte[] requestAsAuthenticatedOrAnonymous(MavenRepository repo, String uriString) throws HttpSenderResponseException, IOException { try { HttpSender.Request.Builder request = httpSender.get(uriString) - .withConnectTimeout(repo.getConnectTimeout()) - .withReadTimeout(repo.getReadTimeout()); + .withConnectTimeout(repo.getTimeout()) + .withReadTimeout(repo.getTimeout()); return sendRequest(applyAuthenticationToRequest(repo, request).build()); } catch (HttpSenderResponseException e) { if (hasCredentials(repo) && e.isClientSideException()) { diff --git a/rewrite-maven/src/main/java/org/openrewrite/maven/internal/RawPom.java b/rewrite-maven/src/main/java/org/openrewrite/maven/internal/RawPom.java index 0e7dfba40af..f8e45e2e814 100755 --- a/rewrite-maven/src/main/java/org/openrewrite/maven/internal/RawPom.java +++ b/rewrite-maven/src/main/java/org/openrewrite/maven/internal/RawPom.java @@ -439,7 +439,7 @@ private List mapRepositories(@Nullable RawRepositories rawRepos pomRepositories.add(new MavenRepository(r.getId(), r.getUrl(), r.getReleases() == null ? null : r.getReleases().getEnabled(), r.getSnapshots() == null ? null : r.getSnapshots().getEnabled(), - false, null, null, null, null, null)); + false, null, null, null, null)); } } diff --git a/rewrite-maven/src/main/java/org/openrewrite/maven/tree/MavenRepository.java b/rewrite-maven/src/main/java/org/openrewrite/maven/tree/MavenRepository.java index 6264efa2de5..0057ad96638 100644 --- a/rewrite-maven/src/main/java/org/openrewrite/maven/tree/MavenRepository.java +++ b/rewrite-maven/src/main/java/org/openrewrite/maven/tree/MavenRepository.java @@ -39,9 +39,9 @@ @RequiredArgsConstructor public class MavenRepository implements Serializable { - public static final MavenRepository MAVEN_LOCAL_USER_NEUTRAL = new MavenRepository("local", new File("~/.m2/repository").toString(), "true", "true", true, null, null, null, null, false); - public static final MavenRepository MAVEN_LOCAL_DEFAULT = new MavenRepository("local", Paths.get(System.getProperty("user.home"), ".m2", "repository").toUri().toString(), "true", "true", true, null, null, null, null, false); - public static final MavenRepository MAVEN_CENTRAL = new MavenRepository("central", "https://repo.maven.apache.org/maven2", "true", "false", true, null, null, null, null, true); + public static final MavenRepository MAVEN_LOCAL_USER_NEUTRAL = new MavenRepository("local", new File("~/.m2/repository").toString(), "true", "true", true, null, null, null, false); + public static final MavenRepository MAVEN_LOCAL_DEFAULT = new MavenRepository("local", Paths.get(System.getProperty("user.home"), ".m2", "repository").toUri().toString(), "true", "true", true, null, null, null, false); + public static final MavenRepository MAVEN_CENTRAL = new MavenRepository("central", "https://repo.maven.apache.org/maven2", "true", "false", true, null, null, null, true); @EqualsAndHashCode.Include @With @@ -83,11 +83,7 @@ public class MavenRepository implements Serializable { @With @Nullable - Duration connectTimeout; - - @With - @Nullable - Duration readTimeout; + Duration timeout; @Nullable @NonFinal @@ -96,7 +92,7 @@ public class MavenRepository implements Serializable { /** * Constructor required by {@link org.openrewrite.maven.tree.OpenRewriteModelSerializableTest}. * - * @deprecated Use {@link #MavenRepository(String, String, String, String, boolean, String, String, Duration, Duration, Boolean)} + * @deprecated Use {@link #MavenRepository(String, String, String, String, boolean, String, String, Duration, Boolean)} */ @Deprecated @JsonIgnore @@ -104,13 +100,13 @@ public MavenRepository( @Nullable String id, String uri, @Nullable String releases, @Nullable String snapshots, @Nullable String username, @Nullable String password ) { - this(id, uri, releases, snapshots, false, username, password, null, null, null); + this(id, uri, releases, snapshots, false, username, password, null, null); } /** * Constructor required by {@link org.openrewrite.gradle.marker.GradleProject}. * - * @deprecated Use {@link #MavenRepository(String, String, String, String, boolean, String, String, Duration, Duration, Boolean)} + * @deprecated Use {@link #MavenRepository(String, String, String, String, boolean, String, String, Duration, Boolean)} */ @Deprecated @JsonIgnore @@ -118,14 +114,13 @@ public MavenRepository( @Nullable String id, String uri, @Nullable String releases, @Nullable String snapshots, boolean knownToExist, @Nullable String username, @Nullable String password, @Nullable Boolean deriveMetadataIfMissing ) { - this(id, uri, releases, snapshots, knownToExist, username, password, null, null, deriveMetadataIfMissing); + this(id, uri, releases, snapshots, knownToExist, username, password, null, deriveMetadataIfMissing); } @JsonIgnore public MavenRepository( @Nullable String id, String uri, @Nullable String releases, @Nullable String snapshots, boolean knownToExist, - @Nullable String username, @Nullable String password, @Nullable Duration connectTimeout, - @Nullable Duration readTimeout, @Nullable Boolean deriveMetadataIfMissing + @Nullable String username, @Nullable String password, @Nullable Duration timeout, @Nullable Boolean deriveMetadataIfMissing ) { this.id = id; this.uri = uri; @@ -134,8 +129,7 @@ public MavenRepository( this.knownToExist = knownToExist; this.username = username; this.password = password; - this.connectTimeout = connectTimeout; - this.readTimeout = readTimeout; + this.timeout = timeout; this.deriveMetadataIfMissing = deriveMetadataIfMissing; } @@ -157,14 +151,13 @@ public static class Builder { String username; String password; Boolean deriveMetadataIfMissing; - Duration connectTimeout; - Duration readTimeout; + Duration timeout; private Builder() { } public MavenRepository build() { - return new MavenRepository(id, uri, releases, snapshots, knownToExist, username, password, connectTimeout, readTimeout, deriveMetadataIfMissing); + return new MavenRepository(id, uri, releases, snapshots, knownToExist, username, password, timeout, deriveMetadataIfMissing); } public Builder releases(boolean releases) { @@ -207,13 +200,8 @@ public Builder password(String password) { return this; } - public Builder connectTimeout(Duration connectTimeout) { - this.connectTimeout = connectTimeout; - return this; - } - - public Builder readTimeout(Duration readTimeout) { - this.readTimeout = readTimeout; + public Builder timeout(Duration timeout) { + this.timeout = timeout; return this; } diff --git a/rewrite-maven/src/main/java/org/openrewrite/maven/tree/MavenRepositoryMirror.java b/rewrite-maven/src/main/java/org/openrewrite/maven/tree/MavenRepositoryMirror.java index 8a15b57b063..2a8eeed6980 100644 --- a/rewrite-maven/src/main/java/org/openrewrite/maven/tree/MavenRepositoryMirror.java +++ b/rewrite-maven/src/main/java/org/openrewrite/maven/tree/MavenRepositoryMirror.java @@ -130,8 +130,7 @@ public MavenRepository apply(MavenRepository repo) { .withSnapshots(!Boolean.FALSE.equals(snapshots) ? "true" : "false") // Since the URL has likely changed we cannot assume that the new repository is known to exist .withKnownToExist(false) - .withConnectTimeout(repo.getConnectTimeout()) - .withReadTimeout(repo.getReadTimeout()); + .withTimeout(repo.getTimeout()); } return repo; } diff --git a/rewrite-maven/src/main/java/org/openrewrite/maven/tree/ResolvedPom.java b/rewrite-maven/src/main/java/org/openrewrite/maven/tree/ResolvedPom.java index 008da3f933b..e970abd798f 100644 --- a/rewrite-maven/src/main/java/org/openrewrite/maven/tree/ResolvedPom.java +++ b/rewrite-maven/src/main/java/org/openrewrite/maven/tree/ResolvedPom.java @@ -736,8 +736,7 @@ private void mergeRepositories(List incomingRepositories) { incomingRepository.isKnownToExist(), incomingRepository.getUsername(), incomingRepository.getPassword(), - incomingRepository.getConnectTimeout(), - incomingRepository.getReadTimeout(), + incomingRepository.getTimeout(), incomingRepository.getDeriveMetadataIfMissing() );