add field name population on mapping download
This commit is contained in:
parent
823854f2a1
commit
b1d5bd0536
13 changed files with 130 additions and 50 deletions
|
@ -34,8 +34,8 @@ dependencies {
|
|||
implementation ('org.zeroturnaround:zt-zip:1.13')
|
||||
implementation ('com.google.code.gson:gson:2.8.5')
|
||||
implementation ('com.google.guava:guava:27.0-jre')
|
||||
implementation ('net.fabricmc:stitch:0.1.0.+')
|
||||
implementation ('net.fabricmc:tiny-remapper:0.1.0.17') {
|
||||
implementation ('net.fabricmc:stitch:0.1.0.8')
|
||||
implementation ('net.fabricmc:tiny-remapper:0.1.0.18') {
|
||||
transitive = false
|
||||
}
|
||||
|
||||
|
|
|
@ -25,6 +25,7 @@
|
|||
package net.fabricmc.loom;
|
||||
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import net.fabricmc.loom.providers.MinecraftMappedProvider;
|
||||
import net.fabricmc.loom.providers.MinecraftProvider;
|
||||
import net.fabricmc.loom.providers.ModRemapperProvider;
|
||||
import net.fabricmc.loom.providers.PomfProvider;
|
||||
|
@ -79,6 +80,9 @@ public class AbstractPlugin implements Plugin<Project> {
|
|||
|
||||
project.getConfigurations().maybeCreate(Constants.MAPPINGS);
|
||||
|
||||
Configuration minecraftMappedConfig = project.getConfigurations().maybeCreate(Constants.MINECRAFT_MAPPED);
|
||||
minecraftMappedConfig.setTransitive(false); // The launchers do not recurse dependencies
|
||||
|
||||
configureIDEs();
|
||||
configureCompile();
|
||||
|
||||
|
@ -212,8 +216,8 @@ public class AbstractPlugin implements Plugin<Project> {
|
|||
LoomDependencyManager dependencyManager = new LoomDependencyManager();
|
||||
extension.setDependencyManager(dependencyManager);
|
||||
|
||||
dependencyManager.addProvider(new PomfProvider());
|
||||
dependencyManager.addProvider(new MinecraftProvider());
|
||||
dependencyManager.addProvider(new PomfProvider());
|
||||
dependencyManager.addProvider(new ModRemapperProvider());
|
||||
|
||||
dependencyManager.handleDependencies(project1);
|
||||
|
|
|
@ -24,6 +24,7 @@
|
|||
|
||||
package net.fabricmc.loom;
|
||||
|
||||
import net.fabricmc.loom.providers.MinecraftMappedProvider;
|
||||
import net.fabricmc.loom.providers.MinecraftProvider;
|
||||
import net.fabricmc.loom.providers.PomfProvider;
|
||||
import net.fabricmc.loom.util.LoomDependencyManager;
|
||||
|
@ -60,6 +61,10 @@ public class LoomGradleExtension {
|
|||
return getDependencyManager().getProvider(MinecraftProvider.class);
|
||||
}
|
||||
|
||||
public MinecraftMappedProvider getMinecraftMappedProvider(){
|
||||
return getPomfProvider().mappedProvider;
|
||||
}
|
||||
|
||||
public PomfProvider getPomfProvider(){
|
||||
return getDependencyManager().getProvider(PomfProvider.class);
|
||||
}
|
||||
|
|
|
@ -39,7 +39,7 @@ public class LoomGradlePlugin extends AbstractPlugin {
|
|||
|
||||
makeTask("genIdeaWorkspace", GenIdeaProjectTask.class).dependsOn("idea").setGroup("ide");
|
||||
|
||||
makeTask("runClient", RunClientTask.class).dependsOn("buildNeeded").setGroup("minecraft");
|
||||
makeTask("runServer", RunServerTask.class).dependsOn("buildNeeded").setGroup("minecraft");
|
||||
makeTask("runClient", RunClientTask.class).dependsOn("buildNeeded").setGroup("minecraftMapped");
|
||||
makeTask("runServer", RunServerTask.class).dependsOn("buildNeeded").setGroup("minecraftMapped");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -36,10 +36,7 @@ import java.io.IOException;
|
|||
import java.util.Collection;
|
||||
|
||||
public class MinecraftJarProvider {
|
||||
|
||||
public File MINECRAFT_INTERMEDIARY_JAR;
|
||||
public File MINECRAFT_MERGED_JAR;
|
||||
public File MINECRAFT_MAPPED_JAR;
|
||||
|
||||
MinecraftProvider minecraftProvider;
|
||||
|
||||
|
@ -53,21 +50,6 @@ public class MinecraftJarProvider {
|
|||
if (!MINECRAFT_MERGED_JAR.exists()) {
|
||||
mergeJars(project);
|
||||
}
|
||||
|
||||
if(!getMappedJar().exists() || !getIntermediaryJar().exists()){
|
||||
if (getMappedJar().exists()) {
|
||||
getMappedJar().delete();
|
||||
}
|
||||
if (getIntermediaryJar().exists()) {
|
||||
getIntermediaryJar().delete();
|
||||
}
|
||||
new MapJarsTiny().mapJars(this, project);
|
||||
}
|
||||
|
||||
if (!MINECRAFT_MAPPED_JAR.exists()) {
|
||||
throw new RuntimeException("mapped jar not found");
|
||||
}
|
||||
minecraftProvider.addDependency(MINECRAFT_MAPPED_JAR, project);
|
||||
}
|
||||
|
||||
public void mergeJars(Project project) throws IOException {
|
||||
|
@ -89,26 +71,11 @@ public class MinecraftJarProvider {
|
|||
private void initFiles(Project project, MinecraftProvider minecraftProvider) {
|
||||
LoomGradleExtension extension = project.getExtensions().getByType(LoomGradleExtension.class);
|
||||
PomfProvider pomfProvider = extension.getPomfProvider();
|
||||
MINECRAFT_INTERMEDIARY_JAR = new File(extension.getUserCache(), minecraftProvider.minecraftVersion + "-intermediary.jar");
|
||||
MINECRAFT_MERGED_JAR = new File(extension.getUserCache(), minecraftProvider.minecraftVersion + "-merged.jar");
|
||||
MINECRAFT_MAPPED_JAR = new File(extension.getUserCache(), minecraftProvider.minecraftVersion + "-mapped-" + pomfProvider.pomfVersion + ".jar");
|
||||
|
||||
}
|
||||
|
||||
public Collection<File> getMapperPaths() {
|
||||
return minecraftProvider.libraryProvider.getLibraries();
|
||||
}
|
||||
|
||||
public File getInputJar() {
|
||||
return MINECRAFT_MERGED_JAR;
|
||||
}
|
||||
|
||||
public File getIntermediaryJar() {
|
||||
return MINECRAFT_INTERMEDIARY_JAR;
|
||||
}
|
||||
|
||||
public File getMappedJar() {
|
||||
return MINECRAFT_MAPPED_JAR;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,83 @@
|
|||
/*
|
||||
* This file is part of fabric-loom, licensed under the MIT License (MIT).
|
||||
*
|
||||
* Copyright (c) 2016, 2017, 2018 FabricMC
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
package net.fabricmc.loom.providers;
|
||||
|
||||
import net.fabricmc.loom.LoomGradleExtension;
|
||||
import net.fabricmc.loom.util.Constants;
|
||||
import net.fabricmc.loom.util.DependencyProvider;
|
||||
import net.fabricmc.loom.util.MapJarsTiny;
|
||||
import org.gradle.api.Project;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Collection;
|
||||
|
||||
public class MinecraftMappedProvider extends DependencyProvider {
|
||||
public File MINECRAFT_MAPPED_JAR;
|
||||
public File MINECRAFT_INTERMEDIARY_JAR;
|
||||
|
||||
private MinecraftProvider minecraftProvider;
|
||||
|
||||
@Override
|
||||
public void provide(DependencyInfo dependency, Project project, LoomGradleExtension extension) throws Exception {
|
||||
if(!getMappedJar().exists() || !getIntermediaryJar().exists()){
|
||||
if (getMappedJar().exists()) {
|
||||
getMappedJar().delete();
|
||||
}
|
||||
if (getIntermediaryJar().exists()) {
|
||||
getIntermediaryJar().delete();
|
||||
}
|
||||
new MapJarsTiny().mapJars(minecraftProvider.jarProvider, this, project);
|
||||
}
|
||||
|
||||
if (!MINECRAFT_MAPPED_JAR.exists()) {
|
||||
throw new RuntimeException("mapped jar not found");
|
||||
}
|
||||
minecraftProvider.addDependency(MINECRAFT_MAPPED_JAR, project);
|
||||
}
|
||||
|
||||
public void initFiles(Project project, MinecraftProvider minecraftProvider, PomfProvider pomfProvider) {
|
||||
LoomGradleExtension extension = project.getExtensions().getByType(LoomGradleExtension.class);
|
||||
this.minecraftProvider = minecraftProvider;
|
||||
MINECRAFT_INTERMEDIARY_JAR = new File(extension.getUserCache(), minecraftProvider.minecraftVersion + "-intermediary.jar");
|
||||
MINECRAFT_MAPPED_JAR = new File(extension.getUserCache(), minecraftProvider.minecraftVersion + "-mapped-" + pomfProvider.pomfVersion + ".jar");
|
||||
}
|
||||
|
||||
public Collection<File> getMapperPaths() {
|
||||
return minecraftProvider.libraryProvider.getLibraries();
|
||||
}
|
||||
|
||||
public File getIntermediaryJar() {
|
||||
return MINECRAFT_INTERMEDIARY_JAR;
|
||||
}
|
||||
|
||||
public File getMappedJar() {
|
||||
return MINECRAFT_MAPPED_JAR;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTargetConfig() {
|
||||
return Constants.MINECRAFT_MAPPED;
|
||||
}
|
||||
}
|
|
@ -70,7 +70,6 @@ public class MinecraftProvider extends DependencyProvider {
|
|||
|
||||
libraryProvider = new MinecraftLibraryProvider();
|
||||
libraryProvider.provide(this, project);
|
||||
|
||||
jarProvider = new MinecraftJarProvider(project, this);
|
||||
}
|
||||
|
||||
|
|
|
@ -27,6 +27,7 @@ package net.fabricmc.loom.providers;
|
|||
import net.fabricmc.loom.LoomGradleExtension;
|
||||
import net.fabricmc.loom.util.Constants;
|
||||
import net.fabricmc.loom.util.DependencyProvider;
|
||||
import net.fabricmc.stitch.commands.CommandProposeFieldNames;
|
||||
import org.gradle.api.Project;
|
||||
|
||||
import java.io.File;
|
||||
|
@ -38,17 +39,21 @@ import java.nio.file.Path;
|
|||
//TODO fix local mappings
|
||||
//TODO possibly use maven for mappings, can fix above at the same time
|
||||
public class PomfProvider extends DependencyProvider {
|
||||
public MinecraftMappedProvider mappedProvider;
|
||||
|
||||
public String minecraftVersion;
|
||||
public String pomfVersion;
|
||||
|
||||
private File POMF_DIR;
|
||||
public File MAPPINGS_TINY_BASE;
|
||||
public File MAPPINGS_TINY;
|
||||
|
||||
public File MAPPINGS_MIXIN_EXPORT;
|
||||
|
||||
@Override
|
||||
public void provide(DependencyInfo dependency, Project project, LoomGradleExtension extension) throws Exception {
|
||||
MinecraftProvider minecraftProvider = getDependencyManager().getProvider(MinecraftProvider.class);
|
||||
|
||||
project.getLogger().lifecycle(":setting up pomf " + dependency.getDependency().getVersion());
|
||||
|
||||
String version = dependency.getDependency().getVersion();
|
||||
|
@ -65,20 +70,31 @@ public class PomfProvider extends DependencyProvider {
|
|||
POMF_DIR.mkdir();
|
||||
}
|
||||
|
||||
|
||||
if (!MAPPINGS_TINY.exists()) {
|
||||
if (!MAPPINGS_TINY_BASE.exists() || !MAPPINGS_TINY.exists()) {
|
||||
project.getLogger().lifecycle(":extracting " + mappingsJar.getName());
|
||||
try (FileSystem fileSystem = FileSystems.newFileSystem(mappingsJar.toPath(), null)) {
|
||||
Path fileToExtract = fileSystem.getPath("mappings/mappings.tiny");
|
||||
Files.copy(fileToExtract, MAPPINGS_TINY.toPath());
|
||||
Files.copy(fileToExtract, MAPPINGS_TINY_BASE.toPath());
|
||||
}
|
||||
|
||||
project.getLogger().lifecycle(":populating field names");
|
||||
new CommandProposeFieldNames().run(new String[] {
|
||||
minecraftProvider.MINECRAFT_MERGED_JAR.getAbsolutePath(),
|
||||
MAPPINGS_TINY_BASE.getAbsolutePath(),
|
||||
MAPPINGS_TINY.getAbsolutePath()
|
||||
});
|
||||
}
|
||||
|
||||
mappedProvider = new MinecraftMappedProvider();
|
||||
mappedProvider.initFiles(project, minecraftProvider, this);
|
||||
mappedProvider.provide(dependency, project, extension);
|
||||
}
|
||||
|
||||
public void initFiles(Project project) {
|
||||
LoomGradleExtension extension = project.getExtensions().getByType(LoomGradleExtension.class);
|
||||
POMF_DIR = new File(extension.getUserCache(), "pomf");
|
||||
|
||||
MAPPINGS_TINY_BASE = new File(POMF_DIR, "pomf-tiny-" + minecraftVersion + "." + pomfVersion + "-base");
|
||||
MAPPINGS_TINY = new File(POMF_DIR, "pomf-tiny-" + minecraftVersion + "." + pomfVersion);
|
||||
MAPPINGS_MIXIN_EXPORT = new File(Constants.CACHE_FILES, "mixin-map-" + minecraftVersion + "." + pomfVersion + ".tiny");
|
||||
}
|
||||
|
|
|
@ -25,6 +25,7 @@
|
|||
package net.fabricmc.loom.task;
|
||||
|
||||
import net.fabricmc.loom.LoomGradleExtension;
|
||||
import net.fabricmc.loom.providers.MinecraftMappedProvider;
|
||||
import net.fabricmc.loom.providers.PomfProvider;
|
||||
import net.fabricmc.loom.util.Constants;
|
||||
import net.fabricmc.loom.util.MinecraftVersionInfo;
|
||||
|
@ -42,7 +43,6 @@ public class RunClientTask extends JavaExec {
|
|||
MinecraftVersionInfo minecraftVersionInfo = extension.getMinecraftProvider().versionInfo;
|
||||
PomfProvider pomfProvider = extension.getPomfProvider();
|
||||
|
||||
|
||||
List<String> libs = new ArrayList<>();
|
||||
for (File file : getProject().getConfigurations().getByName("compile").getFiles()) {
|
||||
libs.add(file.getAbsolutePath());
|
||||
|
|
|
@ -44,5 +44,6 @@ public class Constants {
|
|||
|
||||
public static final String COMPILE_MODS = "modCompile";
|
||||
public static final String MINECRAFT = "minecraft";
|
||||
public static final String MINECRAFT_MAPPED = "minecraftMapped";
|
||||
public static final String MAPPINGS = "mappings";
|
||||
}
|
||||
|
|
|
@ -29,7 +29,9 @@ import org.gradle.api.Project;
|
|||
import org.gradle.api.artifacts.Configuration;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
public class LoomDependencyManager {
|
||||
|
||||
|
@ -58,7 +60,7 @@ public class LoomDependencyManager {
|
|||
public void handleDependencies(Project project){
|
||||
project.getLogger().lifecycle(":setting up loom dependencies");
|
||||
LoomGradleExtension extension = project.getExtensions().getByType(LoomGradleExtension.class);
|
||||
List<String> targetConfigs = new ArrayList<>();
|
||||
Set<String> targetConfigs = new LinkedHashSet<>();
|
||||
for(DependencyProvider provider : dependencyProviderList){
|
||||
targetConfigs.add(provider.getTargetConfig());
|
||||
}
|
||||
|
|
|
@ -27,6 +27,7 @@ package net.fabricmc.loom.util;
|
|||
|
||||
import net.fabricmc.loom.LoomGradleExtension;
|
||||
import net.fabricmc.loom.providers.MinecraftJarProvider;
|
||||
import net.fabricmc.loom.providers.MinecraftMappedProvider;
|
||||
import net.fabricmc.loom.providers.PomfProvider;
|
||||
import net.fabricmc.tinyremapper.OutputConsumerPath;
|
||||
import net.fabricmc.tinyremapper.TinyRemapper;
|
||||
|
@ -40,20 +41,20 @@ import java.util.Arrays;
|
|||
|
||||
public class MapJarsTiny {
|
||||
|
||||
public void mapJars(MinecraftJarProvider jarProvider, Project project) throws IOException {
|
||||
public void mapJars(MinecraftJarProvider jarProvider, MinecraftMappedProvider mapProvider, Project project) throws IOException {
|
||||
String fromM = "official";
|
||||
|
||||
LoomGradleExtension extension = project.getExtensions().getByType(LoomGradleExtension.class);
|
||||
PomfProvider pomfProvider = extension.getPomfProvider();
|
||||
|
||||
Path mappings = pomfProvider.MAPPINGS_TINY.toPath();
|
||||
Path[] classpath = jarProvider.getMapperPaths().stream()
|
||||
Path[] classpath = mapProvider.getMapperPaths().stream()
|
||||
.map(File::toPath)
|
||||
.toArray(Path[]::new);
|
||||
|
||||
Path input = jarProvider.getInputJar().toPath();
|
||||
Path outputMapped = jarProvider.getMappedJar().toPath();
|
||||
Path outputIntermediary = jarProvider.getIntermediaryJar().toPath();
|
||||
Path outputMapped = mapProvider.getMappedJar().toPath();
|
||||
Path outputIntermediary = mapProvider.getIntermediaryJar().toPath();
|
||||
|
||||
for (String toM : Arrays.asList("named", "intermediary")) {
|
||||
Path output = "named".equals(toM) ? outputMapped : outputIntermediary;
|
||||
|
|
|
@ -29,6 +29,7 @@ import com.google.gson.GsonBuilder;
|
|||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonObject;
|
||||
import net.fabricmc.loom.LoomGradleExtension;
|
||||
import net.fabricmc.loom.providers.MinecraftMappedProvider;
|
||||
import net.fabricmc.loom.providers.MinecraftProvider;
|
||||
import net.fabricmc.loom.providers.PomfProvider;
|
||||
import net.fabricmc.tinyremapper.OutputConsumerPath;
|
||||
|
@ -80,12 +81,13 @@ public class ModProcessor {
|
|||
String toM = "named";
|
||||
|
||||
MinecraftProvider minecraftProvider = extension.getMinecraftProvider();
|
||||
MinecraftMappedProvider mappedProvider = extension.getMinecraftMappedProvider();
|
||||
PomfProvider pomfProvider = extension.getPomfProvider();
|
||||
|
||||
File mappingsFile = pomfProvider.MAPPINGS_TINY;
|
||||
Path mappings = mappingsFile.toPath();
|
||||
Path mc = minecraftProvider.jarProvider.MINECRAFT_INTERMEDIARY_JAR.toPath();
|
||||
Path[] mcDeps = minecraftProvider.jarProvider.getMapperPaths().stream()
|
||||
Path mc = mappedProvider.MINECRAFT_INTERMEDIARY_JAR.toPath();
|
||||
Path[] mcDeps = mappedProvider.getMapperPaths().stream()
|
||||
.map(File::toPath)
|
||||
.toArray(Path[]::new);
|
||||
Collection<File> modCompileFiles = project.getConfigurations().getByName(Constants.COMPILE_MODS).getFiles();
|
||||
|
|
Loading…
Reference in a new issue