Skip to content

Commit b868ef1

Browse files
committed
fabric: accept shared fetch/netty arguments
1 parent f6d6c9f commit b868ef1

File tree

6 files changed

+26
-16
lines changed

6 files changed

+26
-16
lines changed

src/main/java/me/itzg/helpers/curseforge/CurseForgeInstaller.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -962,7 +962,7 @@ private void prepareFabric(String minecraftVersion, String loaderVersion) {
962962
final FabricLauncherInstaller installer = new FabricLauncherInstaller(outputDir)
963963
.setResultsFile(resultsFile)
964964
.setForceReinstall(forceReinstallModloader);
965-
installer.installUsingVersions(minecraftVersion, loaderVersion, null);
965+
installer.installUsingVersions(sharedFetchOptions, minecraftVersion, loaderVersion, null);
966966
}
967967

968968
private void prepareForge(SharedFetch sharedFetch, String minecraftVersion, String loaderVersion) {

src/main/java/me/itzg/helpers/fabric/FabricLauncherInstaller.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,11 @@ public class FabricLauncherInstaller {
4343
private boolean forceReinstall;
4444

4545
public void installUsingVersions(
46-
@NonNull String minecraftVersion,
46+
Options sharedFetchOptions, @NonNull String minecraftVersion,
4747
@Nullable String loaderVersion,
4848
@Nullable String installerVersion
4949
) {
50-
try (SharedFetch sharedFetch = sharedFetch("fabric", Options.builder().build())) {
50+
try (SharedFetch sharedFetch = sharedFetch("fabric", sharedFetchOptions)) {
5151
final FabricMetaClient fabricMetaClient = new FabricMetaClient(sharedFetch, fabricMetaBaseUrl);
5252

5353
fabricMetaClient.resolveMinecraftVersion(minecraftVersion)
@@ -156,9 +156,9 @@ private Mono<FabricManifest> finalizeResultsFileAndManifest(FabricManifest prevM
156156
return Mono.just(newManifest);
157157
}
158158

159-
public void installUsingUri(URI loaderUri) throws IOException {
159+
public void installUsingUri(Options sharedFetchOptions, URI loaderUri) throws IOException {
160160
final Path launcherPath;
161-
try (SharedFetch sharedFetch = sharedFetch("fabric", Options.builder().build())) {
161+
try (SharedFetch sharedFetch = sharedFetch("fabric", sharedFetchOptions)) {
162162
launcherPath = sharedFetch.fetch(loaderUri)
163163
.toDirectory(outputDir)
164164
.skipUpToDate(true)

src/main/java/me/itzg/helpers/fabric/InstallFabricLoaderCommand.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import java.util.regex.Pattern;
77
import lombok.extern.slf4j.Slf4j;
88
import me.itzg.helpers.files.ResultsFileWriter;
9+
import me.itzg.helpers.http.SharedFetchArgs;
910
import picocli.CommandLine.ArgGroup;
1011
import picocli.CommandLine.Command;
1112
import picocli.CommandLine.ExitCode;
@@ -30,6 +31,9 @@ public class InstallFabricLoaderCommand implements Callable<Integer> {
3031
@ArgGroup
3132
OriginOptions originOptions = new OriginOptions();
3233

34+
@ArgGroup(exclusive = false)
35+
SharedFetchArgs sharedFetchArgs = new SharedFetchArgs();
36+
3337
static class OriginOptions {
3438
@ArgGroup(exclusive = false)
3539
VersionOptions versionOptions = new VersionOptions();
@@ -84,13 +88,14 @@ public Integer call() throws Exception {
8488
.setResultsFile(resultsFile);
8589

8690
if (originOptions.fromUri != null) {
87-
installer.installUsingUri(originOptions.fromUri);
91+
installer.installUsingUri(sharedFetchArgs.options(), originOptions.fromUri);
8892
}
8993
else if (originOptions.launcherFile != null) {
9094
installer.installUsingLocalFile(originOptions.launcherFile);
9195
}
9296
else {
9397
installer.installUsingVersions(
98+
sharedFetchArgs.options(),
9499
originOptions.versionOptions.minecraftVersion,
95100
originOptions.versionOptions.loaderVersion,
96101
originOptions.versionOptions.installerVersion

src/main/java/me/itzg/helpers/http/SharedFetchArgs.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public void setTlsHandshakeTimeout(Duration timeout) {
3434
optionsBuilder.tlsHandshakeTimeout(timeout);
3535
}
3636

37-
@Option(names = "--connection-pool-max-idle-timeout", defaultValue = "${env:FETCH_CONNECTION_POOL_MAX_IDLE_TIMEOUT}",
37+
@Option(names = "--connection-pool-max-idle-timeout", defaultValue = "${env:FETCH_CONNECTION_POOL_MAX_IDLE_TIMEOUT:-PT15S}",
3838
paramLabel = "DURATION"
3939
)
4040
public void setConnectionPoolMaxIdleTimeout(Duration timeout) {

src/main/java/me/itzg/helpers/modrinth/ModrinthPackInstaller.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,7 @@ private void prepareFabric(SharedFetch sharedFetch, String minecraftVersion, Str
254254
new FabricLauncherInstaller(this.outputDirectory)
255255
.setResultsFile(this.resultsFile)
256256
.installUsingVersions(
257-
minecraftVersion,
257+
sharedFetchOpts, minecraftVersion,
258258
fabricVersion,
259259
null
260260
);

src/test/java/me/itzg/helpers/fabric/FabricLauncherInstallerTest.java

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
import java.nio.file.Paths;
1515
import java.util.Collections;
1616
import me.itzg.helpers.files.Manifests;
17+
import me.itzg.helpers.http.SharedFetch.Options;
1718
import org.junit.jupiter.api.Test;
1819
import org.junit.jupiter.api.condition.EnabledIfSystemProperty;
1920
import org.junit.jupiter.api.io.TempDir;
@@ -58,7 +59,7 @@ void testInstallUsingVersions_onlyGameVersion(WireMockRuntimeInfo wmRuntimeInfo)
5859
.setResultsFile(resultsFile);
5960
installer.setFabricMetaBaseUrl(wmRuntimeInfo.getHttpBaseUrl());
6061

61-
installer.installUsingVersions("1.19.3", null, null);
62+
installer.installUsingVersions(buildSharedFetchOptions(), "1.19.3", null, null);
6263

6364
final Path expectedLauncherPath = tempDir.resolve("fabric-server-mc.1.19.3-loader.0.14.12-launcher.0.11.1.jar");
6465
assertThat(expectedLauncherPath)
@@ -84,6 +85,10 @@ void testInstallUsingVersions_onlyGameVersion(WireMockRuntimeInfo wmRuntimeInfo)
8485
.at("/files").isArrayContaining("fabric-server-mc.1.19.3-loader.0.14.12-launcher.0.11.1.jar");
8586
}
8687

88+
private Options buildSharedFetchOptions() {
89+
return Options.builder().build();
90+
}
91+
8792
@Test
8893
void testWithProvidedUri(WireMockRuntimeInfo wmRuntimeInfo) throws IOException {
8994
stubFor(
@@ -104,7 +109,7 @@ void testWithProvidedUri(WireMockRuntimeInfo wmRuntimeInfo) throws IOException {
104109
.setResultsFile(expectedResultsPath);
105110
final URI loaderUri = URI.create(wmRuntimeInfo.getHttpBaseUrl() + "/fabric-launcher.jar");
106111

107-
installer.installUsingUri(loaderUri);
112+
installer.installUsingUri(Options.builder().build(), loaderUri);
108113

109114
final Path expectedLauncherPath = tempDir.resolve("fabric-launcher.jar");
110115
assertThat(expectedLauncherPath)
@@ -139,7 +144,7 @@ void testWithProvidedUri_contentDisposition(WireMockRuntimeInfo wmRuntimeInfo) t
139144

140145
final FabricLauncherInstaller installer = new FabricLauncherInstaller(tempDir);
141146
installer.installUsingUri(
142-
URI.create(wmRuntimeInfo.getHttpBaseUrl() + "/server")
147+
Options.builder().build(), URI.create(wmRuntimeInfo.getHttpBaseUrl() + "/server")
143148
);
144149

145150
final Path expectedLauncherPath = tempDir.resolve("fabric-server-mc.1.19.3-loader.0.14.12-launcher.0.11.1.jar");
@@ -178,7 +183,7 @@ void testUpgradeFromVersionToVersion(WireMockRuntimeInfo wmRuntimeInfo) {
178183
installer.setFabricMetaBaseUrl(wmRuntimeInfo.getHttpBaseUrl());
179184

180185
installer.installUsingVersions(
181-
"1.19.2", null, null
186+
buildSharedFetchOptions(), "1.19.2", null, null
182187
);
183188

184189
final Path expectedLauncher192 = tempDir.resolve("fabric-server-mc.1.19.2-loader.0.14.12-launcher.0.11.1.jar");
@@ -189,7 +194,7 @@ void testUpgradeFromVersionToVersion(WireMockRuntimeInfo wmRuntimeInfo) {
189194
// Now upgrade from 1.19.2 to 1.19.3
190195

191196
installer.installUsingVersions(
192-
"1.19.3", null, null
197+
buildSharedFetchOptions(), "1.19.3", null, null
193198
);
194199

195200
final Path expectedLauncher193 = tempDir.resolve("fabric-server-mc.1.19.3-loader.0.14.12-launcher.0.11.1.jar");
@@ -212,7 +217,7 @@ void testNoNetworkUsageWhenVersionMatches(WireMockRuntimeInfo wmRuntimeInfo) {
212217
installer.setFabricMetaBaseUrl(wmRuntimeInfo.getHttpBaseUrl());
213218

214219
installer.installUsingVersions(
215-
"1.19.2", null, null
220+
buildSharedFetchOptions(), "1.19.2", null, null
216221
);
217222

218223
wm.verifyThat(
@@ -234,7 +239,7 @@ void testNoNetworkUsageWhenVersionMatches(WireMockRuntimeInfo wmRuntimeInfo) {
234239
wm.resetRequests();
235240

236241
installer.installUsingVersions(
237-
"1.19.2", "0.14.12", "0.11.1"
242+
buildSharedFetchOptions(), "1.19.2", "0.14.12", "0.11.1"
238243
);
239244

240245
assertThat(expectedLauncher192)
@@ -253,6 +258,6 @@ void forRecordingVersionDiscovery() {
253258
.setResultsFile(resultsFile);
254259
installer.setFabricMetaBaseUrl("http://localhost:8080");
255260

256-
installer.installUsingVersions("1.19.3", null, null);
261+
installer.installUsingVersions(buildSharedFetchOptions(), "1.19.3", null, null);
257262
}
258263
}

0 commit comments

Comments
 (0)