Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -962,7 +962,7 @@ private void prepareFabric(String minecraftVersion, String loaderVersion) {
final FabricLauncherInstaller installer = new FabricLauncherInstaller(outputDir)
.setResultsFile(resultsFile)
.setForceReinstall(forceReinstallModloader);
installer.installUsingVersions(minecraftVersion, loaderVersion, null);
installer.installUsingVersions(sharedFetchOptions, minecraftVersion, loaderVersion, null);
}

private void prepareForge(SharedFetch sharedFetch, String minecraftVersion, String loaderVersion) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,11 @@ public class FabricLauncherInstaller {
private boolean forceReinstall;

public void installUsingVersions(
@NonNull String minecraftVersion,
Options sharedFetchOptions, @NonNull String minecraftVersion,
@Nullable String loaderVersion,
@Nullable String installerVersion
) {
try (SharedFetch sharedFetch = sharedFetch("fabric", Options.builder().build())) {
try (SharedFetch sharedFetch = sharedFetch("fabric", sharedFetchOptions)) {
final FabricMetaClient fabricMetaClient = new FabricMetaClient(sharedFetch, fabricMetaBaseUrl);

fabricMetaClient.resolveMinecraftVersion(minecraftVersion)
Expand Down Expand Up @@ -156,9 +156,9 @@ private Mono<FabricManifest> finalizeResultsFileAndManifest(FabricManifest prevM
return Mono.just(newManifest);
}

public void installUsingUri(URI loaderUri) throws IOException {
public void installUsingUri(Options sharedFetchOptions, URI loaderUri) throws IOException {
final Path launcherPath;
try (SharedFetch sharedFetch = sharedFetch("fabric", Options.builder().build())) {
try (SharedFetch sharedFetch = sharedFetch("fabric", sharedFetchOptions)) {
launcherPath = sharedFetch.fetch(loaderUri)
.toDirectory(outputDir)
.skipUpToDate(true)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import java.util.regex.Pattern;
import lombok.extern.slf4j.Slf4j;
import me.itzg.helpers.files.ResultsFileWriter;
import me.itzg.helpers.http.SharedFetchArgs;
import picocli.CommandLine.ArgGroup;
import picocli.CommandLine.Command;
import picocli.CommandLine.ExitCode;
Expand All @@ -30,6 +31,9 @@ public class InstallFabricLoaderCommand implements Callable<Integer> {
@ArgGroup
OriginOptions originOptions = new OriginOptions();

@ArgGroup(exclusive = false)
SharedFetchArgs sharedFetchArgs = new SharedFetchArgs();

static class OriginOptions {
@ArgGroup(exclusive = false)
VersionOptions versionOptions = new VersionOptions();
Expand Down Expand Up @@ -84,13 +88,14 @@ public Integer call() throws Exception {
.setResultsFile(resultsFile);

if (originOptions.fromUri != null) {
installer.installUsingUri(originOptions.fromUri);
installer.installUsingUri(sharedFetchArgs.options(), originOptions.fromUri);
}
else if (originOptions.launcherFile != null) {
installer.installUsingLocalFile(originOptions.launcherFile);
}
else {
installer.installUsingVersions(
sharedFetchArgs.options(),
originOptions.versionOptions.minecraftVersion,
originOptions.versionOptions.loaderVersion,
originOptions.versionOptions.installerVersion
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/me/itzg/helpers/http/SharedFetchArgs.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public void setTlsHandshakeTimeout(Duration timeout) {
optionsBuilder.tlsHandshakeTimeout(timeout);
}

@Option(names = "--connection-pool-max-idle-timeout", defaultValue = "${env:FETCH_CONNECTION_POOL_MAX_IDLE_TIMEOUT}",
@Option(names = "--connection-pool-max-idle-timeout", defaultValue = "${env:FETCH_CONNECTION_POOL_MAX_IDLE_TIMEOUT:-PT15S}",
paramLabel = "DURATION"
)
public void setConnectionPoolMaxIdleTimeout(Duration timeout) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ private void prepareFabric(SharedFetch sharedFetch, String minecraftVersion, Str
new FabricLauncherInstaller(this.outputDirectory)
.setResultsFile(this.resultsFile)
.installUsingVersions(
minecraftVersion,
sharedFetchOpts, minecraftVersion,
fabricVersion,
null
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import java.nio.file.Paths;
import java.util.Collections;
import me.itzg.helpers.files.Manifests;
import me.itzg.helpers.http.SharedFetch.Options;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.condition.EnabledIfSystemProperty;
import org.junit.jupiter.api.io.TempDir;
Expand Down Expand Up @@ -58,7 +59,7 @@ void testInstallUsingVersions_onlyGameVersion(WireMockRuntimeInfo wmRuntimeInfo)
.setResultsFile(resultsFile);
installer.setFabricMetaBaseUrl(wmRuntimeInfo.getHttpBaseUrl());

installer.installUsingVersions("1.19.3", null, null);
installer.installUsingVersions(buildSharedFetchOptions(), "1.19.3", null, null);

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

private Options buildSharedFetchOptions() {
return Options.builder().build();
}

@Test
void testWithProvidedUri(WireMockRuntimeInfo wmRuntimeInfo) throws IOException {
stubFor(
Expand All @@ -104,7 +109,7 @@ void testWithProvidedUri(WireMockRuntimeInfo wmRuntimeInfo) throws IOException {
.setResultsFile(expectedResultsPath);
final URI loaderUri = URI.create(wmRuntimeInfo.getHttpBaseUrl() + "/fabric-launcher.jar");

installer.installUsingUri(loaderUri);
installer.installUsingUri(Options.builder().build(), loaderUri);

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

final FabricLauncherInstaller installer = new FabricLauncherInstaller(tempDir);
installer.installUsingUri(
URI.create(wmRuntimeInfo.getHttpBaseUrl() + "/server")
Options.builder().build(), URI.create(wmRuntimeInfo.getHttpBaseUrl() + "/server")
);

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

installer.installUsingVersions(
"1.19.2", null, null
buildSharedFetchOptions(), "1.19.2", null, null
);

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

installer.installUsingVersions(
"1.19.3", null, null
buildSharedFetchOptions(), "1.19.3", null, null
);

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

installer.installUsingVersions(
"1.19.2", null, null
buildSharedFetchOptions(), "1.19.2", null, null
);

wm.verifyThat(
Expand All @@ -234,7 +239,7 @@ void testNoNetworkUsageWhenVersionMatches(WireMockRuntimeInfo wmRuntimeInfo) {
wm.resetRequests();

installer.installUsingVersions(
"1.19.2", "0.14.12", "0.11.1"
buildSharedFetchOptions(), "1.19.2", "0.14.12", "0.11.1"
);

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

installer.installUsingVersions("1.19.3", null, null);
installer.installUsingVersions(buildSharedFetchOptions(), "1.19.3", null, null);
}
}