Fix failure when running `dependencies` task when using layered mappings.

A SelfResolvingDependency has to be a FileCollectionDependency or a ModuleDependency by the looks of it.
dev/0.11
modmuss50 2021-09-28 16:34:43 +01:00
parent c6f51f1dd2
commit 80ad300b97
4 changed files with 17 additions and 5 deletions

View File

@ -37,8 +37,11 @@ import java.util.Map;
import java.util.Objects;
import java.util.Set;
import org.gradle.api.Project;
import org.gradle.api.artifacts.Dependency;
import org.gradle.api.artifacts.FileCollectionDependency;
import org.gradle.api.artifacts.SelfResolvingDependency;
import org.gradle.api.file.FileCollection;
import org.gradle.api.tasks.TaskDependency;
import org.zeroturnaround.zip.ByteSource;
import org.zeroturnaround.zip.ZipEntrySource;
@ -53,15 +56,17 @@ import net.fabricmc.mappingio.adapter.MappingSourceNsSwitch;
import net.fabricmc.mappingio.format.Tiny2Writer;
import net.fabricmc.mappingio.tree.MemoryMappingTree;
public class LayeredMappingsDependency implements SelfResolvingDependency {
public class LayeredMappingsDependency implements SelfResolvingDependency, FileCollectionDependency {
private static final String GROUP = "loom";
private static final String MODULE = "mappings";
private final Project project;
private final MappingContext mappingContext;
private final LayeredMappingSpec layeredMappingSpec;
private final String version;
public LayeredMappingsDependency(MappingContext mappingContext, LayeredMappingSpec layeredMappingSpec, String version) {
public LayeredMappingsDependency(Project project, MappingContext mappingContext, LayeredMappingSpec layeredMappingSpec, String version) {
this.project = project;
this.mappingContext = mappingContext;
this.layeredMappingSpec = layeredMappingSpec;
this.version = version;
@ -156,7 +161,7 @@ public class LayeredMappingsDependency implements SelfResolvingDependency {
@Override
public Dependency copy() {
return new LayeredMappingsDependency(mappingContext, layeredMappingSpec, version);
return new LayeredMappingsDependency(project, mappingContext, layeredMappingSpec, version);
}
@Override
@ -167,4 +172,9 @@ public class LayeredMappingsDependency implements SelfResolvingDependency {
@Override
public void because(String s) {
}
@Override
public FileCollection getFiles() {
return project.files(resolve());
}
}

View File

@ -121,7 +121,7 @@ public abstract class LoomGradleExtensionApiImpl implements LoomGradleExtensionA
LayeredMappingSpecBuilderImpl builder = new LayeredMappingSpecBuilderImpl();
action.execute(builder);
LayeredMappingSpec builtSpec = builder.build();
return new LayeredMappingsDependency(new GradleMappingContext(getProject(), builtSpec.getVersion().replace("+", "_").replace(".", "_")), builtSpec, builtSpec.getVersion());
return new LayeredMappingsDependency(getProject(), new GradleMappingContext(getProject(), builtSpec.getVersion().replace("+", "_").replace(".", "_")), builtSpec, builtSpec.getVersion());
}
@Override

View File

@ -26,7 +26,7 @@ package net.fabricmc.loom.test
class LoomTestConstants {
public final static String DEFAULT_GRADLE = "7.0.1"
public final static String PRE_RELEASE_GRADLE = "7.4-20210926222420+0000"
public final static String PRE_RELEASE_GRADLE = "7.4-20210927222644+0000"
public final static String[] STANDARD_TEST_VERSIONS = [DEFAULT_GRADLE, PRE_RELEASE_GRADLE]
}

View File

@ -39,9 +39,11 @@ class MojangMappingsProjectTest extends Specification implements GradleProjectTe
when:
def result = gradle.run(task: "build")
def dependenciesResult = gradle.run(task: "dependencies")
then:
result.task(":build").outcome == SUCCESS
dependenciesResult.task(":dependencies").outcome == SUCCESS
where:
version << STANDARD_TEST_VERSIONS