From fdbdcc4bbfd0282191b3e82dd8042a06a9a85a72 Mon Sep 17 00:00:00 2001 From: modmuss50 Date: Tue, 2 Jun 2020 14:29:20 +0100 Subject: [PATCH] Fix #177 --- .../loom/providers/MinecraftNativesProvider.java | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/main/java/net/fabricmc/loom/providers/MinecraftNativesProvider.java b/src/main/java/net/fabricmc/loom/providers/MinecraftNativesProvider.java index fbd032d..37376fd 100644 --- a/src/main/java/net/fabricmc/loom/providers/MinecraftNativesProvider.java +++ b/src/main/java/net/fabricmc/loom/providers/MinecraftNativesProvider.java @@ -28,6 +28,7 @@ import java.io.File; import java.io.IOException; import java.net.URL; +import org.gradle.api.GradleException; import org.zeroturnaround.zip.ZipUtil; import org.gradle.api.Project; @@ -39,6 +40,7 @@ public class MinecraftNativesProvider { public static void provide(MinecraftProvider minecraftProvider, Project project) throws IOException { LoomGradleExtension extension = project.getExtensions().getByType(LoomGradleExtension.class); MinecraftVersionInfo versionInfo = minecraftProvider.getVersionInfo(); + boolean offline = project.getGradle().getStartParameter().isOffline(); File nativesDir = extension.getNativesDirectory(); File jarStore = extension.getNativesJarStore(); @@ -47,7 +49,13 @@ public class MinecraftNativesProvider { File libJarFile = library.getFile(jarStore); if (library.allowed() && library.isNative() && libJarFile != null) { - DownloadUtil.downloadIfChanged(new URL(library.getURL()), libJarFile, project.getLogger()); + if (!offline) { + DownloadUtil.downloadIfChanged(new URL(library.getURL()), libJarFile, project.getLogger()); + } + + if (!libJarFile.exists()) { + throw new GradleException("Native jar not found at " + libJarFile.getAbsolutePath()); + } //TODO possibly find a way to prevent needing to re-extract after each run, doesnt seem too slow ZipUtil.unpack(libJarFile, nativesDir);