Centralise refreshDeps variable.

Makes it easier to hack it to always enable for profiling.
dev/0.11
modmuss50 2021-01-19 21:58:39 +00:00
parent a436eb7690
commit 58e94f2db3
4 changed files with 8 additions and 7 deletions

View File

@ -45,6 +45,7 @@ import org.gradle.jvm.JvmLibrary;
import org.gradle.language.base.artifact.SourcesArtifact; import org.gradle.language.base.artifact.SourcesArtifact;
import net.fabricmc.loom.LoomGradleExtension; import net.fabricmc.loom.LoomGradleExtension;
import net.fabricmc.loom.LoomGradlePlugin;
import net.fabricmc.loom.configuration.RemappedConfigurationEntry; import net.fabricmc.loom.configuration.RemappedConfigurationEntry;
import net.fabricmc.loom.configuration.mods.ModProcessor; import net.fabricmc.loom.configuration.mods.ModProcessor;
import net.fabricmc.loom.configuration.processors.dependency.ModDependencyInfo; import net.fabricmc.loom.configuration.processors.dependency.ModDependencyInfo;
@ -57,7 +58,7 @@ public class ModCompileRemapper {
public static void remapDependencies(Project project, String mappingsSuffix, LoomGradleExtension extension, SourceRemapper sourceRemapper) { public static void remapDependencies(Project project, String mappingsSuffix, LoomGradleExtension extension, SourceRemapper sourceRemapper) {
Logger logger = project.getLogger(); Logger logger = project.getLogger();
DependencyHandler dependencies = project.getDependencies(); DependencyHandler dependencies = project.getDependencies();
boolean refreshDeps = project.getGradle().getStartParameter().isRefreshDependencies(); boolean refreshDeps = LoomGradlePlugin.refreshDeps;
final File modStore = extension.getRemappedModCache(); final File modStore = extension.getRemappedModCache();
final RemapData remapData = new RemapData(mappingsSuffix, modStore); final RemapData remapData = new RemapData(mappingsSuffix, modStore);
@ -169,9 +170,7 @@ public class ModCompileRemapper {
private static void scheduleSourcesRemapping(Project project, SourceRemapper sourceRemapper, File sources, String remappedLog, File remappedSources) { private static void scheduleSourcesRemapping(Project project, SourceRemapper sourceRemapper, File sources, String remappedLog, File remappedSources) {
project.getLogger().debug(":providing " + remappedLog + " sources"); project.getLogger().debug(":providing " + remappedLog + " sources");
boolean refreshDeps = project.getGradle().getStartParameter().isRefreshDependencies(); if (!remappedSources.exists() || sources.lastModified() <= 0 || sources.lastModified() > remappedSources.lastModified() || LoomGradlePlugin.refreshDeps) {
if (!remappedSources.exists() || sources.lastModified() <= 0 || sources.lastModified() > remappedSources.lastModified() || refreshDeps) {
sourceRemapper.scheduleRemapSources(sources, remappedSources, false, true); // Depenedency sources are used in ide only so don't need to be reproducable sourceRemapper.scheduleRemapSources(sources, remappedSources, false, true); // Depenedency sources are used in ide only so don't need to be reproducable
} else { } else {
project.getLogger().info(remappedSources.getName() + " is up to date with " + sources.getName()); project.getLogger().info(remappedSources.getName() + " is up to date with " + sources.getName());

View File

@ -48,6 +48,7 @@ import org.gradle.api.artifacts.SelfResolvingDependency;
import org.zeroturnaround.zip.ZipUtil; import org.zeroturnaround.zip.ZipUtil;
import net.fabricmc.loom.LoomGradleExtension; import net.fabricmc.loom.LoomGradleExtension;
import net.fabricmc.loom.LoomGradlePlugin;
public abstract class DependencyProvider { public abstract class DependencyProvider {
private LoomDependencyManager dependencyManager; private LoomDependencyManager dependencyManager;
@ -88,7 +89,7 @@ public abstract class DependencyProvider {
} }
public boolean isRefreshDeps() { public boolean isRefreshDeps() {
return getProject().getGradle().getStartParameter().isRefreshDependencies(); return LoomGradlePlugin.refreshDeps;
} }
public static class DependencyInfo { public static class DependencyInfo {

View File

@ -130,7 +130,7 @@ public class LoomDependencyManager {
try { try {
provider.provide(info, afterTasks::add); provider.provide(info, afterTasks::add);
} catch (Exception e) { } catch (Exception e) {
throw new RuntimeException("Failed to provide " + dependency.getGroup() + ":" + dependency.getName() + ":" + dependency.getVersion() + " : " + e.getMessage(), e); throw new RuntimeException("Failed to provide " + dependency.getGroup() + ":" + dependency.getName() + ":" + dependency.getVersion() + " : " + e.toString(), e);
} }
} }
} }

View File

@ -54,6 +54,7 @@ import org.zeroturnaround.zip.ZipEntrySource;
import org.zeroturnaround.zip.ZipUtil; import org.zeroturnaround.zip.ZipUtil;
import net.fabricmc.loom.LoomGradleExtension; import net.fabricmc.loom.LoomGradleExtension;
import net.fabricmc.loom.LoomGradlePlugin;
import net.fabricmc.loom.configuration.providers.minecraft.MinecraftVersionInfo; import net.fabricmc.loom.configuration.providers.minecraft.MinecraftVersionInfo;
import net.fabricmc.loom.util.DownloadUtil; import net.fabricmc.loom.util.DownloadUtil;
import net.fabricmc.lorenztiny.TinyMappingsReader; import net.fabricmc.lorenztiny.TinyMappingsReader;
@ -81,7 +82,7 @@ public class MojangMappingsDependency implements SelfResolvingDependency {
Path clientMappings = mappingsDir.resolve(String.format("%s.%s-%s-client.map", GROUP, MODULE, getVersion())); Path clientMappings = mappingsDir.resolve(String.format("%s.%s-%s-client.map", GROUP, MODULE, getVersion()));
Path serverMappings = mappingsDir.resolve(String.format("%s.%s-%s-server.map", GROUP, MODULE, getVersion())); Path serverMappings = mappingsDir.resolve(String.format("%s.%s-%s-server.map", GROUP, MODULE, getVersion()));
if (!Files.exists(mappingsFile) || project.getGradle().getStartParameter().isRefreshDependencies()) { if (!Files.exists(mappingsFile) || LoomGradlePlugin.refreshDeps) {
MappingSet mappingSet; MappingSet mappingSet;
try { try {