dev/0.11
modmuss50 2020-06-02 14:29:20 +01:00
parent 7e3c36159a
commit fdbdcc4bbf
1 changed files with 9 additions and 1 deletions

View File

@ -28,6 +28,7 @@ import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.net.URL; import java.net.URL;
import org.gradle.api.GradleException;
import org.zeroturnaround.zip.ZipUtil; import org.zeroturnaround.zip.ZipUtil;
import org.gradle.api.Project; import org.gradle.api.Project;
@ -39,6 +40,7 @@ public class MinecraftNativesProvider {
public static void provide(MinecraftProvider minecraftProvider, Project project) throws IOException { public static void provide(MinecraftProvider minecraftProvider, Project project) throws IOException {
LoomGradleExtension extension = project.getExtensions().getByType(LoomGradleExtension.class); LoomGradleExtension extension = project.getExtensions().getByType(LoomGradleExtension.class);
MinecraftVersionInfo versionInfo = minecraftProvider.getVersionInfo(); MinecraftVersionInfo versionInfo = minecraftProvider.getVersionInfo();
boolean offline = project.getGradle().getStartParameter().isOffline();
File nativesDir = extension.getNativesDirectory(); File nativesDir = extension.getNativesDirectory();
File jarStore = extension.getNativesJarStore(); File jarStore = extension.getNativesJarStore();
@ -47,7 +49,13 @@ public class MinecraftNativesProvider {
File libJarFile = library.getFile(jarStore); File libJarFile = library.getFile(jarStore);
if (library.allowed() && library.isNative() && libJarFile != null) { if (library.allowed() && library.isNative() && libJarFile != null) {
if (!offline) {
DownloadUtil.downloadIfChanged(new URL(library.getURL()), libJarFile, project.getLogger()); 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 //TODO possibly find a way to prevent needing to re-extract after each run, doesnt seem too slow
ZipUtil.unpack(libJarFile, nativesDir); ZipUtil.unpack(libJarFile, nativesDir);