mirror of
https://github.com/architectury/architectury-loom.git
synced 2026-04-01 21:17:46 -05:00
Fix compilation errors
This commit is contained in:
@@ -9,6 +9,7 @@ import java.util.function.Function;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import org.gradle.api.Project;
|
||||
import org.gradle.api.logging.Logger;
|
||||
import org.gradle.api.logging.Logging;
|
||||
import org.gradle.api.tasks.SourceSet;
|
||||
@@ -79,12 +80,13 @@ public final class ModMetadataFiles {
|
||||
/**
|
||||
* Reads the first mod metadata file from source sets.
|
||||
*
|
||||
* @param project the project owning the source sets
|
||||
* @param sourceSets the source sets to read from
|
||||
* @return the mod metadata file, or {@code null} if not found
|
||||
*/
|
||||
public static @Nullable ModMetadataFile fromSourceSets(SourceSet... sourceSets) throws IOException {
|
||||
public static @Nullable ModMetadataFile fromSourceSets(Project project, SourceSet... sourceSets) throws IOException {
|
||||
for (final String filePath : SINGLE_FILE_METADATA_TYPES.keySet()) {
|
||||
final @Nullable File file = SourceSetHelper.findFirstFileInResource(filePath, sourceSets);
|
||||
final @Nullable File file = SourceSetHelper.findFirstFileInResource(filePath, project, sourceSets);
|
||||
|
||||
if (file != null) {
|
||||
return SINGLE_FILE_METADATA_TYPES.get(filePath).apply(Files.readAllBytes(file.toPath()));
|
||||
|
||||
@@ -174,7 +174,7 @@ public class ModProcessor {
|
||||
}
|
||||
|
||||
MappingOption mappingOption = MappingOption.forPlatform(extension);
|
||||
MemoryMappingTree mappings = mappingConfiguration.getMappingsService(project, serviceManager, mappingOption).getMappingTree();
|
||||
MemoryMappingTree mappings = mappingConfiguration.getMappingsService(project, serviceFactory, mappingOption).getMappingTree();
|
||||
LoggerFilter.replaceSystemOut();
|
||||
|
||||
TinyRemapper.Builder builder = TinyRemapper.newRemapper()
|
||||
|
||||
@@ -1,84 +0,0 @@
|
||||
/*
|
||||
* This file is part of fabric-loom, licensed under the MIT License (MIT).
|
||||
*
|
||||
* Copyright (c) 2022 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.configuration.providers.forge;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Collections;
|
||||
import java.util.Set;
|
||||
|
||||
import org.gradle.api.artifacts.Dependency;
|
||||
import org.gradle.api.artifacts.ModuleDependency;
|
||||
import org.gradle.api.artifacts.SelfResolvingDependency;
|
||||
import org.gradle.api.internal.artifacts.dependencies.AbstractModuleDependency;
|
||||
import org.gradle.api.tasks.TaskDependency;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public class SelfBreakingDependency extends AbstractModuleDependency implements SelfResolvingDependency {
|
||||
public SelfBreakingDependency() {
|
||||
super(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<File> resolve() {
|
||||
throw new RuntimeException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<File> resolve(boolean b) {
|
||||
throw new RuntimeException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public TaskDependency getBuildDependencies() {
|
||||
return task -> Collections.emptySet();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public String getGroup() {
|
||||
return "break";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "break";
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public String getVersion() {
|
||||
return "break";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean contentEquals(Dependency dependency) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ModuleDependency copy() {
|
||||
return this;
|
||||
}
|
||||
}
|
||||
@@ -47,11 +47,6 @@ import com.google.common.base.Stopwatch;
|
||||
import com.google.common.base.Supplier;
|
||||
import com.google.gson.JsonObject;
|
||||
import dev.architectury.loom.util.MappingOption;
|
||||
|
||||
import dev.architectury.loom.util.MappingOption;
|
||||
|
||||
import net.fabricmc.loom.util.service.ServiceFactory;
|
||||
|
||||
import org.apache.tools.ant.util.StringUtils;
|
||||
import org.gradle.api.Project;
|
||||
import org.gradle.api.artifacts.Configuration;
|
||||
@@ -74,6 +69,7 @@ import net.fabricmc.loom.util.Constants;
|
||||
import net.fabricmc.loom.util.DeletingFileVisitor;
|
||||
import net.fabricmc.loom.util.FileSystemUtil;
|
||||
import net.fabricmc.loom.util.ZipUtils;
|
||||
import net.fabricmc.loom.util.service.ScopedServiceFactory;
|
||||
import net.fabricmc.loom.util.service.ServiceFactory;
|
||||
import net.fabricmc.loom.util.srg.ForgeMappingsMerger;
|
||||
import net.fabricmc.loom.util.srg.MCPReader;
|
||||
@@ -271,8 +267,8 @@ public class MappingConfiguration {
|
||||
}
|
||||
|
||||
if (Files.notExists(srgToNamedSrg) || extension.refreshDeps()) {
|
||||
try (var serviceManager = new ScopedSharedServiceManager()) {
|
||||
TinyMappingsService mappingsService = getMappingsService(serviceManager, MappingOption.WITH_SRG);
|
||||
try (var serviceFactory = new ScopedServiceFactory()) {
|
||||
TinyMappingsService mappingsService = getMappingsService(project, serviceFactory, MappingOption.WITH_SRG);
|
||||
SrgNamedWriter.writeTo(project.getLogger(), srgToNamedSrg, mappingsService.getMappingTree(), "srg", "named");
|
||||
}
|
||||
}
|
||||
@@ -384,7 +380,7 @@ public class MappingConfiguration {
|
||||
|
||||
private void readAndMergeMCP(Project project, ServiceFactory serviceFactory, MinecraftProvider minecraftProvider, Path mcpJar) throws Exception {
|
||||
LoomGradleExtension extension = LoomGradleExtension.get(project);
|
||||
IntermediateMappingsService intermediateMappingsService = IntermediateMappingsService.getInstance(serviceManager, project, minecraftProvider);
|
||||
IntermediateMappingsService intermediateMappingsService = serviceFactory.get(IntermediateMappingsService.createOptions(project, minecraftProvider));
|
||||
Path intermediaryTinyPath = intermediateMappingsService.getIntermediaryTiny();
|
||||
SrgProvider provider = extension.getSrgProvider();
|
||||
|
||||
|
||||
@@ -72,7 +72,6 @@ public abstract class GenEclipseRunsTask extends AbstractLoomTask {
|
||||
LoomGradleExtension extension = LoomGradleExtension.get(project);
|
||||
|
||||
List<EclipseRunConfig> runConfigs = new ArrayList<>();
|
||||
File dataRunConfigs = new File(getProject().getRootDir(), eclipseModel.getProject().getName() + "_data.launch");
|
||||
|
||||
for (RunConfigSettings settings : extension.getRunConfigs()) {
|
||||
if (!settings.isIdeConfigGenerated()) {
|
||||
|
||||
@@ -57,8 +57,8 @@ import net.fabricmc.loom.util.DependencyDownloader;
|
||||
import net.fabricmc.loom.util.FileSystemUtil;
|
||||
import net.fabricmc.loom.util.ForgeToolExecutor;
|
||||
import net.fabricmc.loom.util.SourceRemapper;
|
||||
import net.fabricmc.loom.util.service.ScopedSharedServiceManager;
|
||||
import net.fabricmc.loom.util.service.SharedServiceManager;
|
||||
import net.fabricmc.loom.util.service.ScopedServiceFactory;
|
||||
import net.fabricmc.loom.util.service.ServiceFactory;
|
||||
|
||||
// TODO: NeoForge support
|
||||
public abstract class GenerateForgePatchedSourcesTask extends AbstractLoomTask {
|
||||
@@ -94,7 +94,7 @@ public abstract class GenerateForgePatchedSourcesTask extends AbstractLoomTask {
|
||||
throw new UnsupportedOperationException("Cannot run Forge's patched decompilation with a processed Minecraft jar");
|
||||
}
|
||||
|
||||
try (var tempFiles = new TempFiles(); var serviceManager = new ScopedSharedServiceManager()) {
|
||||
try (var tempFiles = new TempFiles(); var serviceFactory = new ScopedServiceFactory()) {
|
||||
Path cache = tempFiles.directory("loom-decompilation");
|
||||
|
||||
// Transform game jar before decompiling
|
||||
@@ -109,9 +109,9 @@ public abstract class GenerateForgePatchedSourcesTask extends AbstractLoomTask {
|
||||
getLogger().lifecycle(":applying Forge patches");
|
||||
Path patched = sourcePatch(cache, rawDecompiled);
|
||||
// Step 3: remap
|
||||
remap(patched, serviceManager);
|
||||
remap(patched, serviceFactory);
|
||||
// Step 4: add Forge's own sources
|
||||
ForgeSourcesRemapper.addForgeSources(getProject(), serviceManager, null, getOutputJar().get().getAsFile().toPath());
|
||||
ForgeSourcesRemapper.addForgeSources(getProject(), serviceFactory, null, getOutputJar().get().getAsFile().toPath());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -159,8 +159,8 @@ public abstract class GenerateForgePatchedSourcesTask extends AbstractLoomTask {
|
||||
return output;
|
||||
}
|
||||
|
||||
private void remap(Path input, SharedServiceManager serviceManager) {
|
||||
SourceRemapper remapper = new SourceRemapper(getProject(), serviceManager, "srg", "named");
|
||||
private void remap(Path input, ServiceFactory serviceFactory) {
|
||||
SourceRemapper remapper = new SourceRemapper(getProject(), serviceFactory, "srg", "named");
|
||||
remapper.scheduleRemapSources(input.toFile(), getOutputJar().get().getAsFile(), false, true, () -> {
|
||||
});
|
||||
remapper.remapAll();
|
||||
|
||||
@@ -480,8 +480,8 @@ public abstract class GenerateSourcesTask extends AbstractLoomTask {
|
||||
|
||||
// Inject Forge's own sources
|
||||
if (getExtension().isForgeLike()) {
|
||||
try (var serviceManager = new ScopedSharedServiceManager()) {
|
||||
ForgeSourcesRemapper.addForgeSources(getProject(), serviceManager, inputJar, outputJar);
|
||||
try (var serviceFactory = new ScopedServiceFactory()) {
|
||||
ForgeSourcesRemapper.addForgeSources(getProject(), serviceFactory, inputJar, outputJar);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -503,8 +503,8 @@ public abstract class GenerateSourcesTask extends AbstractLoomTask {
|
||||
|
||||
// Inject Forge's own sources
|
||||
if (getExtension().isForgeLike()) {
|
||||
try (var serviceManager = new ScopedSharedServiceManager()) {
|
||||
ForgeSourcesRemapper.addForgeSources(getProject(), serviceManager, inputJar, outputJar);
|
||||
try (var serviceFactory = new ScopedServiceFactory()) {
|
||||
ForgeSourcesRemapper.addForgeSources(getProject(), serviceFactory, inputJar, outputJar);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -140,10 +140,10 @@ public final class FabricModJsonFactory {
|
||||
|
||||
if (file == null) {
|
||||
// Try another mod metadata file if fabric.mod.json wasn't found.
|
||||
final @Nullable ModMetadataFile modMetadata = ModMetadataFiles.fromSourceSets(sourceSets);
|
||||
final @Nullable ModMetadataFile modMetadata = ModMetadataFiles.fromSourceSets(project, sourceSets);
|
||||
|
||||
if (modMetadata != null) {
|
||||
return new ModMetadataFabricModJson(modMetadata, new FabricModJsonSource.SourceSetSource(sourceSets));
|
||||
return new ModMetadataFabricModJson(modMetadata, new FabricModJsonSource.SourceSetSource(project, sourceSets));
|
||||
}
|
||||
|
||||
return null;
|
||||
|
||||
Reference in New Issue
Block a user