mirror of
https://github.com/architectury/architectury-loom.git
synced 2026-04-02 13:37:45 -05:00
Merge remote-tracking branch 'FabricMC/exp/0.10' into dev/future
# Conflicts: # src/main/java/net/fabricmc/loom/LoomRepositoryPlugin.java # src/main/java/net/fabricmc/loom/configuration/providers/minecraft/assets/MinecraftAssetsProvider.java
This commit is contained in:
@@ -30,12 +30,14 @@ import org.gradle.api.artifacts.dsl.RepositoryHandler;
|
||||
import org.gradle.api.artifacts.repositories.IvyArtifactRepository;
|
||||
import org.gradle.api.initialization.Settings;
|
||||
import org.gradle.api.invocation.Gradle;
|
||||
import org.gradle.api.plugins.ExtensionAware;
|
||||
import org.gradle.api.plugins.PluginAware;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import net.fabricmc.loom.extension.LoomFiles;
|
||||
|
||||
import net.fabricmc.loom.util.Constants;
|
||||
import net.fabricmc.loom.util.MirrorUtil;
|
||||
|
||||
public class LoomRepositoryPlugin implements Plugin<PluginAware> {
|
||||
@Override
|
||||
@@ -74,11 +76,11 @@ public class LoomRepositoryPlugin implements Plugin<PluginAware> {
|
||||
});
|
||||
repositories.maven(repo -> {
|
||||
repo.setName("Fabric");
|
||||
repo.setUrl("https://maven.fabricmc.net/");
|
||||
repo.setUrl(MirrorUtil.getFabricRepository((ExtensionAware) target));
|
||||
});
|
||||
repositories.maven(repo -> {
|
||||
repo.setName("Mojang");
|
||||
repo.setUrl("https://libraries.minecraft.net/");
|
||||
repo.setUrl(MirrorUtil.getLibrariesBase((ExtensionAware) target));
|
||||
});
|
||||
repositories.maven(repo -> {
|
||||
repo.setName("Forge");
|
||||
|
||||
@@ -44,6 +44,7 @@ import net.fabricmc.loom.configuration.providers.minecraft.ManifestVersion;
|
||||
import net.fabricmc.loom.configuration.providers.minecraft.MinecraftLibraryProvider;
|
||||
import net.fabricmc.loom.configuration.providers.minecraft.MinecraftVersionMeta;
|
||||
import net.fabricmc.loom.util.Constants;
|
||||
import net.fabricmc.loom.util.MirrorUtil;
|
||||
import net.fabricmc.loom.util.DownloadUtil;
|
||||
import net.fabricmc.loom.util.HashedDownloadUtil;
|
||||
import net.fabricmc.stitch.merge.JarMerger;
|
||||
@@ -154,7 +155,7 @@ public class MinecraftProviderImpl extends DependencyProvider implements Minecra
|
||||
}
|
||||
} else {
|
||||
getProject().getLogger().debug("Downloading version manifests");
|
||||
DownloadUtil.downloadIfChanged(new URL(Constants.VERSION_MANIFESTS), versionManifestJson, getProject().getLogger());
|
||||
DownloadUtil.downloadIfChanged(new URL(MirrorUtil.getVersionManifests(getProject())), versionManifestJson, getProject().getLogger());
|
||||
}
|
||||
|
||||
String versionManifest = Files.asCharSource(versionManifestJson, StandardCharsets.UTF_8).read();
|
||||
@@ -213,7 +214,7 @@ public class MinecraftProviderImpl extends DependencyProvider implements Minecra
|
||||
return Optional.empty();
|
||||
}
|
||||
} else {
|
||||
DownloadUtil.downloadIfChanged(new URL(Constants.EXPERIMENTAL_VERSIONS), experimentalVersionsJson, getProject().getLogger());
|
||||
DownloadUtil.downloadIfChanged(new URL(MirrorUtil.getExperimentalVersions(getProject())), experimentalVersionsJson, getProject().getLogger());
|
||||
}
|
||||
|
||||
String expVersionManifest = Files.asCharSource(experimentalVersionsJson, StandardCharsets.UTF_8).read();
|
||||
|
||||
@@ -75,7 +75,7 @@ public class LayeredMappingsDependency implements SelfResolvingDependency {
|
||||
Tiny2Writer tiny2Writer = new Tiny2Writer(writer, false);
|
||||
|
||||
MappingDstNsReorder nsReorder = new MappingDstNsReorder(tiny2Writer, Collections.singletonList(MappingNamespace.NAMED.stringValue()));
|
||||
MappingSourceNsSwitch nsSwitch = new MappingSourceNsSwitch(nsReorder, MappingNamespace.INTERMEDIARY.stringValue());
|
||||
MappingSourceNsSwitch nsSwitch = new MappingSourceNsSwitch(nsReorder, MappingNamespace.INTERMEDIARY.stringValue(), true);
|
||||
mappings.accept(nsSwitch);
|
||||
|
||||
Files.deleteIfExists(mappingsFile);
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
|
||||
package net.fabricmc.loom.configuration.providers.mappings.parchment;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Locale;
|
||||
|
||||
import net.fabricmc.mappingio.MappingVisitor;
|
||||
@@ -35,7 +36,7 @@ public final class ParchmentPrefixStripingMappingVisitor extends ForwardingMappi
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean visitMethodArg(int argPosition, int lvIndex, String srcName) {
|
||||
public boolean visitMethodArg(int argPosition, int lvIndex, String srcName) throws IOException {
|
||||
return super.visitMethodArg(argPosition, lvIndex, stripMethodArg(srcName));
|
||||
}
|
||||
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
|
||||
package net.fabricmc.loom.configuration.providers.mappings.parchment;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
@@ -39,7 +40,7 @@ public record ParchmentTreeV1(
|
||||
@Nullable
|
||||
List<Package> packages
|
||||
) {
|
||||
public void visit(MappingVisitor visitor, String srcNamespace) {
|
||||
public void visit(MappingVisitor visitor, String srcNamespace) throws IOException {
|
||||
while (true) {
|
||||
if (visitor.visitHeader()) {
|
||||
visitor.visitNamespaces(srcNamespace, Collections.emptyList());
|
||||
@@ -68,7 +69,7 @@ public record ParchmentTreeV1(
|
||||
@Nullable
|
||||
List<String> javadoc
|
||||
) {
|
||||
public void visit(MappingVisitor visitor) {
|
||||
public void visit(MappingVisitor visitor) throws IOException {
|
||||
if (visitor.visitClass(name())) {
|
||||
if (!visitor.visitElementContent(MappedElementKind.CLASS)) {
|
||||
return;
|
||||
@@ -99,7 +100,7 @@ public record ParchmentTreeV1(
|
||||
@Nullable
|
||||
List<String> javadoc
|
||||
) {
|
||||
public void visit(MappingVisitor visitor) {
|
||||
public void visit(MappingVisitor visitor) throws IOException {
|
||||
if (visitor.visitField(name, descriptor)) {
|
||||
if (!visitor.visitElementContent(MappedElementKind.FIELD)) {
|
||||
return;
|
||||
@@ -120,7 +121,7 @@ public record ParchmentTreeV1(
|
||||
@Nullable
|
||||
List<String> javadoc
|
||||
) {
|
||||
public void visit(MappingVisitor visitor) {
|
||||
public void visit(MappingVisitor visitor) throws IOException {
|
||||
if (visitor.visitMethod(name, descriptor)) {
|
||||
if (!visitor.visitElementContent(MappedElementKind.METHOD)) {
|
||||
return;
|
||||
@@ -145,7 +146,7 @@ public record ParchmentTreeV1(
|
||||
@Nullable
|
||||
String javadoc
|
||||
) {
|
||||
public void visit(MappingVisitor visitor) {
|
||||
public void visit(MappingVisitor visitor) throws IOException {
|
||||
if (visitor.visitMethodArg(index, index, name)) {
|
||||
if (!visitor.visitElementContent(MappedElementKind.METHOD_ARG)) {
|
||||
return;
|
||||
|
||||
@@ -40,6 +40,7 @@ import org.zeroturnaround.zip.ZipUtil;
|
||||
import net.fabricmc.loom.LoomGradleExtension;
|
||||
import net.fabricmc.loom.LoomGradlePlugin;
|
||||
import net.fabricmc.loom.util.HashedDownloadUtil;
|
||||
import net.fabricmc.loom.util.MirrorUtil;
|
||||
|
||||
public class MinecraftNativesProvider {
|
||||
private final Project project;
|
||||
@@ -93,7 +94,7 @@ public class MinecraftNativesProvider {
|
||||
File libJarFile = library.relativeFile(jarStore);
|
||||
|
||||
if (!offline) {
|
||||
HashedDownloadUtil.downloadIfInvalid(new URL(library.url()), libJarFile, library.sha1(), project.getLogger(), false);
|
||||
HashedDownloadUtil.downloadIfInvalid(new URL(MirrorUtil.getLibrariesBase(project) + library.path()), libJarFile, library.sha1(), project.getLogger(), false);
|
||||
}
|
||||
|
||||
if (!libJarFile.exists()) {
|
||||
|
||||
@@ -45,7 +45,7 @@ import net.fabricmc.loom.LoomGradleExtension;
|
||||
import net.fabricmc.loom.LoomGradlePlugin;
|
||||
import net.fabricmc.loom.configuration.providers.MinecraftProviderImpl;
|
||||
import net.fabricmc.loom.configuration.providers.minecraft.MinecraftVersionMeta;
|
||||
import net.fabricmc.loom.util.Constants;
|
||||
import net.fabricmc.loom.util.MirrorUtil;
|
||||
import net.fabricmc.loom.util.HashedDownloadUtil;
|
||||
|
||||
public class MinecraftAssetsProvider {
|
||||
@@ -136,7 +136,7 @@ public class MinecraftAssetsProvider {
|
||||
project.getLogger().debug(":downloading asset " + assetName);
|
||||
|
||||
try {
|
||||
HashedDownloadUtil.downloadIfInvalid(new URL(Constants.RESOURCES_BASE + sha1.substring(0, 2) + "/" + sha1), file, sha1, project.getLogger(), true, false);
|
||||
HashedDownloadUtil.downloadIfInvalid(new URL(MirrorUtil.getResourcesBase(project) + sha1.substring(0, 2) + "/" + sha1), file, sha1, project.getLogger(), true, false);
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException("Failed to download: " + assetName, e);
|
||||
}
|
||||
|
||||
@@ -38,6 +38,7 @@ public class Constants {
|
||||
public static final String RESOURCES_BASE = "https://resources.download.minecraft.net/";
|
||||
public static final String VERSION_MANIFESTS = "https://launchermeta.mojang.com/mc/game/version_manifest_v2.json";
|
||||
public static final String EXPERIMENTAL_VERSIONS = "https://maven.fabricmc.net/net/minecraft/experimental_versions.json";
|
||||
public static final String FABRIC_REPOSITORY = "https://maven.fabricmc.net/";
|
||||
|
||||
public static final String SYSTEM_ARCH = System.getProperty("os.arch").equals("64") ? "64" : "32";
|
||||
|
||||
|
||||
69
src/main/java/net/fabricmc/loom/util/MirrorUtil.java
Normal file
69
src/main/java/net/fabricmc/loom/util/MirrorUtil.java
Normal file
@@ -0,0 +1,69 @@
|
||||
/*
|
||||
* This file is part of fabric-loom, licensed under the MIT License (MIT).
|
||||
*
|
||||
* Copyright (c) 2016-2021 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.util;
|
||||
|
||||
import org.gradle.api.plugins.ExtensionAware;
|
||||
|
||||
public class MirrorUtil {
|
||||
public static String getLibrariesBase(ExtensionAware aware) {
|
||||
if (aware.getExtensions().getExtraProperties().has("loom_libraries_base")) {
|
||||
return String.valueOf(aware.getExtensions().getExtraProperties().get("loom_libraries_base"));
|
||||
}
|
||||
|
||||
return Constants.LIBRARIES_BASE;
|
||||
}
|
||||
|
||||
public static String getResourcesBase(ExtensionAware aware) {
|
||||
if (aware.getExtensions().getExtraProperties().has("loom_resources_base")) {
|
||||
return String.valueOf(aware.getExtensions().getExtraProperties().get("loom_resources_base"));
|
||||
}
|
||||
|
||||
return Constants.RESOURCES_BASE;
|
||||
}
|
||||
|
||||
public static String getVersionManifests(ExtensionAware aware) {
|
||||
if (aware.getExtensions().getExtraProperties().has("loom_version_manifests")) {
|
||||
return String.valueOf(aware.getExtensions().getExtraProperties().get("loom_version_manifests"));
|
||||
}
|
||||
|
||||
return Constants.VERSION_MANIFESTS;
|
||||
}
|
||||
|
||||
public static String getExperimentalVersions(ExtensionAware aware) {
|
||||
if (aware.getExtensions().getExtraProperties().has("loom_experimental_versions")) {
|
||||
return String.valueOf(aware.getExtensions().getExtraProperties().get("loom_experimental_versions"));
|
||||
}
|
||||
|
||||
return Constants.EXPERIMENTAL_VERSIONS;
|
||||
}
|
||||
|
||||
public static String getFabricRepository(ExtensionAware aware) {
|
||||
if (aware.getExtensions().getExtraProperties().has("loom_fabric_repository")) {
|
||||
return String.valueOf(aware.getExtensions().getExtraProperties().get("loom_fabric_repository"));
|
||||
}
|
||||
|
||||
return Constants.FABRIC_REPOSITORY;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user