mirror of
https://github.com/architectury/architectury-loom.git
synced 2026-04-01 21:17:46 -05:00
Multi-thread native unpacking.
This commit is contained in:
@@ -28,6 +28,7 @@ import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.net.URL;
|
||||
|
||||
import com.google.common.base.Stopwatch;
|
||||
import org.gradle.api.GradleException;
|
||||
import org.gradle.api.Project;
|
||||
import org.zeroturnaround.zip.ZipUtil;
|
||||
@@ -35,6 +36,7 @@ import org.zeroturnaround.zip.ZipUtil;
|
||||
import net.fabricmc.loom.LoomGradleExtension;
|
||||
import net.fabricmc.loom.configuration.providers.MinecraftProvider;
|
||||
import net.fabricmc.loom.util.DownloadUtil;
|
||||
import net.fabricmc.loom.util.ThreadingUtils;
|
||||
|
||||
public class MinecraftNativesProvider {
|
||||
public static void provide(MinecraftProvider minecraftProvider, Project project) throws IOException {
|
||||
@@ -53,7 +55,9 @@ public class MinecraftNativesProvider {
|
||||
return;
|
||||
}
|
||||
|
||||
for (MinecraftVersionInfo.Library library : versionInfo.libraries) {
|
||||
Stopwatch stopwatch = Stopwatch.createStarted();
|
||||
|
||||
ThreadingUtils.run(versionInfo.libraries, library -> {
|
||||
File libJarFile = library.getFile(jarStore);
|
||||
|
||||
if (library.allowed() && library.isNative() && libJarFile != null) {
|
||||
@@ -68,6 +72,8 @@ public class MinecraftNativesProvider {
|
||||
// TODO possibly find a way to prevent needing to re-extract after each run, doesnt seem too slow
|
||||
ZipUtil.unpack(libJarFile, nativesDir);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
project.getLogger().info("Took " + stopwatch.stop() + " to provide " + versionInfo.libraries.size() + " natives.");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -44,8 +44,9 @@ public class Checksum {
|
||||
|
||||
try {
|
||||
HashCode hash = Files.asByteSource(file).hash(Hashing.sha1());
|
||||
log.debug("Checksum check: '" + hash.toString() + "' == '" + checksum + "'?");
|
||||
return hash.toString().equals(checksum);
|
||||
String hashString = hash.toString();
|
||||
log.debug("Checksum check: '" + hashString + "' == '" + checksum + "'?");
|
||||
return hashString.equals(checksum);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
@@ -46,8 +46,8 @@ public class DownloadUtil {
|
||||
* @param logger The logger to print everything to, typically from {@link Project#getLogger()}
|
||||
* @throws IOException If an exception occurs during the process
|
||||
*/
|
||||
public static void downloadIfChanged(URL from, File to, Logger logger) throws IOException {
|
||||
downloadIfChanged(from, to, logger, false);
|
||||
public static boolean downloadIfChanged(URL from, File to, Logger logger) throws IOException {
|
||||
return downloadIfChanged(from, to, logger, false);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -59,7 +59,7 @@ public class DownloadUtil {
|
||||
* @param quiet Whether to only print warnings (when <code>true</code>) or everything
|
||||
* @throws IOException If an exception occurs during the process
|
||||
*/
|
||||
public static void downloadIfChanged(URL from, File to, Logger logger, boolean quiet) throws IOException {
|
||||
public static boolean downloadIfChanged(URL from, File to, Logger logger, boolean quiet) throws IOException {
|
||||
HttpURLConnection connection = (HttpURLConnection) from.openConnection();
|
||||
|
||||
if (LoomGradlePlugin.refreshDeps) {
|
||||
@@ -99,7 +99,7 @@ public class DownloadUtil {
|
||||
logger.info("'{}' Not Modified, skipping.", to);
|
||||
}
|
||||
|
||||
return; //What we've got is already fine
|
||||
return false; //What we've got is already fine
|
||||
}
|
||||
|
||||
long contentLength = connection.getContentLengthLong();
|
||||
@@ -131,6 +131,8 @@ public class DownloadUtil {
|
||||
|
||||
saveETag(to, eTag, logger);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user