diff --git a/src/main/java/net/fabricmc/loom/configuration/accesswidener/TransitiveAccessWidenerJarProcessor.java b/src/main/java/net/fabricmc/loom/configuration/accesswidener/TransitiveAccessWidenerJarProcessor.java index 8ae9938..77156a4 100644 --- a/src/main/java/net/fabricmc/loom/configuration/accesswidener/TransitiveAccessWidenerJarProcessor.java +++ b/src/main/java/net/fabricmc/loom/configuration/accesswidener/TransitiveAccessWidenerJarProcessor.java @@ -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 getTransitiveAccessWideners() { - List accessWideners = new ArrayList<>(); + final List accessWideners = new ArrayList<>(); + final Set 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 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; diff --git a/src/test/groovy/net/fabricmc/loom/test/LoomTestConstants.groovy b/src/test/groovy/net/fabricmc/loom/test/LoomTestConstants.groovy index d198560..5329c9f 100644 --- a/src/test/groovy/net/fabricmc/loom/test/LoomTestConstants.groovy +++ b/src/test/groovy/net/fabricmc/loom/test/LoomTestConstants.groovy @@ -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] }