File Structure Changes (#462)
* File Structure changes * Fix checkstyle * Fix processed jars * Fix unpick tests * Resolve reviews * Fix merge conflictsdev/0.11
parent
a0c2d877af
commit
97a629eef9
|
@ -73,13 +73,13 @@ public class LoomRepositoryPlugin implements Plugin<PluginAware> {
|
||||||
|
|
||||||
repositories.ivy(repo -> {
|
repositories.ivy(repo -> {
|
||||||
repo.setUrl(files.getUserCache());
|
repo.setUrl(files.getUserCache());
|
||||||
repo.patternLayout(layout -> layout.artifact("[revision]/[artifact]-[revision](-[classifier])(.[ext])"));
|
repo.patternLayout(layout -> layout.artifact("[revision]/[artifact](-[classifier])(.[ext])"));
|
||||||
repo.metadataSources(IvyArtifactRepository.MetadataSources::artifact);
|
repo.metadataSources(IvyArtifactRepository.MetadataSources::artifact);
|
||||||
});
|
});
|
||||||
|
|
||||||
repositories.ivy(repo -> {
|
repositories.ivy(repo -> {
|
||||||
repo.setUrl(files.getRootProjectPersistentCache());
|
repo.setUrl(files.getRootProjectPersistentCache());
|
||||||
repo.patternLayout(layout -> layout.artifact("[revision]/[artifact]-[revision](-[classifier])(.[ext])"));
|
repo.patternLayout(layout -> layout.artifact("[revision]/[artifact](-[classifier])(.[ext])"));
|
||||||
repo.metadataSources(IvyArtifactRepository.MetadataSources::artifact);
|
repo.metadataSources(IvyArtifactRepository.MetadataSources::artifact);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -82,7 +82,7 @@ public abstract class AnnotationProcessorInvoker<T extends Task> {
|
||||||
LoomGradleExtension loom = LoomGradleExtension.get(project);
|
LoomGradleExtension loom = LoomGradleExtension.get(project);
|
||||||
String refmapName = Objects.requireNonNull(MixinApExtension.getMixinInformationContainer(sourceSet)).refmapNameProvider().get();
|
String refmapName = Objects.requireNonNull(MixinApExtension.getMixinInformationContainer(sourceSet)).refmapNameProvider().get();
|
||||||
Map<String, String> args = new HashMap<>() {{
|
Map<String, String> args = new HashMap<>() {{
|
||||||
put(Constants.MixinArguments.IN_MAP_FILE_NAMED_INTERMEDIARY, loom.getMappingsProvider().tinyMappings.getCanonicalPath());
|
put(Constants.MixinArguments.IN_MAP_FILE_NAMED_INTERMEDIARY, loom.getMappingsProvider().tinyMappings.toFile().getCanonicalPath());
|
||||||
put(Constants.MixinArguments.OUT_MAP_FILE_NAMED_INTERMEDIARY, loom.getNextMixinMappings().getCanonicalPath());
|
put(Constants.MixinArguments.OUT_MAP_FILE_NAMED_INTERMEDIARY, loom.getNextMixinMappings().getCanonicalPath());
|
||||||
put(Constants.MixinArguments.OUT_REFMAP_FILE, getRefmapDestination(task, refmapName));
|
put(Constants.MixinArguments.OUT_REFMAP_FILE, getRefmapDestination(task, refmapName));
|
||||||
put(Constants.MixinArguments.DEFAULT_OBFUSCATION_ENV, "named:intermediary");
|
put(Constants.MixinArguments.DEFAULT_OBFUSCATION_ENV, "named:intermediary");
|
||||||
|
|
|
@ -49,6 +49,7 @@ import org.zeroturnaround.zip.ZipUtil;
|
||||||
|
|
||||||
import net.fabricmc.loom.LoomGradleExtension;
|
import net.fabricmc.loom.LoomGradleExtension;
|
||||||
import net.fabricmc.loom.LoomGradlePlugin;
|
import net.fabricmc.loom.LoomGradlePlugin;
|
||||||
|
import net.fabricmc.loom.configuration.providers.MinecraftProvider;
|
||||||
import net.fabricmc.loom.extension.LoomFiles;
|
import net.fabricmc.loom.extension.LoomFiles;
|
||||||
|
|
||||||
public abstract class DependencyProvider {
|
public abstract class DependencyProvider {
|
||||||
|
@ -93,6 +94,10 @@ public abstract class DependencyProvider {
|
||||||
return getExtension().getFiles();
|
return getExtension().getFiles();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public MinecraftProvider getMinecraftProvider() {
|
||||||
|
return getExtension().getMinecraftProvider();
|
||||||
|
}
|
||||||
|
|
||||||
public boolean isRefreshDeps() {
|
public boolean isRefreshDeps() {
|
||||||
return LoomGradlePlugin.refreshDeps;
|
return LoomGradlePlugin.refreshDeps;
|
||||||
}
|
}
|
||||||
|
|
|
@ -139,7 +139,7 @@ public class LoomDependencyManager {
|
||||||
}
|
}
|
||||||
|
|
||||||
SourceRemapper sourceRemapper = new SourceRemapper(project, true);
|
SourceRemapper sourceRemapper = new SourceRemapper(project, true);
|
||||||
String mappingsKey = mappingsProvider.getMappingsKey();
|
String mappingsIdentifier = mappingsProvider.mappingsIdentifier();
|
||||||
|
|
||||||
if (extension.getInstallerData() == null) {
|
if (extension.getInstallerData() == null) {
|
||||||
//If we've not found the installer JSON we've probably skipped remapping Fabric loader, let's go looking
|
//If we've not found the installer JSON we've probably skipped remapping Fabric loader, let's go looking
|
||||||
|
@ -168,7 +168,7 @@ public class LoomDependencyManager {
|
||||||
project.getLogger().warn("fabric-installer.json not found in classpath!");
|
project.getLogger().warn("fabric-installer.json not found in classpath!");
|
||||||
}
|
}
|
||||||
|
|
||||||
ModCompileRemapper.remapDependencies(project, mappingsKey, extension, sourceRemapper);
|
ModCompileRemapper.remapDependencies(project, mappingsIdentifier, extension, sourceRemapper);
|
||||||
|
|
||||||
long start = System.currentTimeMillis();
|
long start = System.currentTimeMillis();
|
||||||
|
|
||||||
|
|
|
@ -66,11 +66,11 @@ public class MinecraftProcessedProvider extends MinecraftMappedProvider {
|
||||||
}
|
}
|
||||||
|
|
||||||
getProject().getDependencies().add(Constants.Configurations.MINECRAFT_NAMED,
|
getProject().getDependencies().add(Constants.Configurations.MINECRAFT_NAMED,
|
||||||
getProject().getDependencies().module("net.minecraft:minecraft:" + getJarVersionString(projectMappedClassifier)));
|
getProject().getDependencies().module("net.minecraft:minecraft-" + projectMappedClassifier + ":" + getMinecraftProvider().minecraftVersion() + "/" + getExtension().getMappingsProvider().mappingsIdentifier()));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void invalidateJars() {
|
private void invalidateJars() {
|
||||||
File dir = getJarDirectory(getExtension().getFiles().getUserCache(), projectMappedClassifier);
|
File dir = projectMappedJar.getParentFile();
|
||||||
|
|
||||||
if (dir.exists()) {
|
if (dir.exists()) {
|
||||||
getProject().getLogger().warn("Invalidating project jars");
|
getProject().getLogger().warn("Invalidating project jars");
|
||||||
|
@ -87,7 +87,8 @@ public class MinecraftProcessedProvider extends MinecraftMappedProvider {
|
||||||
public void initFiles(MinecraftProviderImpl minecraftProvider, MappingsProviderImpl mappingsProvider) {
|
public void initFiles(MinecraftProviderImpl minecraftProvider, MappingsProviderImpl mappingsProvider) {
|
||||||
super.initFiles(minecraftProvider, mappingsProvider);
|
super.initFiles(minecraftProvider, mappingsProvider);
|
||||||
|
|
||||||
projectMappedJar = new File(getJarDirectory(getExtension().getFiles().getRootProjectPersistentCache(), projectMappedClassifier), "minecraft-" + getJarVersionString(projectMappedClassifier) + ".jar");
|
projectMappedJar = new File(getDirectories().getRootProjectPersistentCache(), getMinecraftProvider().minecraftVersion() + "/"
|
||||||
|
+ getExtension().getMappingsProvider().mappingsIdentifier() + "/minecraft-" + projectMappedClassifier + ".jar");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -58,8 +58,8 @@ public class LaunchProvider extends DependencyProvider {
|
||||||
.property("fabric.remapClasspathFile", getRemapClasspathFile().getAbsolutePath())
|
.property("fabric.remapClasspathFile", getRemapClasspathFile().getAbsolutePath())
|
||||||
.property("log4j.configurationFile", getAllLog4JConfigFiles())
|
.property("log4j.configurationFile", getAllLog4JConfigFiles())
|
||||||
|
|
||||||
.property("client", "java.library.path", getDirectories().getNativesDirectory(getExtension().getMinecraftProvider()).getAbsolutePath())
|
.property("client", "java.library.path", getExtension().getMinecraftProvider().nativesDir().getAbsolutePath())
|
||||||
.property("client", "org.lwjgl.librarypath", getDirectories().getNativesDirectory(getExtension().getMinecraftProvider()).getAbsolutePath())
|
.property("client", "org.lwjgl.librarypath", getExtension().getMinecraftProvider().nativesDir().getAbsolutePath())
|
||||||
|
|
||||||
.argument("client", "--assetIndex")
|
.argument("client", "--assetIndex")
|
||||||
.argument("client", getExtension().getMinecraftProvider().getVersionInfo().assetIndex().fabricId(getExtension().getMinecraftProvider().minecraftVersion()))
|
.argument("client", getExtension().getMinecraftProvider().getVersionInfo().assetIndex().fabricId(getExtension().getMinecraftProvider().minecraftVersion()))
|
||||||
|
|
|
@ -24,9 +24,21 @@
|
||||||
|
|
||||||
package net.fabricmc.loom.configuration.providers;
|
package net.fabricmc.loom.configuration.providers;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
|
||||||
import net.fabricmc.loom.configuration.providers.minecraft.MinecraftVersionMeta;
|
import net.fabricmc.loom.configuration.providers.minecraft.MinecraftVersionMeta;
|
||||||
|
|
||||||
public interface MinecraftProvider {
|
public interface MinecraftProvider {
|
||||||
|
File workingDir();
|
||||||
|
|
||||||
|
boolean hasCustomNatives();
|
||||||
|
|
||||||
|
File nativesDir();
|
||||||
|
|
||||||
|
File dir(String path);
|
||||||
|
|
||||||
|
File file(String path);
|
||||||
|
|
||||||
String minecraftVersion();
|
String minecraftVersion();
|
||||||
|
|
||||||
MinecraftVersionMeta getVersionInfo();
|
MinecraftVersionMeta getVersionInfo();
|
||||||
|
|
|
@ -53,6 +53,7 @@ public class MinecraftProviderImpl extends DependencyProvider implements Minecra
|
||||||
private MinecraftVersionMeta versionInfo;
|
private MinecraftVersionMeta versionInfo;
|
||||||
private MinecraftLibraryProvider libraryProvider;
|
private MinecraftLibraryProvider libraryProvider;
|
||||||
|
|
||||||
|
private File workingDir;
|
||||||
private File minecraftJson;
|
private File minecraftJson;
|
||||||
private File minecraftClientJar;
|
private File minecraftClientJar;
|
||||||
private File minecraftServerJar;
|
private File minecraftServerJar;
|
||||||
|
@ -112,10 +113,12 @@ public class MinecraftProviderImpl extends DependencyProvider implements Minecra
|
||||||
}
|
}
|
||||||
|
|
||||||
private void initFiles() {
|
private void initFiles() {
|
||||||
minecraftJson = new File(getDirectories().getUserCache(), "minecraft-" + minecraftVersion + "-info.json");
|
workingDir = new File(getDirectories().getUserCache(), minecraftVersion);
|
||||||
minecraftClientJar = new File(getDirectories().getUserCache(), "minecraft-" + minecraftVersion + "-client.jar");
|
workingDir.mkdirs();
|
||||||
minecraftServerJar = new File(getDirectories().getUserCache(), "minecraft-" + minecraftVersion + "-server.jar");
|
minecraftJson = file("minecraft-info.json");
|
||||||
minecraftMergedJar = new File(getDirectories().getUserCache(), "minecraft-" + minecraftVersion + "-merged.jar");
|
minecraftClientJar = file("minecraft-client.jar");
|
||||||
|
minecraftServerJar = file("minecraft-server.jar");
|
||||||
|
minecraftMergedJar = file("minecraft-merged.jar");
|
||||||
versionManifestJson = new File(getDirectories().getUserCache(), "version_manifest.json");
|
versionManifestJson = new File(getDirectories().getUserCache(), "version_manifest.json");
|
||||||
experimentalVersionsJson = new File(getDirectories().getUserCache(), "experimental_version_manifest.json");
|
experimentalVersionsJson = new File(getDirectories().getUserCache(), "experimental_version_manifest.json");
|
||||||
}
|
}
|
||||||
|
@ -257,6 +260,37 @@ public class MinecraftProviderImpl extends DependencyProvider implements Minecra
|
||||||
return minecraftMergedJar;
|
return minecraftMergedJar;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public File workingDir() {
|
||||||
|
return workingDir;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean hasCustomNatives() {
|
||||||
|
return getProject().getProperties().get("fabric.loom.natives.dir") != null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public File nativesDir() {
|
||||||
|
if (hasCustomNatives()) {
|
||||||
|
return new File((String) getProject().property("fabric.loom.natives.dir"));
|
||||||
|
}
|
||||||
|
|
||||||
|
return dir("natives");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public File dir(String path) {
|
||||||
|
File dir = file(path);
|
||||||
|
dir.mkdirs();
|
||||||
|
return dir;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public File file(String path) {
|
||||||
|
return new File(workingDir(), path);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String minecraftVersion() {
|
public String minecraftVersion() {
|
||||||
return minecraftVersion;
|
return minecraftVersion;
|
||||||
|
|
|
@ -62,9 +62,7 @@ public class GradleMappingContext implements MappingContext {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public File workingDirectory(String name) {
|
public File workingDirectory(String name) {
|
||||||
File tempDir = new File(mappingsProvider().getMappingsDir().toFile(), workingDirName);
|
return new File(minecraftProvider().dir("layered/working_dir/" + workingDirName), name);
|
||||||
tempDir.mkdirs();
|
|
||||||
return new File(tempDir, name);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -64,7 +64,7 @@ public class LayeredMappingsDependency implements SelfResolvingDependency {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Set<File> resolve() {
|
public Set<File> resolve() {
|
||||||
Path mappingsDir = mappingContext.mappingsProvider().getMappingsDir();
|
Path mappingsDir = mappingContext.minecraftProvider().dir("layered").toPath();
|
||||||
Path mappingsFile = mappingsDir.resolve(String.format("%s.%s-%s.tiny", GROUP, MODULE, getVersion()));
|
Path mappingsFile = mappingsDir.resolve(String.format("%s.%s-%s.tiny", GROUP, MODULE, getVersion()));
|
||||||
|
|
||||||
if (!Files.exists(mappingsFile) || LoomGradlePlugin.refreshDeps) {
|
if (!Files.exists(mappingsFile) || LoomGradlePlugin.refreshDeps) {
|
||||||
|
|
|
@ -28,7 +28,7 @@ import java.io.File;
|
||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
|
|
||||||
public interface MappingsProvider {
|
public interface MappingsProvider {
|
||||||
Path getMappingsDir();
|
Path mappingsWorkingDir();
|
||||||
|
|
||||||
File intermediaryTinyFile();
|
File intermediaryTinyFile();
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,18 +28,18 @@ import java.io.BufferedReader;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
|
import java.nio.charset.StandardCharsets;
|
||||||
import java.nio.file.FileSystem;
|
import java.nio.file.FileSystem;
|
||||||
import java.nio.file.FileSystems;
|
import java.nio.file.FileSystems;
|
||||||
import java.nio.file.Files;
|
import java.nio.file.Files;
|
||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
import java.nio.file.Paths;
|
|
||||||
import java.nio.file.StandardCopyOption;
|
import java.nio.file.StandardCopyOption;
|
||||||
|
import java.util.Collections;
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
|
|
||||||
import com.google.common.base.Preconditions;
|
import com.google.common.base.Stopwatch;
|
||||||
import com.google.common.net.UrlEscapers;
|
import com.google.common.net.UrlEscapers;
|
||||||
import com.google.gson.JsonObject;
|
import com.google.gson.JsonObject;
|
||||||
import org.apache.commons.io.FileUtils;
|
|
||||||
import org.apache.tools.ant.util.StringUtils;
|
import org.apache.tools.ant.util.StringUtils;
|
||||||
import org.gradle.api.Project;
|
import org.gradle.api.Project;
|
||||||
import org.zeroturnaround.zip.FileSource;
|
import org.zeroturnaround.zip.FileSource;
|
||||||
|
@ -59,6 +59,11 @@ import net.fabricmc.loom.util.DeletingFileVisitor;
|
||||||
import net.fabricmc.loom.util.DownloadUtil;
|
import net.fabricmc.loom.util.DownloadUtil;
|
||||||
import net.fabricmc.mapping.reader.v2.TinyV2Factory;
|
import net.fabricmc.mapping.reader.v2.TinyV2Factory;
|
||||||
import net.fabricmc.mapping.tree.TinyTree;
|
import net.fabricmc.mapping.tree.TinyTree;
|
||||||
|
import net.fabricmc.mappingio.adapter.MappingNsCompleter;
|
||||||
|
import net.fabricmc.mappingio.adapter.MappingSourceNsSwitch;
|
||||||
|
import net.fabricmc.mappingio.format.Tiny2Reader;
|
||||||
|
import net.fabricmc.mappingio.format.Tiny2Writer;
|
||||||
|
import net.fabricmc.mappingio.tree.MemoryMappingTree;
|
||||||
import net.fabricmc.stitch.Command;
|
import net.fabricmc.stitch.Command;
|
||||||
import net.fabricmc.stitch.commands.CommandProposeFieldNames;
|
import net.fabricmc.stitch.commands.CommandProposeFieldNames;
|
||||||
import net.fabricmc.stitch.commands.tinyv2.CommandMergeTinyV2;
|
import net.fabricmc.stitch.commands.tinyv2.CommandMergeTinyV2;
|
||||||
|
@ -67,35 +72,26 @@ import net.fabricmc.stitch.commands.tinyv2.CommandReorderTinyV2;
|
||||||
public class MappingsProviderImpl extends DependencyProvider implements MappingsProvider {
|
public class MappingsProviderImpl extends DependencyProvider implements MappingsProvider {
|
||||||
public MinecraftMappedProvider mappedProvider;
|
public MinecraftMappedProvider mappedProvider;
|
||||||
|
|
||||||
public String mappingsName;
|
public String mappingsIdentifier;
|
||||||
public String minecraftVersion;
|
|
||||||
public String mappingsVersion;
|
|
||||||
|
|
||||||
private final Path mappingsDir;
|
private Path mappingsWorkingDir;
|
||||||
private final Path mappingsStepsDir;
|
|
||||||
private Path intermediaryTiny;
|
private Path intermediaryTiny;
|
||||||
private boolean hasRefreshed = false;
|
private boolean hasRefreshed = false;
|
||||||
// The mappings that gradle gives us
|
// The mappings that gradle gives us
|
||||||
private Path baseTinyMappings;
|
private Path baseTinyMappings;
|
||||||
// The mappings we use in practice
|
// The mappings we use in practice
|
||||||
public File tinyMappings;
|
public Path tinyMappings;
|
||||||
public File tinyMappingsJar;
|
public Path tinyMappingsJar;
|
||||||
private File unpickDefinitionsFile;
|
private Path unpickDefinitions;
|
||||||
private boolean hasUnpickDefinitions;
|
private boolean hasUnpickDefinitions;
|
||||||
private UnpickMetadata unpickMetadata;
|
private UnpickMetadata unpickMetadata;
|
||||||
|
|
||||||
public MappingsProviderImpl(Project project) {
|
public MappingsProviderImpl(Project project) {
|
||||||
super(project);
|
super(project);
|
||||||
mappingsDir = getDirectories().getUserCache().toPath().resolve("mappings");
|
|
||||||
mappingsStepsDir = mappingsDir.resolve("steps");
|
|
||||||
}
|
|
||||||
|
|
||||||
public void clean() throws IOException {
|
|
||||||
FileUtils.deleteDirectory(mappingsDir.toFile());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public TinyTree getMappings() throws IOException {
|
public TinyTree getMappings() throws IOException {
|
||||||
return MappingsCache.INSTANCE.get(tinyMappings.toPath());
|
return MappingsCache.INSTANCE.get(tinyMappings);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -107,59 +103,22 @@ public class MappingsProviderImpl extends DependencyProvider implements Mappings
|
||||||
String version = dependency.getResolvedVersion();
|
String version = dependency.getResolvedVersion();
|
||||||
File mappingsJar = dependency.resolveFile().orElseThrow(() -> new RuntimeException("Could not find yarn mappings: " + dependency));
|
File mappingsJar = dependency.resolveFile().orElseThrow(() -> new RuntimeException("Could not find yarn mappings: " + dependency));
|
||||||
|
|
||||||
this.mappingsName = StringUtils.removeSuffix(dependency.getDependency().getGroup() + "." + dependency.getDependency().getName(), "-unmerged");
|
String mappingsName = StringUtils.removeSuffix(dependency.getDependency().getGroup() + "." + dependency.getDependency().getName(), "-unmerged");
|
||||||
this.minecraftVersion = minecraftProvider.minecraftVersion();
|
boolean isV2 = isV2(dependency, mappingsJar);
|
||||||
|
this.mappingsIdentifier = createMappingsIdentifier(mappingsName, version, getMappingsClassifier(dependency, isV2));
|
||||||
boolean isV2;
|
|
||||||
|
|
||||||
// Only do this for official yarn, there isn't really a way we can get the mc version for all mappings
|
|
||||||
if (dependency.getDependency().getGroup() != null && dependency.getDependency().getGroup().equals("net.fabricmc") && dependency.getDependency().getName().equals("yarn") && dependency.getDependency().getVersion() != null) {
|
|
||||||
String yarnVersion = dependency.getDependency().getVersion();
|
|
||||||
char separator = yarnVersion.contains("+build.") ? '+' : yarnVersion.contains("-") ? '-' : '.';
|
|
||||||
String yarnMinecraftVersion = yarnVersion.substring(0, yarnVersion.lastIndexOf(separator));
|
|
||||||
|
|
||||||
if (!yarnMinecraftVersion.equalsIgnoreCase(minecraftVersion)) {
|
|
||||||
throw new RuntimeException(String.format("Minecraft Version (%s) does not match yarn's minecraft version (%s)", minecraftVersion, yarnMinecraftVersion));
|
|
||||||
}
|
|
||||||
|
|
||||||
// We can save reading the zip file + header by checking the file name
|
|
||||||
isV2 = mappingsJar.getName().endsWith("-v2.jar");
|
|
||||||
} else {
|
|
||||||
isV2 = doesJarContainV2Mappings(mappingsJar.toPath());
|
|
||||||
}
|
|
||||||
|
|
||||||
this.mappingsVersion = version + (isV2 ? "-v2" : "");
|
|
||||||
|
|
||||||
initFiles();
|
initFiles();
|
||||||
|
|
||||||
if (isRefreshDeps()) {
|
if (Files.notExists(tinyMappings) || isRefreshDeps()) {
|
||||||
cleanFiles();
|
|
||||||
}
|
|
||||||
|
|
||||||
Files.createDirectories(mappingsDir);
|
|
||||||
Files.createDirectories(mappingsStepsDir);
|
|
||||||
|
|
||||||
String[] depStringSplit = dependency.getDepString().split(":");
|
|
||||||
String jarClassifier = "final";
|
|
||||||
|
|
||||||
if (depStringSplit.length >= 4) {
|
|
||||||
jarClassifier = jarClassifier + depStringSplit[3];
|
|
||||||
}
|
|
||||||
|
|
||||||
tinyMappings = mappingsDir.resolve(StringUtils.removeSuffix(mappingsJar.getName(), ".jar") + ".tiny").toFile();
|
|
||||||
unpickDefinitionsFile = mappingsDir.resolve(StringUtils.removeSuffix(mappingsJar.getName(), ".jar") + ".unpick").toFile();
|
|
||||||
tinyMappingsJar = new File(getDirectories().getUserCache(), mappingsJar.getName().replace(".jar", "-" + jarClassifier + ".jar"));
|
|
||||||
|
|
||||||
if (!tinyMappings.exists() || isRefreshDeps()) {
|
|
||||||
storeMappings(getProject(), minecraftProvider, mappingsJar.toPath());
|
storeMappings(getProject(), minecraftProvider, mappingsJar.toPath());
|
||||||
} else {
|
} else {
|
||||||
try (FileSystem fileSystem = FileSystems.newFileSystem(mappingsJar.toPath(), (ClassLoader) null)) {
|
try (FileSystem fileSystem = FileSystems.newFileSystem(mappingsJar.toPath(), (ClassLoader) null)) {
|
||||||
extractUnpickDefinitions(fileSystem, unpickDefinitionsFile.toPath());
|
extractUnpickDefinitions(fileSystem, unpickDefinitions);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!tinyMappingsJar.exists() || isRefreshDeps()) {
|
if (Files.notExists(tinyMappingsJar) || isRefreshDeps()) {
|
||||||
ZipUtil.pack(new ZipEntrySource[] {new FileSource("mappings/mappings.tiny", tinyMappings)}, tinyMappingsJar);
|
ZipUtil.pack(new ZipEntrySource[] {new FileSource("mappings/mappings.tiny", tinyMappings.toFile())}, tinyMappingsJar.toFile());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (hasUnpickDefinitions()) {
|
if (hasUnpickDefinitions()) {
|
||||||
|
@ -173,7 +132,7 @@ public class MappingsProviderImpl extends DependencyProvider implements Mappings
|
||||||
populateUnpickClasspath();
|
populateUnpickClasspath();
|
||||||
}
|
}
|
||||||
|
|
||||||
addDependency(tinyMappingsJar, Constants.Configurations.MAPPINGS_FINAL);
|
addDependency(tinyMappingsJar.toFile(), Constants.Configurations.MAPPINGS_FINAL);
|
||||||
|
|
||||||
LoomGradleExtension extension = getExtension();
|
LoomGradleExtension extension = getExtension();
|
||||||
|
|
||||||
|
@ -198,30 +157,57 @@ public class MappingsProviderImpl extends DependencyProvider implements Mappings
|
||||||
mappedProvider.provide(dependency, postPopulationScheduler);
|
mappedProvider.provide(dependency, postPopulationScheduler);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private String getMappingsClassifier(DependencyInfo dependency, boolean isV2) {
|
||||||
|
String[] depStringSplit = dependency.getDepString().split(":");
|
||||||
|
|
||||||
|
if (depStringSplit.length >= 4) {
|
||||||
|
return "-" + depStringSplit[3] + (isV2 ? "-v2" : "");
|
||||||
|
}
|
||||||
|
|
||||||
|
return isV2 ? "-v2" : "";
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean isV2(DependencyInfo dependency, File mappingsJar) throws IOException {
|
||||||
|
String minecraftVersion = getMinecraftProvider().minecraftVersion();
|
||||||
|
|
||||||
|
// Only do this for official yarn, there isn't really a way we can get the mc version for all mappings
|
||||||
|
if (dependency.getDependency().getGroup() != null && dependency.getDependency().getGroup().equals("net.fabricmc") && dependency.getDependency().getName().equals("yarn") && dependency.getDependency().getVersion() != null) {
|
||||||
|
String yarnVersion = dependency.getDependency().getVersion();
|
||||||
|
char separator = yarnVersion.contains("+build.") ? '+' : yarnVersion.contains("-") ? '-' : '.';
|
||||||
|
String yarnMinecraftVersion = yarnVersion.substring(0, yarnVersion.lastIndexOf(separator));
|
||||||
|
|
||||||
|
if (!yarnMinecraftVersion.equalsIgnoreCase(minecraftVersion)) {
|
||||||
|
throw new RuntimeException(String.format("Minecraft Version (%s) does not match yarn's minecraft version (%s)", minecraftVersion, yarnMinecraftVersion));
|
||||||
|
}
|
||||||
|
|
||||||
|
// We can save reading the zip file + header by checking the file name
|
||||||
|
return mappingsJar.getName().endsWith("-v2.jar");
|
||||||
|
} else {
|
||||||
|
return doesJarContainV2Mappings(mappingsJar.toPath());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void storeMappings(Project project, MinecraftProviderImpl minecraftProvider, Path yarnJar) throws IOException {
|
private void storeMappings(Project project, MinecraftProviderImpl minecraftProvider, Path yarnJar) throws IOException {
|
||||||
project.getLogger().info(":extracting " + yarnJar.getFileName());
|
project.getLogger().info(":extracting " + yarnJar.getFileName());
|
||||||
|
|
||||||
try (FileSystem fileSystem = FileSystems.newFileSystem(yarnJar, (ClassLoader) null)) {
|
try (FileSystem fileSystem = FileSystems.newFileSystem(yarnJar, (ClassLoader) null)) {
|
||||||
extractMappings(fileSystem, baseTinyMappings);
|
extractMappings(fileSystem, baseTinyMappings);
|
||||||
extractUnpickDefinitions(fileSystem, unpickDefinitionsFile.toPath());
|
extractUnpickDefinitions(fileSystem, unpickDefinitions);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (baseMappingsAreV2()) {
|
if (areMappingsV2(baseTinyMappings)) {
|
||||||
// These are unmerged v2 mappings
|
// These are unmerged v2 mappings
|
||||||
mergeAndSaveMappings(project, yarnJar);
|
mergeAndSaveMappings(project, baseTinyMappings, tinyMappings);
|
||||||
} else {
|
} else {
|
||||||
// These are merged v1 mappings
|
// These are merged v1 mappings
|
||||||
if (tinyMappings.exists()) {
|
Files.deleteIfExists(tinyMappings);
|
||||||
tinyMappings.delete();
|
|
||||||
}
|
|
||||||
|
|
||||||
project.getLogger().lifecycle(":populating field names");
|
project.getLogger().lifecycle(":populating field names");
|
||||||
suggestFieldNames(minecraftProvider, baseTinyMappings, tinyMappings.toPath());
|
suggestFieldNames(minecraftProvider, baseTinyMappings, tinyMappings);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean baseMappingsAreV2() throws IOException {
|
private static boolean areMappingsV2(Path path) throws IOException {
|
||||||
try (BufferedReader reader = Files.newBufferedReader(baseTinyMappings)) {
|
try (BufferedReader reader = Files.newBufferedReader(path)) {
|
||||||
TinyV2Factory.readMetadata(reader);
|
TinyV2Factory.readMetadata(reader);
|
||||||
return true;
|
return true;
|
||||||
} catch (IllegalArgumentException e) {
|
} catch (IllegalArgumentException e) {
|
||||||
|
@ -230,7 +216,7 @@ public class MappingsProviderImpl extends DependencyProvider implements Mappings
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean doesJarContainV2Mappings(Path path) throws IOException {
|
private static boolean doesJarContainV2Mappings(Path path) throws IOException {
|
||||||
try (FileSystem fs = FileSystems.newFileSystem(path, (ClassLoader) null)) {
|
try (FileSystem fs = FileSystems.newFileSystem(path, (ClassLoader) null)) {
|
||||||
try (BufferedReader reader = Files.newBufferedReader(fs.getPath("mappings", "mappings.tiny"))) {
|
try (BufferedReader reader = Files.newBufferedReader(fs.getPath("mappings", "mappings.tiny"))) {
|
||||||
TinyV2Factory.readMetadata(reader);
|
TinyV2Factory.readMetadata(reader);
|
||||||
|
@ -241,6 +227,12 @@ public class MappingsProviderImpl extends DependencyProvider implements Mappings
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static void extractMappings(Path jar, Path extractTo) throws IOException {
|
||||||
|
try (FileSystem unmergedIntermediaryFs = FileSystems.newFileSystem(jar, (ClassLoader) null)) {
|
||||||
|
extractMappings(unmergedIntermediaryFs, extractTo);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static void extractMappings(FileSystem jar, Path extractTo) throws IOException {
|
public static void extractMappings(FileSystem jar, Path extractTo) throws IOException {
|
||||||
Files.copy(jar.getPath("mappings/mappings.tiny"), extractTo, StandardCopyOption.REPLACE_EXISTING);
|
Files.copy(jar.getPath("mappings/mappings.tiny"), extractTo, StandardCopyOption.REPLACE_EXISTING);
|
||||||
}
|
}
|
||||||
|
@ -279,28 +271,34 @@ public class MappingsProviderImpl extends DependencyProvider implements Mappings
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void extractIntermediary(Path intermediaryJar, Path intermediaryTiny) throws IOException {
|
private void mergeAndSaveMappings(Project project, Path from, Path out) throws IOException {
|
||||||
getProject().getLogger().info(":extracting " + intermediaryJar.getFileName());
|
Stopwatch stopwatch = Stopwatch.createStarted();
|
||||||
|
project.getLogger().info(":merging mappings");
|
||||||
|
|
||||||
try (FileSystem unmergedIntermediaryFs = FileSystems.newFileSystem(intermediaryJar, (ClassLoader) null)) {
|
MemoryMappingTree tree = new MemoryMappingTree();
|
||||||
extractMappings(unmergedIntermediaryFs, intermediaryTiny);
|
MappingSourceNsSwitch sourceNsSwitch = new MappingSourceNsSwitch(tree, MappingNamespace.OFFICIAL.stringValue());
|
||||||
|
readIntermediaryTree().accept(sourceNsSwitch);
|
||||||
|
|
||||||
|
try (BufferedReader reader = Files.newBufferedReader(from, StandardCharsets.UTF_8)) {
|
||||||
|
Tiny2Reader.read(reader, tree);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
try (Tiny2Writer writer = new Tiny2Writer(Files.newBufferedWriter(out, StandardCharsets.UTF_8), false)) {
|
||||||
|
tree.accept(writer);
|
||||||
|
}
|
||||||
|
|
||||||
|
project.getLogger().info(":merged mappings in " + stopwatch.stop());
|
||||||
}
|
}
|
||||||
|
|
||||||
private void mergeAndSaveMappings(Project project, Path unmergedYarnJar) throws IOException {
|
private MemoryMappingTree readIntermediaryTree() throws IOException {
|
||||||
Path unmergedYarn = Paths.get(mappingsStepsDir.toString(), "unmerged-yarn.tiny");
|
MemoryMappingTree tree = new MemoryMappingTree();
|
||||||
project.getLogger().info(":extracting " + unmergedYarnJar.getFileName());
|
MappingNsCompleter nsCompleter = new MappingNsCompleter(tree, Collections.singletonMap(MappingNamespace.NAMED.stringValue(), MappingNamespace.INTERMEDIARY.stringValue()), true);
|
||||||
|
|
||||||
try (FileSystem unmergedYarnJarFs = FileSystems.newFileSystem(unmergedYarnJar, (ClassLoader) null)) {
|
try (BufferedReader reader = Files.newBufferedReader(getIntermediaryTiny(), StandardCharsets.UTF_8)) {
|
||||||
extractMappings(unmergedYarnJarFs, unmergedYarn);
|
Tiny2Reader.read(reader, nsCompleter);
|
||||||
}
|
}
|
||||||
|
|
||||||
Path invertedIntermediary = Paths.get(mappingsStepsDir.toString(), "inverted-intermediary.tiny");
|
return tree;
|
||||||
reorderMappings(getIntermediaryTiny(), invertedIntermediary, "intermediary", "official");
|
|
||||||
Path unorderedMergedMappings = Paths.get(mappingsStepsDir.toString(), "unordered-merged.tiny");
|
|
||||||
project.getLogger().info(":merging");
|
|
||||||
mergeMappings(invertedIntermediary, unmergedYarn, unorderedMergedMappings);
|
|
||||||
reorderMappings(unorderedMergedMappings, tinyMappings.toPath(), "official", "intermediary", "named");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void reorderMappings(Path oldMappings, Path newMappings, String... newOrder) {
|
private void reorderMappings(Path oldMappings, Path newMappings, String... newOrder) {
|
||||||
|
@ -341,25 +339,21 @@ public class MappingsProviderImpl extends DependencyProvider implements Mappings
|
||||||
}
|
}
|
||||||
|
|
||||||
private void initFiles() {
|
private void initFiles() {
|
||||||
baseTinyMappings = mappingsDir.resolve(mappingsName + "-tiny-" + minecraftVersion + "-" + mappingsVersion + "-base");
|
mappingsWorkingDir = getMinecraftProvider().dir(mappingsIdentifier).toPath();
|
||||||
|
baseTinyMappings = mappingsWorkingDir.resolve("mappings-base.tiny");
|
||||||
|
tinyMappings = mappingsWorkingDir.resolve("mappings.tiny");
|
||||||
|
tinyMappingsJar = mappingsWorkingDir.resolve("mappings.jar");
|
||||||
|
unpickDefinitions = mappingsWorkingDir.resolve("mappings.unpick");
|
||||||
|
|
||||||
|
if (isRefreshDeps()) {
|
||||||
|
cleanFiles();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void cleanFiles() {
|
public void cleanFiles() {
|
||||||
try {
|
try {
|
||||||
if (Files.exists(mappingsStepsDir)) {
|
if (Files.exists(mappingsWorkingDir)) {
|
||||||
Files.walkFileTree(mappingsStepsDir, new DeletingFileVisitor());
|
Files.walkFileTree(mappingsWorkingDir, new DeletingFileVisitor());
|
||||||
}
|
|
||||||
|
|
||||||
if (Files.exists(baseTinyMappings)) {
|
|
||||||
Files.deleteIfExists(baseTinyMappings);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (tinyMappings != null) {
|
|
||||||
tinyMappings.delete();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (tinyMappingsJar != null) {
|
|
||||||
tinyMappingsJar.delete();
|
|
||||||
}
|
}
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
@ -371,40 +365,42 @@ public class MappingsProviderImpl extends DependencyProvider implements Mappings
|
||||||
return Constants.Configurations.MAPPINGS;
|
return Constants.Configurations.MAPPINGS;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public Path getMappingsDir() {
|
|
||||||
return mappingsDir;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Path getIntermediaryTiny() throws IOException {
|
public Path getIntermediaryTiny() throws IOException {
|
||||||
if (intermediaryTiny == null) {
|
if (intermediaryTiny == null) {
|
||||||
minecraftVersion = getExtension().getMinecraftProvider().minecraftVersion();
|
intermediaryTiny = getMinecraftProvider().file("intermediary-v2.tiny").toPath();
|
||||||
Preconditions.checkNotNull(minecraftVersion, "Minecraft version cannot be null");
|
|
||||||
|
|
||||||
intermediaryTiny = mappingsDir.resolve(String.format("intermediary-%s-v2.tiny", minecraftVersion));
|
|
||||||
|
|
||||||
if (!Files.exists(intermediaryTiny) || (isRefreshDeps() && !hasRefreshed)) {
|
if (!Files.exists(intermediaryTiny) || (isRefreshDeps() && !hasRefreshed)) {
|
||||||
hasRefreshed = true;
|
hasRefreshed = true;
|
||||||
|
|
||||||
// Download and extract intermediary
|
// Download and extract intermediary
|
||||||
String encodedMinecraftVersion = UrlEscapers.urlFragmentEscaper().escape(minecraftVersion);
|
String encodedMinecraftVersion = UrlEscapers.urlFragmentEscaper().escape(getMinecraftProvider().minecraftVersion());
|
||||||
String intermediaryArtifactUrl = getExtension().getIntermediaryUrl(encodedMinecraftVersion);
|
String intermediaryArtifactUrl = getExtension().getIntermediaryUrl(encodedMinecraftVersion);
|
||||||
Path intermediaryJar = mappingsDir.resolve("v2-intermediary-" + minecraftVersion + ".jar");
|
File intermediaryJar = getMinecraftProvider().file("intermediary-v2.jar");
|
||||||
DownloadUtil.downloadIfChanged(new URL(intermediaryArtifactUrl), intermediaryJar.toFile(), getProject().getLogger());
|
DownloadUtil.downloadIfChanged(new URL(intermediaryArtifactUrl), intermediaryJar, getProject().getLogger());
|
||||||
|
extractMappings(intermediaryJar.toPath(), intermediaryTiny);
|
||||||
extractIntermediary(intermediaryJar, intermediaryTiny);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return intermediaryTiny;
|
return intermediaryTiny;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getMappingsKey() {
|
@Override
|
||||||
return mappingsName + "." + minecraftVersion.replace(' ', '_').replace('.', '_').replace('-', '_') + "." + mappingsVersion;
|
public Path mappingsWorkingDir() {
|
||||||
|
return mappingsWorkingDir;
|
||||||
|
}
|
||||||
|
|
||||||
|
private String createMappingsIdentifier(String mappingsName, String version, String classifier) {
|
||||||
|
// mappingsName . mcVersion . version classifier
|
||||||
|
// Example: net.fabricmc.yarn . 1_16_5 . 1.16.5+build.5 -v2
|
||||||
|
return mappingsName + "." + getMinecraftProvider().minecraftVersion().replace(' ', '_').replace('.', '_').replace('-', '_') + "." + version + classifier;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String mappingsIdentifier() {
|
||||||
|
return mappingsIdentifier;
|
||||||
}
|
}
|
||||||
|
|
||||||
public File getUnpickDefinitionsFile() {
|
public File getUnpickDefinitionsFile() {
|
||||||
return unpickDefinitionsFile;
|
return unpickDefinitions.toFile();
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean hasUnpickDefinitions() {
|
public boolean hasUnpickDefinitions() {
|
||||||
|
|
|
@ -61,7 +61,7 @@ public class MinecraftMappedProvider extends DependencyProvider {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void provide(DependencyInfo dependency, Consumer<Runnable> postPopulationScheduler) throws Exception {
|
public void provide(DependencyInfo dependency, Consumer<Runnable> postPopulationScheduler) throws Exception {
|
||||||
if (!getExtension().getMappingsProvider().tinyMappings.exists()) {
|
if (Files.notExists(getExtension().getMappingsProvider().tinyMappings)) {
|
||||||
throw new RuntimeException("mappings file not found");
|
throw new RuntimeException("mappings file not found");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -145,13 +145,13 @@ public class MinecraftMappedProvider extends DependencyProvider {
|
||||||
|
|
||||||
protected void addDependencies(DependencyInfo dependency, Consumer<Runnable> postPopulationScheduler) {
|
protected void addDependencies(DependencyInfo dependency, Consumer<Runnable> postPopulationScheduler) {
|
||||||
getProject().getDependencies().add(Constants.Configurations.MINECRAFT_NAMED,
|
getProject().getDependencies().add(Constants.Configurations.MINECRAFT_NAMED,
|
||||||
getProject().getDependencies().module("net.minecraft:minecraft:" + getJarVersionString("mapped")));
|
getProject().getDependencies().module("net.minecraft:minecraft-mapped:" + getMinecraftProvider().minecraftVersion() + "/" + getExtension().getMappingsProvider().mappingsIdentifier()));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void initFiles(MinecraftProviderImpl minecraftProvider, MappingsProviderImpl mappingsProvider) {
|
public void initFiles(MinecraftProviderImpl minecraftProvider, MappingsProviderImpl mappingsProvider) {
|
||||||
this.minecraftProvider = minecraftProvider;
|
this.minecraftProvider = minecraftProvider;
|
||||||
minecraftIntermediaryJar = new File(getDirectories().getUserCache(), "minecraft-" + getJarVersionString("intermediary") + ".jar");
|
minecraftIntermediaryJar = new File(getExtension().getMappingsProvider().mappingsWorkingDir().toFile(), "minecraft-intermediary.jar");
|
||||||
minecraftMappedJar = new File(getJarDirectory(getDirectories().getUserCache(), "mapped"), "minecraft-" + getJarVersionString("mapped") + ".jar");
|
minecraftMappedJar = new File(getExtension().getMappingsProvider().mappingsWorkingDir().toFile(), "minecraft-mapped.jar");
|
||||||
}
|
}
|
||||||
|
|
||||||
protected File getJarDirectory(File parentDirectory, String type) {
|
protected File getJarDirectory(File parentDirectory, String type) {
|
||||||
|
@ -159,7 +159,7 @@ public class MinecraftMappedProvider extends DependencyProvider {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected String getJarVersionString(String type) {
|
protected String getJarVersionString(String type) {
|
||||||
return String.format("%s-%s-%s-%s", minecraftProvider.minecraftVersion(), type, getExtension().getMappingsProvider().mappingsName, getExtension().getMappingsProvider().mappingsVersion);
|
return String.format("%s-%s", type, getExtension().getMappingsProvider().mappingsIdentifier());
|
||||||
}
|
}
|
||||||
|
|
||||||
public File getIntermediaryJar() {
|
public File getIntermediaryJar() {
|
||||||
|
@ -171,7 +171,7 @@ public class MinecraftMappedProvider extends DependencyProvider {
|
||||||
}
|
}
|
||||||
|
|
||||||
public File getUnpickedJar() {
|
public File getUnpickedJar() {
|
||||||
return new File(getJarDirectory(getDirectories().getUserCache(), "mapped"), "minecraft-" + getJarVersionString("unpicked") + ".jar");
|
return new File(getExtension().getMappingsProvider().mappingsWorkingDir().toFile(), "minecraft-unpicked.jar");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -51,7 +51,7 @@ public class MinecraftNativesProvider {
|
||||||
this.project = project;
|
this.project = project;
|
||||||
extension = LoomGradleExtension.get(project);
|
extension = LoomGradleExtension.get(project);
|
||||||
|
|
||||||
nativesDir = extension.getFiles().getNativesDirectory(extension.getMinecraftProvider());
|
nativesDir = extension.getMinecraftProvider().nativesDir();
|
||||||
jarStore = extension.getFiles().getNativesJarStore();
|
jarStore = extension.getFiles().getNativesJarStore();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -60,7 +60,7 @@ public class MinecraftNativesProvider {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void provide() throws IOException {
|
private void provide() throws IOException {
|
||||||
if (extension.getFiles().hasCustomNatives()) {
|
if (extension.getMinecraftProvider().hasCustomNatives()) {
|
||||||
if (!nativesDir.exists()) {
|
if (!nativesDir.exists()) {
|
||||||
throw new RuntimeException("Could no find custom natives directory at " + nativesDir.getAbsolutePath());
|
throw new RuntimeException("Could no find custom natives directory at " + nativesDir.getAbsolutePath());
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,8 +29,6 @@ import java.io.File;
|
||||||
import org.gradle.api.Project;
|
import org.gradle.api.Project;
|
||||||
import org.gradle.api.initialization.Settings;
|
import org.gradle.api.initialization.Settings;
|
||||||
|
|
||||||
import net.fabricmc.loom.configuration.providers.MinecraftProvider;
|
|
||||||
|
|
||||||
public interface LoomFiles {
|
public interface LoomFiles {
|
||||||
static LoomFiles create(Project project) {
|
static LoomFiles create(Project project) {
|
||||||
return new LoomFilesProjectImpl(project);
|
return new LoomFilesProjectImpl(project);
|
||||||
|
@ -46,8 +44,6 @@ public interface LoomFiles {
|
||||||
File getProjectBuildCache();
|
File getProjectBuildCache();
|
||||||
File getRemappedModCache();
|
File getRemappedModCache();
|
||||||
File getNativesJarStore();
|
File getNativesJarStore();
|
||||||
boolean hasCustomNatives();
|
|
||||||
File getNativesDirectory(MinecraftProvider minecraftProvider);
|
|
||||||
File getDefaultLog4jConfigFile();
|
File getDefaultLog4jConfigFile();
|
||||||
File getDevLauncherConfig();
|
File getDevLauncherConfig();
|
||||||
File getUnpickLoggingConfigFile();
|
File getUnpickLoggingConfigFile();
|
||||||
|
|
|
@ -29,8 +29,6 @@ import java.util.Objects;
|
||||||
|
|
||||||
import org.gradle.api.Project;
|
import org.gradle.api.Project;
|
||||||
|
|
||||||
import net.fabricmc.loom.configuration.providers.MinecraftProvider;
|
|
||||||
|
|
||||||
public final class LoomFilesProjectImpl extends LoomFilesBaseImpl {
|
public final class LoomFilesProjectImpl extends LoomFilesBaseImpl {
|
||||||
private final Project project;
|
private final Project project;
|
||||||
|
|
||||||
|
@ -57,24 +55,4 @@ public final class LoomFilesProjectImpl extends LoomFilesBaseImpl {
|
||||||
protected File getBuildDir() {
|
protected File getBuildDir() {
|
||||||
return project.getBuildDir();
|
return project.getBuildDir();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean hasCustomNatives() {
|
|
||||||
return project.getProperties().get("fabric.loom.natives.dir") != null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public File getNativesDirectory(MinecraftProvider minecraftProvider) {
|
|
||||||
if (hasCustomNatives()) {
|
|
||||||
return new File((String) project.property("fabric.loom.natives.dir"));
|
|
||||||
}
|
|
||||||
|
|
||||||
File natives = new File(getUserCache(), "natives/" + minecraftProvider.minecraftVersion());
|
|
||||||
|
|
||||||
if (!natives.exists()) {
|
|
||||||
natives.mkdirs();
|
|
||||||
}
|
|
||||||
|
|
||||||
return natives;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,8 +29,6 @@ import java.util.Objects;
|
||||||
|
|
||||||
import org.gradle.api.initialization.Settings;
|
import org.gradle.api.initialization.Settings;
|
||||||
|
|
||||||
import net.fabricmc.loom.configuration.providers.MinecraftProvider;
|
|
||||||
|
|
||||||
public class LoomFilesSettingsImpl extends LoomFilesBaseImpl {
|
public class LoomFilesSettingsImpl extends LoomFilesBaseImpl {
|
||||||
private final Settings settings;
|
private final Settings settings;
|
||||||
|
|
||||||
|
@ -38,16 +36,6 @@ public class LoomFilesSettingsImpl extends LoomFilesBaseImpl {
|
||||||
this.settings = Objects.requireNonNull(settings);
|
this.settings = Objects.requireNonNull(settings);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean hasCustomNatives() {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public File getNativesDirectory(MinecraftProvider minecraftProvider) {
|
|
||||||
throw new IllegalStateException("You can not access natives directory from setting stage");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected File getGradleUserHomeDir() {
|
protected File getGradleUserHomeDir() {
|
||||||
return settings.getGradle().getGradleUserHomeDir();
|
return settings.getGradle().getGradleUserHomeDir();
|
||||||
|
|
|
@ -107,7 +107,7 @@ public abstract class LoomGradleExtensionApiImpl implements LoomGradleExtensionA
|
||||||
LayeredMappingSpecBuilder builder = new LayeredMappingSpecBuilder();
|
LayeredMappingSpecBuilder builder = new LayeredMappingSpecBuilder();
|
||||||
action.execute(builder);
|
action.execute(builder);
|
||||||
LayeredMappingSpec builtSpec = builder.build();
|
LayeredMappingSpec builtSpec = builder.build();
|
||||||
return new LayeredMappingsDependency(new GradleMappingContext(getProject(), "layers_" + builtSpec.getVersion().replace("+", "_").replace(".", "_")), builtSpec, builtSpec.getVersion());
|
return new LayeredMappingsDependency(new GradleMappingContext(getProject(), builtSpec.getVersion().replace("+", "_").replace(".", "_")), builtSpec, builtSpec.getVersion());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -81,7 +81,7 @@ public class LoomGradleExtensionImpl extends LoomGradleExtensionApiImpl implemen
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public synchronized File getNextMixinMappings() {
|
public synchronized File getNextMixinMappings() {
|
||||||
File mixinMapping = new File(getFiles().getProjectBuildCache(), "mixin-map-" + getMinecraftProvider().minecraftVersion() + "-" + getMappingsProvider().mappingsVersion + "." + mixinMappings.size() + ".tiny");
|
File mixinMapping = new File(getFiles().getProjectBuildCache(), "mixin-map-" + getMappingsProvider().mappingsIdentifier() + "." + mixinMappings.size() + ".tiny");
|
||||||
mixinMappings.add(mixinMapping);
|
mixinMappings.add(mixinMapping);
|
||||||
return mixinMapping;
|
return mixinMapping;
|
||||||
}
|
}
|
||||||
|
|
|
@ -62,7 +62,7 @@ public class GenerateSourcesTask extends AbstractLoomTask {
|
||||||
@TaskAction
|
@TaskAction
|
||||||
public void doTask() throws Throwable {
|
public void doTask() throws Throwable {
|
||||||
int threads = Runtime.getRuntime().availableProcessors();
|
int threads = Runtime.getRuntime().availableProcessors();
|
||||||
Path javaDocs = getExtension().getMappingsProvider().tinyMappings.toPath();
|
Path javaDocs = getExtension().getMappingsProvider().tinyMappings;
|
||||||
Collection<Path> libraries = getProject().getConfigurations().getByName(Constants.Configurations.MINECRAFT_DEPENDENCIES).getFiles()
|
Collection<Path> libraries = getProject().getConfigurations().getByName(Constants.Configurations.MINECRAFT_DEPENDENCIES).getFiles()
|
||||||
.stream().map(File::toPath).collect(Collectors.toSet());
|
.stream().map(File::toPath).collect(Collectors.toSet());
|
||||||
|
|
||||||
|
|
|
@ -33,7 +33,7 @@ import java.nio.charset.StandardCharsets
|
||||||
import static org.gradle.testkit.runner.TaskOutcome.SUCCESS
|
import static org.gradle.testkit.runner.TaskOutcome.SUCCESS
|
||||||
|
|
||||||
class UnpickTest extends Specification implements ProjectTestTrait {
|
class UnpickTest extends Specification implements ProjectTestTrait {
|
||||||
static final String MAPPINGS = "21w13a-mapped-net.fabricmc.yarn-21w13a+build.30-v2"
|
static final String MAPPINGS = "21w13a/net.fabricmc.yarn.21w13a.21w13a+build.30-v2"
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
String name() {
|
String name() {
|
||||||
|
|
|
@ -121,6 +121,6 @@ trait ProjectTestTrait {
|
||||||
}
|
}
|
||||||
|
|
||||||
File getGeneratedSources(String mappings, String gradleVersion = DEFAULT_GRADLE) {
|
File getGeneratedSources(String mappings, String gradleVersion = DEFAULT_GRADLE) {
|
||||||
return new File(gradleHomeDirectory(gradleVersion), "caches/fabric-loom/${mappings}/minecraft-${mappings}-sources.jar")
|
return new File(gradleHomeDirectory(gradleVersion), "caches/fabric-loom/${mappings}/minecraft-mapped-sources.jar")
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue