Ugly fix to mercury classpath not having jetbrains annotations

dev/0.11
modmuss50 2020-10-10 21:13:12 +01:00
parent a8e0c8edbb
commit 5c4d89bd0d
3 changed files with 21 additions and 3 deletions

View File

@ -40,12 +40,15 @@ import java.util.stream.Collectors;
import org.apache.commons.io.FileUtils; import org.apache.commons.io.FileUtils;
import org.gradle.api.Project; import org.gradle.api.Project;
import org.gradle.api.artifacts.Dependency;
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.RemappedConfigurationEntry; import net.fabricmc.loom.util.RemappedConfigurationEntry;
public class LaunchProvider extends DependencyProvider { public class LaunchProvider extends DependencyProvider {
public Dependency annotationDependency;
public LaunchProvider(Project project) { public LaunchProvider(Project project) {
super(project); super(project);
} }
@ -77,7 +80,7 @@ public class LaunchProvider extends DependencyProvider {
addDependency(Constants.Dependencies.DEV_LAUNCH_INJECTOR + Constants.Dependencies.Versions.DEV_LAUNCH_INJECTOR, "runtimeOnly"); addDependency(Constants.Dependencies.DEV_LAUNCH_INJECTOR + Constants.Dependencies.Versions.DEV_LAUNCH_INJECTOR, "runtimeOnly");
addDependency(Constants.Dependencies.TERMINAL_CONSOLE_APPENDER + Constants.Dependencies.Versions.TERMINAL_CONSOLE_APPENDER, "runtimeOnly"); addDependency(Constants.Dependencies.TERMINAL_CONSOLE_APPENDER + Constants.Dependencies.Versions.TERMINAL_CONSOLE_APPENDER, "runtimeOnly");
addDependency(Constants.Dependencies.JETBRAINS_ANNOTATIONS + Constants.Dependencies.Versions.JETBRAINS_ANNOTATIONS, "compileOnly"); annotationDependency = addDependency(Constants.Dependencies.JETBRAINS_ANNOTATIONS + Constants.Dependencies.Versions.JETBRAINS_ANNOTATIONS, "compileOnly");
postPopulationScheduler.accept(this::writeRemapClassPath); postPopulationScheduler.accept(this::writeRemapClassPath);
} }

View File

@ -67,12 +67,12 @@ public abstract class DependencyProvider {
addDependency(object, "compile"); addDependency(object, "compile");
} }
public void addDependency(Object object, String target) { public Dependency addDependency(Object object, String target) {
if (object instanceof File) { if (object instanceof File) {
object = project.files(object); object = project.files(object);
} }
project.getDependencies().add(target, object); return project.getDependencies().add(target, object);
} }
public void register(LoomDependencyManager dependencyManager) { public void register(LoomDependencyManager dependencyManager) {

View File

@ -30,16 +30,19 @@ import java.nio.file.Files;
import java.nio.file.Path; import java.nio.file.Path;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Set;
import java.util.function.Consumer; import java.util.function.Consumer;
import org.cadixdev.lorenz.MappingSet; import org.cadixdev.lorenz.MappingSet;
import org.cadixdev.mercury.Mercury; import org.cadixdev.mercury.Mercury;
import org.cadixdev.mercury.remapper.MercuryRemapper; import org.cadixdev.mercury.remapper.MercuryRemapper;
import org.gradle.api.Project; import org.gradle.api.Project;
import org.gradle.api.artifacts.Dependency;
import org.zeroturnaround.zip.ZipUtil; import org.zeroturnaround.zip.ZipUtil;
import net.fabricmc.loom.LoomGradleExtension; import net.fabricmc.loom.LoomGradleExtension;
import net.fabricmc.loom.providers.MappingsProvider; import net.fabricmc.loom.providers.MappingsProvider;
import net.fabricmc.loom.providers.LaunchProvider;
import net.fabricmc.loom.util.progress.ProgressLogger; import net.fabricmc.loom.util.progress.ProgressLogger;
import net.fabricmc.lorenztiny.TinyMappingsReader; import net.fabricmc.lorenztiny.TinyMappingsReader;
import net.fabricmc.mapping.tree.TinyTree; import net.fabricmc.mapping.tree.TinyTree;
@ -176,6 +179,18 @@ public class SourceRemapper {
m.getClassPath().add(extension.getMinecraftMappedProvider().getMappedJar().toPath()); m.getClassPath().add(extension.getMinecraftMappedProvider().getMappedJar().toPath());
m.getClassPath().add(extension.getMinecraftMappedProvider().getIntermediaryJar().toPath()); m.getClassPath().add(extension.getMinecraftMappedProvider().getIntermediaryJar().toPath());
Dependency annotationDependency = extension.getDependencyManager().getProvider(LaunchProvider.class).annotationDependency;
Set<File> files = project.getConfigurations().getByName("compileOnly")
.files(annotationDependency);
if (files.size() != 1) {
throw new RuntimeException(String.format("Found %d files for the annotations, expected 1", files.size()));
}
for (File file : files) {
m.getClassPath().add(file.toPath());
}
m.getProcessors().add(MercuryRemapper.create(mappings)); m.getProcessors().add(MercuryRemapper.create(mappings));
return m; return m;