Some trivial performance improvements

dev/0.11
modmuss50 2020-04-27 14:08:37 +01:00
parent 93820f0d65
commit 76087d4d3d
2 changed files with 12 additions and 18 deletions

View File

@ -40,7 +40,6 @@ import org.gradle.api.GradleException;
import org.gradle.api.Project; import org.gradle.api.Project;
import org.gradle.api.logging.Logger; import org.gradle.api.logging.Logger;
import net.fabricmc.loom.util.Checksum;
import net.fabricmc.loom.util.Constants; import net.fabricmc.loom.util.Constants;
import net.fabricmc.loom.util.DependencyProvider; import net.fabricmc.loom.util.DependencyProvider;
import net.fabricmc.loom.util.DownloadUtil; import net.fabricmc.loom.util.DownloadUtil;
@ -172,16 +171,9 @@ public class MinecraftProvider extends DependencyProvider {
} }
private void downloadJars(Logger logger) throws IOException { private void downloadJars(Logger logger) throws IOException {
if (!minecraftClientJar.exists() || (!Checksum.equals(minecraftClientJar, versionInfo.downloads.get("client").sha1) && StaticPathWatcher.INSTANCE.hasFileChanged(minecraftClientJar.toPath()))) {
logger.debug("Downloading Minecraft {} client jar", minecraftVersion);
DownloadUtil.downloadIfChanged(new URL(versionInfo.downloads.get("client").url), minecraftClientJar, logger); DownloadUtil.downloadIfChanged(new URL(versionInfo.downloads.get("client").url), minecraftClientJar, logger);
}
if (!minecraftServerJar.exists() || (!Checksum.equals(minecraftServerJar, versionInfo.downloads.get("server").sha1) && StaticPathWatcher.INSTANCE.hasFileChanged(minecraftServerJar.toPath()))) {
logger.debug("Downloading Minecraft {} server jar", minecraftVersion);
DownloadUtil.downloadIfChanged(new URL(versionInfo.downloads.get("server").url), minecraftServerJar, logger); DownloadUtil.downloadIfChanged(new URL(versionInfo.downloads.get("server").url), minecraftServerJar, logger);
} }
}
private void mergeJars(Logger logger) throws IOException { private void mergeJars(Logger logger) throws IOException {
logger.lifecycle(":merging jars"); logger.lifecycle(":merging jars");

View File

@ -26,8 +26,8 @@ package net.fabricmc.loom.util;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.function.Consumer; import java.util.function.Consumer;
import java.util.zip.ZipFile;
import org.gradle.api.Project; import org.gradle.api.Project;
import org.gradle.api.artifacts.Configuration; import org.gradle.api.artifacts.Configuration;
@ -98,15 +98,17 @@ public class ModCompileRemapper {
*/ */
private static boolean isFabricMod(Project project, Logger logger, ResolvedArtifact artifact, String notation) { private static boolean isFabricMod(Project project, Logger logger, ResolvedArtifact artifact, String notation) {
File input = artifact.getFile(); File input = artifact.getFile();
AtomicBoolean fabricMod = new AtomicBoolean(false);
project.zipTree(input).visit(f -> { try (ZipFile zipFile = new ZipFile(input)) {
if (f.getName().endsWith("fabric.mod.json")) { if (zipFile.getEntry("fabric.mod.json") != null) {
logger.info("Found Fabric mod in modCompile: {}", notation); logger.info("Found Fabric mod in modCompile: {}", notation);
fabricMod.set(true); return true;
f.stopVisiting(); }
return false;
} catch (IOException e) {
return false;
} }
});
return fabricMod.get();
} }
private static void addToRegularCompile(Project project, Configuration regularCompile, String notation) { private static void addToRegularCompile(Project project, Configuration regularCompile, String notation) {