Skip to content

Commit

Permalink
Update deps, suppress 8.11 warnings, remove self resolving dependency…
Browse files Browse the repository at this point in the history
… code (#1180)

* Update a handful of deps

* Fully remove deprecated SelfResolvingDependency support

* Work around Gradle 8.11 deprecation, lets deal with it later.
  • Loading branch information
modmuss50 authored Sep 26, 2024
1 parent 567f978 commit e4d4503
Show file tree
Hide file tree
Showing 12 changed files with 28 additions and 219 deletions.
2 changes: 1 addition & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ gson = "2.10.1"
guava = "33.0.0-jre"

stitch = "0.6.2"
tiny-remapper = "0.10.3"
tiny-remapper = "0.10.4"
access-widener = "2.1.0"
mapping-io = "0.6.1"
lorenz-tiny = "4.0.2"
Expand Down
2 changes: 1 addition & 1 deletion gradle/runtime.libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ vineflower = "1.10.1"
mixin-compile-extensions = "0.6.0"
dev-launch-injector = "0.2.1+build.8"
terminal-console-appender = "1.3.0"
jetbrains-annotations = "24.1.0"
jetbrains-annotations = "25.0.0"
native-support = "1.0.1"

[libraries]
Expand Down
12 changes: 6 additions & 6 deletions gradle/test.libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
[versions]
spock = "2.3-groovy-3.0"
junit = "5.10.2"
javalin = "6.1.6"
mockito = "5.12.0"
junit = "5.11.1"
javalin = "6.3.0"
mockito = "5.13.0"
java-debug = "0.52.0"
mixin = "0.12.5+mixin.0.8.5"
mixin = "0.15.3+mixin.0.8.7"

gradle-nightly = "8.11-20240814172604+0000"
fabric-loader = "0.15.11"
gradle-nightly = "8.11-20240926001708+0000"
fabric-loader = "0.16.5"
fabric-installer = "1.0.1"

[libraries]
Expand Down
3 changes: 0 additions & 3 deletions src/main/java/net/fabricmc/loom/LoomGradleExtension.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@
import net.fabricmc.loom.configuration.providers.minecraft.mapped.IntermediaryMinecraftProvider;
import net.fabricmc.loom.configuration.providers.minecraft.mapped.NamedMinecraftProvider;
import net.fabricmc.loom.extension.LoomFiles;
import net.fabricmc.loom.extension.LoomProblemReporter;
import net.fabricmc.loom.extension.MixinExtension;
import net.fabricmc.loom.extension.RemapperExtensionHolder;
import net.fabricmc.loom.util.download.DownloadBuilder;
Expand Down Expand Up @@ -116,7 +115,5 @@ default List<Path> getMinecraftJars(MappingsNamespace mappingsNamespace) {

Collection<LayeredMappingsFactory> getLayeredMappingFactories();

LoomProblemReporter getProblemReporter();

boolean isConfigurationCacheActive();
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,6 @@
import org.gradle.api.artifacts.component.ComponentIdentifier;
import org.gradle.api.artifacts.component.ModuleComponentIdentifier;

import net.fabricmc.loom.LoomGradleExtension;
import net.fabricmc.loom.util.gradle.SelfResolvingDependencyUtils;

public class DependencyInfo {
final Project project;
final Dependency dependency;
Expand All @@ -66,10 +63,7 @@ public static DependencyInfo create(Project project, Configuration configuration
}

public static DependencyInfo create(Project project, Dependency dependency, Configuration sourceConfiguration) {
if (SelfResolvingDependencyUtils.isExplicitSRD(dependency)) {
LoomGradleExtension.get(project).getProblemReporter().reportSelfResolvingDependencyUsage();
return FileDependencyInfo.createForDeprecatedSRD(project, dependency, sourceConfiguration);
} else if (dependency instanceof FileCollectionDependency fileCollectionDependency) {
if (dependency instanceof FileCollectionDependency fileCollectionDependency) {
return new FileDependencyInfo(project, fileCollectionDependency, sourceConfiguration);
} else {
return new DependencyInfo(project, dependency, sourceConfiguration);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@
import org.gradle.api.artifacts.FileCollectionDependency;

import net.fabricmc.loom.util.ZipUtils;
import net.fabricmc.loom.util.gradle.SelfResolvingDependencyUtils;

public class FileDependencyInfo extends DependencyInfo {
protected final Map<String, File> classifierToFile = new HashMap<>();
Expand Down Expand Up @@ -131,15 +130,6 @@ private FileDependencyInfo(Project project, Dependency dependency, Configuration
}
}

@Deprecated // Remove in Gradle 9
public static FileDependencyInfo createForDeprecatedSRD(Project project, Dependency dependency, Configuration configuration) {
if (!SelfResolvingDependencyUtils.isExplicitSRD(dependency)) {
throw new IllegalArgumentException("Dependency is a FileCollectionDependency");
}

return new FileDependencyInfo(project, dependency, configuration, SelfResolvingDependencyUtils.resolve(dependency));
}

@Override
public String getResolvedVersion() {
return version;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ private static Stream<Project> getLoomProjectDependencies(Configuration configur
return configuration.getAllDependencies()
.withType(ProjectDependency.class)
.stream()
.map(ProjectDependency::getDependencyProject)
.map(GradleUtils::getDependencyProject)
.filter(GradleUtils::isLoomProject);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,27 +34,11 @@

import net.fabricmc.loom.api.mappings.layered.MappingContext;
import net.fabricmc.loom.api.mappings.layered.spec.FileSpec;
import net.fabricmc.loom.configuration.providers.mappings.GradleMappingContext;
import net.fabricmc.loom.util.gradle.SelfResolvingDependencyUtils;

public record DependencyFileSpec(Dependency dependency) implements FileSpec {
@Override
public Path get(MappingContext context) {
if (SelfResolvingDependencyUtils.isExplicitSRD(dependency)) {
if (context instanceof GradleMappingContext gradleMappingContext) {
gradleMappingContext.getExtension().getProblemReporter().reportSelfResolvingDependencyUsage();
}

Set<File> files = SelfResolvingDependencyUtils.resolve(dependency);

if (files.isEmpty()) {
throw new RuntimeException("SelfResolvingDependency (%s) resolved no files".formatted(dependency.toString()));
} else if (files.size() > 1) {
throw new RuntimeException("SelfResolvingDependency (%s) resolved too many files (%d) only 1 is expected".formatted(dependency.toString(), files.size()));
}

return files.iterator().next().toPath();
} else if (dependency instanceof FileCollectionDependency fileCollectionDependency) {
if (dependency instanceof FileCollectionDependency fileCollectionDependency) {
Set<File> files = fileCollectionDependency.getFiles().getFiles();

if (files.isEmpty()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@ public abstract class LoomGradleExtensionImpl extends LoomGradleExtensionApiImpl
private InstallerData installerData;
private boolean refreshDeps;
private final ListProperty<LibraryProcessorManager.LibraryProcessorFactory> libraryProcessorFactories;
private final LoomProblemReporter problemReporter;
private final boolean configurationCacheActive;
private final boolean isolatedProjectsActive;

Expand Down Expand Up @@ -113,8 +112,6 @@ public LoomGradleExtensionImpl(Project project, LoomFiles files) {
if (refreshDeps) {
project.getLogger().lifecycle("Refresh dependencies is in use, loom will be significantly slower.");
}

problemReporter = project.getObjects().newInstance(LoomProblemReporter.class);
}

@Override
Expand Down Expand Up @@ -288,11 +285,6 @@ protected <T extends IntermediateMappingsProvider> void configureIntermediateMap
provider.getIsLegacyMinecraft().disallowChanges();
}

@Override
public LoomProblemReporter getProblemReporter() {
return problemReporter;
}

@Override
public boolean isConfigurationCacheActive() {
return configurationCacheActive;
Expand Down
51 changes: 0 additions & 51 deletions src/main/java/net/fabricmc/loom/extension/LoomProblemReporter.java

This file was deleted.

17 changes: 17 additions & 0 deletions src/main/java/net/fabricmc/loom/util/gradle/GradleUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,13 @@
package net.fabricmc.loom.util.gradle;

import java.io.File;
import java.lang.reflect.Field;
import java.util.function.Consumer;

import org.gradle.api.Project;
import org.gradle.api.artifacts.ProjectDependency;
import org.gradle.api.file.RegularFileProperty;
import org.gradle.api.internal.artifacts.dependencies.DefaultProjectDependency;
import org.gradle.api.invocation.Gradle;
import org.gradle.api.provider.Provider;

Expand Down Expand Up @@ -88,4 +91,18 @@ public static File configurationInputFile(Project project, File file) {
property.set(file);
return property.getAsFile().get();
}

// Get the project from the field with reflection to suppress the deprecation warning.
// If you hate it find a solution yourself and make a PR, I'm getting a bit tired of chasing Gradle updates
public static Project getDependencyProject(ProjectDependency projectDependency) {
try {
final Class<DefaultProjectDependency> clazz = DefaultProjectDependency.class;
final Field dependencyProject = clazz.getDeclaredField("dependencyProject");
dependencyProject.setAccessible(true);
return (Project) dependencyProject.get(projectDependency);
} catch (NoSuchFieldException | IllegalAccessException ignored) {
// Just fallback and trigger the warning, this will break in Gradle 9
return projectDependency.getDependencyProject();
}
}
}

This file was deleted.

0 comments on commit e4d4503

Please sign in to comment.