Fix merge conflicts

Signed-off-by: shedaniel <daniel@shedaniel.me>
This commit is contained in:
shedaniel
2021-09-11 04:54:58 +08:00
parent d06081d560
commit aa4f1b107f
10 changed files with 97 additions and 64 deletions

View File

@@ -92,7 +92,7 @@ dependencies {
}
// tinyfile management
implementation ('dev.architectury:tiny-remapper:1.1.0')
implementation ('dev.architectury:tiny-remapper:1.3.11')
implementation ('dev.architectury:mappings-layers-core:1.4.9')
implementation ('net.fabricmc:tiny-mappings-parser:0.3.0+build.17')

View File

@@ -69,7 +69,7 @@ public final class MavenPublication {
PublishingExtension mavenPublish = p.getExtensions().findByType(PublishingExtension.class);
if (mavenPublish != null) {
p.getLogger().info("Processing maven publication for project [" + p.getName() + "] of " + entry.sourceConfiguration());
p.getLogger().info("Processing maven publication for project [" + p.getName() + "] of " + configurationName);
processEntry(project, scope, config, mavenPublish, reportedDeprecation);
}
});
@@ -118,11 +118,11 @@ public final class MavenPublication {
for (Dependency dependency : config.getAllDependencies()) {
if (foundArtifacts.contains(dependency.getGroup() + ":" + dependency.getName())) {
logger.info("Found inserted artifact " + dependency.getGroup() + ":" + dependency.getName());
project.getLogger().info("Found inserted artifact " + dependency.getGroup() + ":" + dependency.getName());
continue;
}
logger.info("Inserting artifact " + dependency.getGroup() + ":" + dependency.getName());
project.getLogger().info("Inserting artifact " + dependency.getGroup() + ":" + dependency.getName());
Node depNode = dependencies.appendNode("dependency");
depNode.appendNode("groupId", dependency.getGroup());

View File

@@ -53,9 +53,6 @@ import net.fabricmc.loom.api.LoomGradleExtensionAPI;
import net.fabricmc.loom.api.MixinExtensionAPI;
import net.fabricmc.loom.api.decompilers.LoomDecompiler;
import net.fabricmc.loom.api.ForgeExtensionAPI;
import net.fabricmc.loom.api.LoomGradleExtensionAPI;
import net.fabricmc.loom.api.MixinApExtensionAPI;
import net.fabricmc.loom.api.decompilers.LoomDecompiler;
import net.fabricmc.loom.configuration.ide.RunConfig;
import net.fabricmc.loom.configuration.ide.RunConfigSettings;
import net.fabricmc.loom.configuration.mods.ModVersionParser;

View File

@@ -35,6 +35,8 @@ import org.gradle.api.provider.Provider;
import org.gradle.api.tasks.SourceSet;
import org.gradle.api.tasks.util.PatternSet;
import net.fabricmc.loom.LoomGradleExtension;
import net.fabricmc.loom.api.LoomGradleExtensionAPI;
import net.fabricmc.loom.api.MixinExtensionAPI;
public abstract class MixinExtensionApiImpl implements MixinExtensionAPI {
@@ -44,7 +46,7 @@ public abstract class MixinExtensionApiImpl implements MixinExtensionAPI {
public MixinExtensionApiImpl(Project project) {
this.project = Objects.requireNonNull(project);
this.useMixinAp = project.getObjects().property(Boolean.class)
.convention(false);
.convention(project.provider(() -> LoomGradleExtension.get(project).isForge()));
}
protected final PatternSet add0(SourceSet sourceSet, String refmapName) {

View File

@@ -70,7 +70,7 @@ public class MixinExtensionImpl extends MixinExtensionApiImpl implements MixinEx
String defaultRefmapName = project.getConvention().getPlugin(BasePluginConvention.class).getArchivesBaseName() + "-refmap.json";
if (project.getRootProject() != project) {
defaultRefmapName = project.getConvention().getPlugin(BasePluginConvention.class).getArchivesBaseName() + "-" + getProject().getPath().replaceFirst(":", "").replace(':', '_') + "-refmap.json";
defaultRefmapName = project.getConvention().getPlugin(BasePluginConvention.class).getArchivesBaseName() + "-" + project.getPath().replaceFirst(":", "").replace(':', '_') + "-refmap.json";
}
project.getLogger().info("Could not find refmap definition, will be using default name: " + defaultRefmapName);

View File

@@ -64,6 +64,7 @@ import dev.architectury.refmapremapper.remapper.SimpleReferenceRemapper;
import dev.architectury.tinyremapper.IMappingProvider;
import dev.architectury.tinyremapper.TinyRemapper;
import dev.architectury.tinyremapper.TinyUtils;
import dev.architectury.tinyremapper.extension.mixin.MixinExtension;
import org.cadixdev.at.AccessTransformSet;
import org.cadixdev.at.io.AccessTransformFormats;
import org.gradle.api.Action;
@@ -108,9 +109,6 @@ import net.fabricmc.mapping.tree.FieldDef;
import net.fabricmc.mapping.tree.MethodDef;
import net.fabricmc.mapping.tree.TinyTree;
import net.fabricmc.stitch.util.Pair;
import net.fabricmc.tinyremapper.TinyRemapper;
import net.fabricmc.tinyremapper.TinyUtils;
import net.fabricmc.tinyremapper.extension.mixin.MixinExtension;
public class RemapJarTask extends Jar {
private static final String MANIFEST_PATH = "META-INF/MANIFEST.MF";
@@ -296,14 +294,16 @@ public class RemapJarTask extends Jar {
if (MixinRefmapHelper.addRefmapName(project, output)) {
project.getLogger().debug("Transformed mixin reference maps in output JAR!");
}
}
if (!toM.equals("intermediary")) {
try {
remapRefmap(extension, output, "intermediary", toM);
} catch (IOException e) {
throw new RuntimeException("Failed to remap refmap jar", e);
if (!toM.equals("intermediary")) {
try {
remapRefmap(extension, output, "intermediary", toM);
} catch (IOException e) {
throw new RuntimeException("Failed to remap refmap jar", e);
}
}
} else if (extension.isForge()) {
throw new RuntimeException("Forge must have useLegacyMixinAp enabled");
}
if (getAddNestedDependencies().getOrElse(false)) {
@@ -346,7 +346,7 @@ public class RemapJarTask extends Jar {
private void remapRefmap(LoomGradleExtension extension, Path output, String from, String to) throws IOException {
try (FileSystem fs = FileSystems.newFileSystem(URI.create("jar:" + output.toUri()), ImmutableMap.of("create", false))) {
Path refmapPath = fs.getPath(extension.getRefmapName());
Path refmapPath = fs.getPath(extension.getMixin().getDefaultRefmapName().get());
if (Files.exists(refmapPath)) {
try (Reader refmapReader = Files.newBufferedReader(refmapPath, StandardCharsets.UTF_8)) {

View File

@@ -29,13 +29,10 @@ import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.Deque;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.function.Consumer;
import com.google.common.base.Stopwatch;
import org.cadixdev.lorenz.MappingSet;
import org.cadixdev.mercury.Mercury;
import org.cadixdev.mercury.remapper.MercuryRemapper;
@@ -63,7 +60,7 @@ public class SourceRemapper {
}
public static String intermediary(Project project) {
LoomGradleExtension extension = LoomGradleExtension.get(project);;
LoomGradleExtension extension = LoomGradleExtension.get(project);
return extension.isForge() ? "srg" : "intermediary";
}
@@ -195,8 +192,8 @@ public class SourceRemapper {
}
});
Mercury mercury = extension.getOrCreateSrcMercuryCache(toNamed ? 1 : 0, () -> {
Mercury m = createMercuryWithClassPath(project, toNamed);
Mercury mercury = extension.getOrCreateSrcMercuryCache(id, () -> {
Mercury m = createMercuryWithClassPath(project, to.equals("named"));
for (File file : extension.getUnmappedModCollection()) {
Path path = file.toPath();
@@ -209,6 +206,16 @@ public class SourceRemapper {
m.getClassPath().add(extension.getMinecraftMappedProvider().getMappedJar().toPath());
m.getClassPath().add(extension.getMinecraftMappedProvider().getIntermediaryJar().toPath());
if (extension.isForge()) {
m.getClassPath().add(extension.getMinecraftMappedProvider().getSrgJar().toPath());
if (extension.isForgeAndNotOfficial()) {
m.getClassPath().add(extension.getMinecraftMappedProvider().getForgeMappedJar().toPath());
m.getClassPath().add(extension.getMinecraftMappedProvider().getForgeIntermediaryJar().toPath());
m.getClassPath().add(extension.getMinecraftMappedProvider().getForgeSrgJar().toPath());
}
}
Set<File> files = project.getConfigurations()
.detachedConfiguration(project.getDependencies().create(Constants.Dependencies.JETBRAINS_ANNOTATIONS + Constants.Dependencies.Versions.JETBRAINS_ANNOTATIONS))
.resolve();
@@ -258,23 +265,6 @@ public class SourceRemapper {
m.getClassPath().add(inputFile.toPath());
}
}
classpath.add(extension.getMinecraftMappedProvider().getMappedJar().toPath());
classpath.add(extension.getMinecraftMappedProvider().getIntermediaryJar().toPath());
if (extension.isForge()) {
classpath.add(extension.getMinecraftMappedProvider().getSrgJar().toPath());
classpath.add(extension.getMinecraftMappedProvider().getForgeMappedJar().toPath());
classpath.add(extension.getMinecraftMappedProvider().getForgeIntermediaryJar().toPath());
classpath.add(extension.getMinecraftMappedProvider().getForgeSrgJar().toPath());
}
Set<File> files = project.getConfigurations()
.detachedConfiguration(project.getDependencies().create(Constants.Dependencies.JETBRAINS_ANNOTATIONS + Constants.Dependencies.Versions.JETBRAINS_ANNOTATIONS))
.resolve();
for (File file : files) {
classpath.add(file.toPath());
}
return m;

View File

@@ -25,23 +25,22 @@
package net.fabricmc.loom.test.integration.forge
import net.fabricmc.loom.test.util.ArchiveAssertionsTrait
import net.fabricmc.loom.test.util.ProjectTestTrait
import net.fabricmc.loom.test.util.GradleProjectTestTrait
import spock.lang.Specification
import static org.gradle.testkit.runner.TaskOutcome.SUCCESS
class Aw2AtTest extends Specification implements ProjectTestTrait, ArchiveAssertionsTrait {
@Override
String name() {
"forge/aw2At"
}
class Aw2AtTest extends Specification implements GradleProjectTestTrait, ArchiveAssertionsTrait {
def build() {
when:
def result = create("build", DEFAULT_GRADLE)
then:
result.task(":build").outcome == SUCCESS
getArchiveEntry("fabric-example-mod-1.0.0.jar", "META-INF/accesstransformer.cfg") == expected().replaceAll('\r', '')
setup:
def gradle = gradleProject(project: "forge/aw2At", version: version)
when:
def result = gradle.run(task: "build")
then:
result.task(":build").outcome == SUCCESS
getArchiveEntry("fabric-example-mod-1.0.0.jar", "META-INF/accesstransformer.cfg") == expected().replaceAll('\r', '')
}
String expected() {

View File

@@ -25,23 +25,22 @@
package net.fabricmc.loom.test.integration.forge
import net.fabricmc.loom.test.util.ArchiveAssertionsTrait
import net.fabricmc.loom.test.util.ProjectTestTrait
import net.fabricmc.loom.test.util.GradleProjectTestTrait
import spock.lang.Specification
import static org.gradle.testkit.runner.TaskOutcome.SUCCESS
class LegacyAw2AtTest extends Specification implements ProjectTestTrait, ArchiveAssertionsTrait {
@Override
String name() {
"forge/legacyAw2At"
}
class LegacyAw2AtTest extends Specification implements GradleProjectTestTrait, ArchiveAssertionsTrait {
def build() {
setup:
def gradle = gradleProject(project: "forge/legacyAw2At", version: version)
when:
def result = create("build", DEFAULT_GRADLE)
def result = gradle.run(task: "build")
then:
result.task(":build").outcome == SUCCESS
getArchiveEntry("fabric-example-mod-1.0.0.jar", "META-INF/accesstransformer.cfg") == expected().replaceAll('\r', '')
result.task(":build").outcome == SUCCESS
getArchiveEntry("fabric-example-mod-1.0.0.jar", "META-INF/accesstransformer.cfg") == expected().replaceAll('\r', '')
}
String expected() {

View File

@@ -0,0 +1,46 @@
/*
* 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.test.util
import org.zeroturnaround.zip.ZipUtil
trait ArchiveAssertionsTrait {
String getArchiveEntry(String name, String entry, String project = "") {
def file = getOutputFile(name, project)
def bytes = ZipUtil.unpackEntry(file, entry)
if (bytes == null) {
throw new FileNotFoundException("Could not find ${entry} in ${name}")
}
new String(bytes as byte[])
}
boolean hasArchiveEntry(String name, String entry, String project = "") {
def file = getOutputFile(name, project)
ZipUtil.unpackEntry(file, entry) != null
}
}