Skip to content

Commit

Permalink
Further cascading changes
Browse files Browse the repository at this point in the history
  • Loading branch information
timtebeek committed Jul 5, 2024
1 parent 893b2eb commit 3141aae
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 37 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -278,8 +278,7 @@ private List<MavenRepository> mapRepositories(MavenSettings settings, List<Strin
knownRepo.isKnownToExist() && knownRepo.getUri().equals(repo.getUrl()),
knownRepo.getUsername(),
knownRepo.getPassword(),
knownRepo.getConnectTimeout(),
knownRepo.getReadTimeout(),
knownRepo.getTimeout(),
knownRepo.getDeriveMetadataIfMissing()
);
} else {
Expand All @@ -290,7 +289,6 @@ private List<MavenRepository> mapRepositories(MavenSettings settings, List<Strin
repo.getSnapshots() == null ? null : repo.getSnapshots().getEnabled(),
null,
null,
null,
null
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,6 @@ public Xml visitDocument(Xml.Document document, P p) {
t.getChild("snapshots").flatMap(s -> s.getChildValue("enabled")).orElse(null),
null,
null,
null,
null
)).collect(Collectors.toList()));
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -439,7 +439,7 @@ private List<MavenRepository> 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));
}

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -83,11 +83,7 @@ public class MavenRepository implements Serializable {

@With
@Nullable
Duration connectTimeout;

@With
@Nullable
Duration readTimeout;
Duration timeout;

@Nullable
@NonFinal
Expand All @@ -96,36 +92,35 @@ 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
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
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;
Expand All @@ -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;
}

Expand All @@ -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) {
Expand Down Expand Up @@ -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;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -736,8 +736,7 @@ private void mergeRepositories(List<MavenRepository> incomingRepositories) {
incomingRepository.isKnownToExist(),
incomingRepository.getUsername(),
incomingRepository.getPassword(),
incomingRepository.getConnectTimeout(),
incomingRepository.getReadTimeout(),
incomingRepository.getTimeout(),
incomingRepository.getDeriveMetadataIfMissing()
);

Expand Down

0 comments on commit 3141aae

Please sign in to comment.