Alter TransitiveAccessWidenerJarProcessor to use the same logic used in ModCompileRemapper for resolving mod jars.

dev/0.11
modmuss50 2021-10-25 16:34:06 +01:00
parent 640deecd96
commit 13f4b29d12
2 changed files with 36 additions and 18 deletions

View File

@ -26,12 +26,18 @@ package net.fabricmc.loom.configuration.accesswidener;
import java.io.File;
import java.io.IOException;
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import com.google.common.base.Preconditions;
import org.gradle.api.Project;
import org.gradle.api.artifacts.Configuration;
import org.gradle.api.artifacts.FileCollectionDependency;
import org.gradle.api.artifacts.ResolvedArtifact;
import org.gradle.api.file.FileCollection;
import net.fabricmc.accesswidener.AccessWidener;
import net.fabricmc.accesswidener.AccessWidenerReader;
@ -80,7 +86,8 @@ public class TransitiveAccessWidenerJarProcessor implements JarProcessor {
}
private List<AccessWidenerFile> getTransitiveAccessWideners() {
List<AccessWidenerFile> accessWideners = new ArrayList<>();
final List<AccessWidenerFile> accessWideners = new ArrayList<>();
final Set<Path> possibleModJars = new HashSet<>();
for (RemappedConfigurationEntry entry : Constants.MOD_COMPILE_ENTRIES) {
// Only apply global AWs from mods that are part of the compile classpath
@ -88,24 +95,35 @@ public class TransitiveAccessWidenerJarProcessor implements JarProcessor {
continue;
}
Set<File> artifacts = extension.getLazyConfigurationProvider(entry.sourceConfiguration())
.get()
.resolve();
final Configuration configuration = extension.getLazyConfigurationProvider(entry.sourceConfiguration()).get();
for (File artifact : artifacts) {
AccessWidenerFile accessWidener = AccessWidenerFile.fromModJar(artifact.toPath());
if (accessWidener == null) {
continue;
}
if (!TransitiveDetectorVisitor.isTransitive(accessWidener.content())) {
// AW does not contain anything transitive, skip over it
continue;
}
accessWideners.add(accessWidener);
// Based off the logic in ModCompileRemapper.
for (ResolvedArtifact artifact : configuration.getResolvedConfiguration().getResolvedArtifacts()) {
possibleModJars.add(artifact.getFile().toPath());
}
for (FileCollectionDependency dependency : configuration.getAllDependencies().withType(FileCollectionDependency.class)) {
FileCollection files = dependency.getFiles();
for (File artifact : files) {
possibleModJars.add(artifact.toPath());
}
}
}
for (Path path : possibleModJars) {
AccessWidenerFile accessWidener = AccessWidenerFile.fromModJar(path);
if (accessWidener == null) {
continue;
}
if (!TransitiveDetectorVisitor.isTransitive(accessWidener.content())) {
// AW does not contain anything transitive, skip over it
continue;
}
accessWideners.add(accessWidener);
}
return accessWideners;

View File

@ -28,7 +28,7 @@ import org.gradle.util.GradleVersion
class LoomTestConstants {
public final static String DEFAULT_GRADLE = GradleVersion.current().getVersion()
public final static String PRE_RELEASE_GRADLE = "7.4-20211011231946+0000"
public final static String PRE_RELEASE_GRADLE = "7.4-20211023222429+0000"
public final static String[] STANDARD_TEST_VERSIONS = [DEFAULT_GRADLE, PRE_RELEASE_GRADLE]
}