Cleanup installer json handling, should hopefully fix incorrect dependency versions.
parent
35437891b5
commit
e03bbe0f87
|
@ -64,7 +64,6 @@ public class LoomGradleExtension {
|
|||
private Project project;
|
||||
private LoomDependencyManager dependencyManager;
|
||||
private JsonObject installerJson;
|
||||
private int installerJsonPriority = Integer.MAX_VALUE; // 0+, higher = less prioritized
|
||||
private MappingSet[] srcMappingCache = new MappingSet[2];
|
||||
private Mercury[] srcMercuryCache = new Mercury[2];
|
||||
|
||||
|
@ -88,11 +87,8 @@ public class LoomGradleExtension {
|
|||
return Collections.unmodifiableList(unmappedModsBuilt);
|
||||
}
|
||||
|
||||
public void setInstallerJson(JsonObject object, int priority) {
|
||||
if (installerJson == null || priority <= installerJsonPriority) {
|
||||
public void setInstallerJson(JsonObject object) {
|
||||
this.installerJson = object;
|
||||
this.installerJsonPriority = priority;
|
||||
}
|
||||
}
|
||||
|
||||
public JsonObject getInstallerJson() {
|
||||
|
|
|
@ -27,15 +27,12 @@ package net.fabricmc.loom.util;
|
|||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import com.google.gson.JsonObject;
|
||||
import org.gradle.api.Project;
|
||||
import org.gradle.api.artifacts.Configuration;
|
||||
import org.gradle.api.artifacts.Dependency;
|
||||
import org.gradle.api.artifacts.ExternalModuleDependency;
|
||||
import org.gradle.api.artifacts.repositories.MavenArtifactRepository;
|
||||
|
||||
|
@ -129,23 +126,20 @@ public class LoomDependencyManager {
|
|||
|
||||
if (extension.getInstallerJson() == null) {
|
||||
//If we've not found the installer JSON we've probably skipped remapping Fabric loader, let's go looking
|
||||
project.getLogger().info("Didn't find installer JSON, searching through modCompileClasspath");
|
||||
Configuration configuration = project.getConfigurations().getByName(Constants.MOD_COMPILE_CLASSPATH);
|
||||
project.getLogger().info("Searching through modCompileClasspath for installer JSON");
|
||||
final Configuration configuration = project.getConfigurations().getByName(Constants.MOD_COMPILE_CLASSPATH);
|
||||
|
||||
Set<File> seenFiles = new HashSet<>();
|
||||
|
||||
for (Dependency dependency : configuration.getDependencies()) {
|
||||
DependencyInfo info = DependencyInfo.create(project, dependency, configuration);
|
||||
|
||||
for (File input : info.resolve()) {
|
||||
if (seenFiles.add(input)) {
|
||||
ModProcessor.readInstallerJson(input, project);
|
||||
for (File input : configuration.resolve()) {
|
||||
JsonObject jsonObject = ModProcessor.readInstallerJson(input, project);
|
||||
|
||||
if (jsonObject != null) {
|
||||
if (extension.getInstallerJson() != null) {
|
||||
project.getLogger().info("Found installer JSON in " + info);
|
||||
break; //Found it, probably don't need to look any further
|
||||
}
|
||||
project.getLogger().info("Found another installer JSON in, ignoring it! " + input);
|
||||
continue;
|
||||
}
|
||||
|
||||
project.getLogger().info("Found installer JSON in " + input);
|
||||
extension.setInstallerJson(jsonObject);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -141,8 +141,6 @@ public class ModCompileRemapper {
|
|||
} else {
|
||||
project.getLogger().info(output.getName() + " is up to date with " + input.getName());
|
||||
}
|
||||
|
||||
ModProcessor.acknowledgeMod(input, output, project, config);
|
||||
}
|
||||
|
||||
private static File findSources(DependencyHandler dependencies, ResolvedArtifact artifact) {
|
||||
|
|
|
@ -73,10 +73,6 @@ public class ModProcessor {
|
|||
stripNestedJars(output);
|
||||
}
|
||||
|
||||
public static void acknowledgeMod(File input, File output, Project project, Configuration config) {
|
||||
readInstallerJson(input, project);
|
||||
}
|
||||
|
||||
private static void handleNestedJars(File input, Project project, Configuration config) throws IOException {
|
||||
JarFile jarFile = new JarFile(input);
|
||||
JarEntry modJsonEntry = jarFile.getJarEntry("fabric.mod.json");
|
||||
|
@ -187,7 +183,7 @@ public class ModProcessor {
|
|||
}
|
||||
}
|
||||
|
||||
static void readInstallerJson(File file, Project project) {
|
||||
static JsonObject readInstallerJson(File file, Project project) {
|
||||
try {
|
||||
LoomGradleExtension extension = project.getExtensions().getByType(LoomGradleExtension.class);
|
||||
String launchMethod = extension.getLoaderLaunchMethod();
|
||||
|
@ -211,7 +207,7 @@ public class ModProcessor {
|
|||
priority++;
|
||||
|
||||
if (entry == null) {
|
||||
return;
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -221,9 +217,10 @@ public class ModProcessor {
|
|||
}
|
||||
|
||||
JsonObject jsonObject = GSON.fromJson(jsonStr, JsonObject.class);
|
||||
extension.setInstallerJson(jsonObject, priority);
|
||||
return jsonObject;
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue