mirror of
https://github.com/architectury/architectury-loom.git
synced 2026-03-30 13:05:27 -05:00
Fix compilation and code style
This commit is contained in:
@@ -38,8 +38,6 @@ public interface MixinExtensionAPI {
|
||||
|
||||
Property<String> getRefmapTargetNamespace();
|
||||
|
||||
Property<String> getLegacyRemapToNamespace();
|
||||
|
||||
/**
|
||||
* Apply Mixin AP to sourceSet.
|
||||
* @param sourceSet the sourceSet that applies Mixin AP.
|
||||
|
||||
@@ -86,7 +86,7 @@ public abstract class AnnotationProcessorInvoker<T extends Task> {
|
||||
try {
|
||||
LoomGradleExtension loom = LoomGradleExtension.get(project);
|
||||
String refmapName = Objects.requireNonNull(MixinExtension.getMixinInformationContainer(sourceSet)).refmapNameProvider().get();
|
||||
Path mappings = loom.getMappingsProvider().getReplacedTarget(loom, loom.getMixin().getLegacyRemapToNamespace().get());
|
||||
Path mappings = loom.getMappingsProvider().getReplacedTarget(loom, loom.getMixin().getRefmapTargetNamespace().get());
|
||||
Map<String, String> args = new HashMap<>() {{
|
||||
put(Constants.MixinArguments.IN_MAP_FILE_NAMED_INTERMEDIARY, mappings.toFile().getCanonicalPath());
|
||||
put(Constants.MixinArguments.OUT_MAP_FILE_NAMED_INTERMEDIARY, MixinMappingsService.getMixinMappingFile(project, sourceSet).getCanonicalPath());
|
||||
|
||||
@@ -118,7 +118,7 @@ public final class CompileConfiguration {
|
||||
extendsFrom(Constants.Configurations.FORGE_RUNTIME_LIBRARY, Constants.Configurations.FORGE_DEPENDENCIES, project);
|
||||
extendsFrom(Constants.Configurations.FORGE_RUNTIME_LIBRARY, Constants.Configurations.MINECRAFT_DEPENDENCIES, project);
|
||||
extendsFrom(Constants.Configurations.FORGE_RUNTIME_LIBRARY, Constants.Configurations.FORGE_EXTRA, project);
|
||||
extendsFrom(Constants.Configurations.FORGE_RUNTIME_LIBRARY, Constants.Configurations.MINECRAFT_NAMED, project);
|
||||
extendsFrom(Constants.Configurations.FORGE_RUNTIME_LIBRARY, MinecraftSourceSets.get(project).getCombinedSourceSetName(), project);
|
||||
extendsFrom(Constants.Configurations.FORGE_RUNTIME_LIBRARY, Constants.Configurations.FORGE_NAMED, project);
|
||||
// Include any user-defined libraries on the runtime CP.
|
||||
// (All the other superconfigurations are already on there.)
|
||||
|
||||
@@ -330,8 +330,8 @@ public class InterfaceInjectionProcessor implements JarProcessor, GenerateSource
|
||||
}
|
||||
|
||||
if (commonJsonBytes != null) {
|
||||
JsonObject jsonObject = new Gson().fromJson(new String(commonJsonBytes, StandardCharsets.UTF_8), JsonObject.class);
|
||||
return fromJsonArch(jsonObject, modJarPath.toString());
|
||||
JsonObject commonJsonObject = new Gson().fromJson(new String(commonJsonBytes, StandardCharsets.UTF_8), JsonObject.class);
|
||||
return fromJsonArch(commonJsonObject, modJarPath.toString());
|
||||
} else {
|
||||
try {
|
||||
commonJsonBytes = ZipUtils.unpackNullable(modJarPath, "quilt.mod.json");
|
||||
@@ -340,14 +340,15 @@ public class InterfaceInjectionProcessor implements JarProcessor, GenerateSource
|
||||
}
|
||||
|
||||
if (commonJsonBytes != null) {
|
||||
JsonObject jsonObject = new Gson().fromJson(new String(commonJsonBytes, StandardCharsets.UTF_8), JsonObject.class);
|
||||
JsonObject commonJsonObject = new Gson().fromJson(new String(commonJsonBytes, StandardCharsets.UTF_8), JsonObject.class);
|
||||
|
||||
if (jsonObject.has("quilt_loom")) {
|
||||
if (commonJsonObject.has("quilt_loom")) {
|
||||
// quilt injected interfaces has the same format as architectury.common.json
|
||||
return fromJsonArch(jsonObject.getAsJsonObject("quilt_loom"), modJarPath.toString());
|
||||
return fromJsonArch(commonJsonObject.getAsJsonObject("quilt_loom"), modJarPath.toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
|
||||
@@ -73,7 +73,7 @@ public final class ModJavadocProcessor implements JarProcessor, GenerateSourcesT
|
||||
.resolve();
|
||||
|
||||
for (File artifact : artifacts) {
|
||||
if (!ModUtils.isMod(artifact.toPath())) {
|
||||
if (!ModUtils.isMod(artifact.toPath(), extension.getPlatform().get())) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
@@ -56,7 +56,7 @@ import org.objectweb.asm.Opcodes;
|
||||
import net.fabricmc.loom.LoomGradleExtension;
|
||||
import net.fabricmc.loom.LoomGradlePlugin;
|
||||
import net.fabricmc.loom.api.mappings.layered.MappingsNamespace;
|
||||
import net.fabricmc.loom.configuration.providers.mappings.IntermediaryService;
|
||||
import net.fabricmc.loom.configuration.providers.mappings.IntermediateMappingsService;
|
||||
import net.fabricmc.loom.configuration.providers.mappings.MappingsProviderImpl;
|
||||
import net.fabricmc.loom.configuration.providers.minecraft.MinecraftProvider;
|
||||
import net.fabricmc.loom.util.FileSystemUtil;
|
||||
@@ -74,7 +74,7 @@ public class FieldMigratedMappingsProvider extends MappingsProviderImpl {
|
||||
public Path rawTinyMappings;
|
||||
public Path rawTinyMappingsWithSrg;
|
||||
|
||||
public FieldMigratedMappingsProvider(String mappingsIdentifier, Path mappingsWorkingDir, Supplier<IntermediaryService> intermediaryService) {
|
||||
public FieldMigratedMappingsProvider(String mappingsIdentifier, Path mappingsWorkingDir, Supplier<IntermediateMappingsService> intermediaryService) {
|
||||
super(mappingsIdentifier, mappingsWorkingDir, intermediaryService);
|
||||
}
|
||||
|
||||
|
||||
@@ -55,7 +55,7 @@ public enum MinecraftJarConfiguration {
|
||||
SingleJarMinecraftProvider::server,
|
||||
IntermediaryMinecraftProvider.SingleJarImpl::server,
|
||||
NamedMinecraftProvider.SingleJarImpl::server,
|
||||
SrgMinecraftProvider.ServerOnlyImpl::new,
|
||||
SrgMinecraftProvider.SingleJarImpl::server,
|
||||
ProcessedNamedMinecraftProvider.SingleJarImpl::server,
|
||||
SingleJarDecompileConfiguration::new,
|
||||
List.of("server")
|
||||
@@ -64,6 +64,7 @@ public enum MinecraftJarConfiguration {
|
||||
SingleJarMinecraftProvider::client,
|
||||
IntermediaryMinecraftProvider.SingleJarImpl::client,
|
||||
NamedMinecraftProvider.SingleJarImpl::client,
|
||||
SrgMinecraftProvider.SingleJarImpl::client,
|
||||
ProcessedNamedMinecraftProvider.SingleJarImpl::client,
|
||||
SingleJarDecompileConfiguration::new,
|
||||
List.of("client")
|
||||
|
||||
@@ -31,7 +31,6 @@ import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.function.BiConsumer;
|
||||
|
||||
import dev.architectury.tinyremapper.OutputConsumerPath;
|
||||
import dev.architectury.tinyremapper.TinyRemapper;
|
||||
|
||||
@@ -33,11 +33,11 @@ import org.gradle.api.Project;
|
||||
import net.fabricmc.loom.api.mappings.layered.MappingsNamespace;
|
||||
import net.fabricmc.loom.configuration.providers.minecraft.MergedMinecraftProvider;
|
||||
import net.fabricmc.loom.configuration.providers.minecraft.MinecraftProvider;
|
||||
import net.fabricmc.loom.configuration.providers.minecraft.ServerOnlyMinecraftProvider;
|
||||
import net.fabricmc.loom.configuration.providers.minecraft.SingleJarMinecraftProvider;
|
||||
import net.fabricmc.loom.configuration.providers.minecraft.SplitMinecraftProvider;
|
||||
import net.fabricmc.loom.util.SidedClassVisitor;
|
||||
|
||||
public abstract sealed class SrgMinecraftProvider<M extends MinecraftProvider> extends AbstractMappedMinecraftProvider<M> permits SrgMinecraftProvider.MergedImpl, SrgMinecraftProvider.ServerOnlyImpl, SrgMinecraftProvider.SplitImpl {
|
||||
public abstract sealed class SrgMinecraftProvider<M extends MinecraftProvider> extends AbstractMappedMinecraftProvider<M> permits SrgMinecraftProvider.MergedImpl, SrgMinecraftProvider.SingleJarImpl, SrgMinecraftProvider.SplitImpl {
|
||||
public SrgMinecraftProvider(Project project, M minecraftProvider) {
|
||||
super(project, minecraftProvider);
|
||||
}
|
||||
@@ -86,16 +86,32 @@ public abstract sealed class SrgMinecraftProvider<M extends MinecraftProvider> e
|
||||
}
|
||||
}
|
||||
|
||||
public static final class ServerOnlyImpl extends SrgMinecraftProvider<ServerOnlyMinecraftProvider> implements ServerOnly {
|
||||
public ServerOnlyImpl(Project project, ServerOnlyMinecraftProvider minecraftProvider) {
|
||||
public static final class SingleJarImpl extends SrgMinecraftProvider<SingleJarMinecraftProvider> implements SingleJar {
|
||||
private final String env;
|
||||
|
||||
private SingleJarImpl(Project project, SingleJarMinecraftProvider minecraftProvider, String env) {
|
||||
super(project, minecraftProvider);
|
||||
this.env = env;
|
||||
}
|
||||
|
||||
public static SingleJarImpl server(Project project, SingleJarMinecraftProvider minecraftProvider) {
|
||||
return new SingleJarImpl(project, minecraftProvider, "server");
|
||||
}
|
||||
|
||||
public static SingleJarImpl client(Project project, SingleJarMinecraftProvider minecraftProvider) {
|
||||
return new SingleJarImpl(project, minecraftProvider, "client");
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<RemappedJars> getRemappedJars() {
|
||||
return List.of(
|
||||
new RemappedJars(minecraftProvider.getMinecraftServerOnlyJar(), getServerOnlyJar(), MappingsNamespace.OFFICIAL)
|
||||
new RemappedJars(minecraftProvider.getMinecraftEnvOnlyJar(), getEnvOnlyJar(), MappingsNamespace.OFFICIAL)
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String env() {
|
||||
return env;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -36,7 +36,7 @@ import org.gradle.api.tasks.SourceSet;
|
||||
import org.gradle.api.tasks.util.PatternSet;
|
||||
|
||||
import net.fabricmc.loom.api.MixinExtensionAPI;
|
||||
import net.fabricmc.loom.api.mappings.layered.MappingsNamespace;
|
||||
import net.fabricmc.loom.util.SourceRemapper;
|
||||
|
||||
public abstract class MixinExtensionApiImpl implements MixinExtensionAPI {
|
||||
protected final Project project;
|
||||
@@ -50,7 +50,7 @@ public abstract class MixinExtensionApiImpl implements MixinExtensionAPI {
|
||||
.convention(true);
|
||||
|
||||
this.refmapTargetNamespace = project.getObjects().property(String.class)
|
||||
.convention(MappingsNamespace.INTERMEDIARY.toString());
|
||||
.convention(project.provider(() -> SourceRemapper.intermediary(project)));
|
||||
this.refmapTargetNamespace.finalizeValueOnRead();
|
||||
}
|
||||
|
||||
@@ -145,11 +145,6 @@ public abstract class MixinExtensionApiImpl implements MixinExtensionAPI {
|
||||
throw new RuntimeException("Yeah... something is really wrong");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Property<String> getLegacyRemapToNamespace() {
|
||||
throw new RuntimeException("Yeah... something is really wrong");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected PatternSet add0(SourceSet sourceSet, Provider<String> refmapName) {
|
||||
throw new RuntimeException("Yeah... something is really wrong");
|
||||
|
||||
@@ -48,12 +48,9 @@ import org.gradle.api.tasks.SourceSet;
|
||||
import org.gradle.api.tasks.util.PatternSet;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import net.fabricmc.loom.util.SourceRemapper;
|
||||
|
||||
public class MixinExtensionImpl extends MixinExtensionApiImpl implements MixinExtension {
|
||||
private boolean isDefault;
|
||||
private final Property<String> defaultRefmapName;
|
||||
private final Property<String> legacyRemapToNamespace;
|
||||
|
||||
@Inject
|
||||
public MixinExtensionImpl(Project project) {
|
||||
@@ -61,8 +58,6 @@ public class MixinExtensionImpl extends MixinExtensionApiImpl implements MixinEx
|
||||
this.isDefault = true;
|
||||
this.defaultRefmapName = project.getObjects().property(String.class)
|
||||
.convention(project.provider(this::getDefaultMixinRefmapName));
|
||||
this.legacyRemapToNamespace = project.getObjects().property(String.class)
|
||||
.convention(project.provider(() -> SourceRemapper.intermediary(project)));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -72,13 +67,6 @@ public class MixinExtensionImpl extends MixinExtensionApiImpl implements MixinEx
|
||||
return defaultRefmapName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Property<String> getLegacyRemapToNamespace() {
|
||||
if (!super.getUseLegacyMixinAp().get()) throw new IllegalStateException("You need to set useLegacyMixinAp = true to configure Mixin annotation processor.");
|
||||
|
||||
return legacyRemapToNamespace;
|
||||
}
|
||||
|
||||
private String getDefaultMixinRefmapName() {
|
||||
String defaultRefmapName = project.getExtensions().getByType(BasePluginExtension.class).getArchivesName().get() + "-refmap.json";
|
||||
|
||||
|
||||
@@ -57,6 +57,7 @@ import net.fabricmc.loom.util.HashedDownloadUtil;
|
||||
import net.fabricmc.loom.util.MirrorUtil;
|
||||
import net.fabricmc.loom.util.gradle.ProgressLoggerHelper;
|
||||
|
||||
// TODO: Reintroduce the progress bar.
|
||||
public abstract class DownloadAssetsTask extends AbstractLoomTask {
|
||||
@Input
|
||||
public abstract Property<String> getAssetsHash();
|
||||
@@ -133,7 +134,7 @@ public abstract class DownloadAssetsTask extends AbstractLoomTask {
|
||||
final ProgressLoggerHelper logger = getOrCreateLogger.get();
|
||||
|
||||
try {
|
||||
HashedDownloadUtil.downloadIfInvalid(new URL(MirrorUtil.getResourcesBase(project) + sha1.substring(0, 2) + "/" + sha1), file, sha1, project.getLogger(), true, () -> {
|
||||
HashedDownloadUtil.downloadIfInvalid(new URL(MirrorUtil.getResourcesBase(project) + sha1.substring(0, 2) + "/" + sha1), file, sha1, project.getLogger(), true, false, () -> {
|
||||
project.getLogger().debug("downloading asset " + object.name());
|
||||
logger.progress(String.format("%-30.30s", object.name()) + " - " + sha1);
|
||||
});
|
||||
|
||||
@@ -68,7 +68,7 @@ public abstract class GenerateDLIConfigTask extends AbstractLoomTask {
|
||||
.property("client", "java.library.path", nativesPath)
|
||||
.property("client", "org.lwjgl.librarypath", nativesPath);
|
||||
|
||||
if (!getExtension().isForge())
|
||||
if (!getExtension().isForge()) {
|
||||
launchConfig
|
||||
.argument("client", "--assetIndex")
|
||||
.argument("client", getExtension().getMinecraftProvider().getVersionInfo().assetIndex().fabricId(getExtension().getMinecraftProvider().minecraftVersion()))
|
||||
|
||||
@@ -41,14 +41,14 @@ public final class ModUtils {
|
||||
}
|
||||
|
||||
public static boolean isMod(File file, ModPlatform platform) {
|
||||
return isMod(file.toPath());
|
||||
return isMod(file.toPath(), platform);
|
||||
}
|
||||
|
||||
public static boolean isMod(Path input, ModPlatform platform) {
|
||||
if (platform == ModPlatform.FORGE) {
|
||||
return ZipUtils.contains(input.toPath(), "META-INF/mods.toml");
|
||||
return ZipUtils.contains(input, "META-INF/mods.toml");
|
||||
} else if (platform == ModPlatform.QUILT) {
|
||||
return ZipUtils.contains(input.toPath(), "quilt.mod.json");
|
||||
return ZipUtils.contains(input, "quilt.mod.json");
|
||||
}
|
||||
|
||||
return ZipUtils.contains(input, "fabric.mod.json");
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
|
||||
package net.fabricmc.loom.util.kotlin;
|
||||
|
||||
import net.fabricmc.tinyremapper.TinyRemapper;
|
||||
import dev.architectury.tinyremapper.TinyRemapper;
|
||||
|
||||
public interface KotlinMetadataTinyRemapperExtension extends TinyRemapper.ApplyVisitorProvider, TinyRemapper.Extension {
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user