From fba35ed610dc4f9729beca27dc66e73c806e4b6c Mon Sep 17 00:00:00 2001 From: Raven Szewczyk Date: Fri, 5 Apr 2024 16:59:40 +0100 Subject: [PATCH] Fix Gradle 8.7 compat --- gradle/wrapper/gradle-wrapper.properties | 2 +- .../retrofuturagradle/mcp/MCPTasks.java | 27 +------- .../util/FileWithSourcesDependency.java | 65 ------------------- 3 files changed, 3 insertions(+), 91 deletions(-) delete mode 100644 plugin/src/main/java/com/gtnewhorizons/retrofuturagradle/util/FileWithSourcesDependency.java diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 829e1a5a..bb6c1919 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-all.zip networkTimeout=10000 zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/plugin/src/main/java/com/gtnewhorizons/retrofuturagradle/mcp/MCPTasks.java b/plugin/src/main/java/com/gtnewhorizons/retrofuturagradle/mcp/MCPTasks.java index 4c191319..25ebbe09 100644 --- a/plugin/src/main/java/com/gtnewhorizons/retrofuturagradle/mcp/MCPTasks.java +++ b/plugin/src/main/java/com/gtnewhorizons/retrofuturagradle/mcp/MCPTasks.java @@ -25,7 +25,6 @@ import org.gradle.api.UnknownTaskException; import org.gradle.api.artifacts.Configuration; import org.gradle.api.artifacts.Dependency; -import org.gradle.api.artifacts.DependencySet; import org.gradle.api.artifacts.ModuleDependency; import org.gradle.api.artifacts.ResolvedArtifact; import org.gradle.api.artifacts.ResolvedDependency; @@ -70,7 +69,6 @@ import com.gtnewhorizons.retrofuturagradle.minecraft.MinecraftTasks; import com.gtnewhorizons.retrofuturagradle.minecraft.RunMinecraftTask; import com.gtnewhorizons.retrofuturagradle.util.Distribution; -import com.gtnewhorizons.retrofuturagradle.util.FileWithSourcesDependency; import com.gtnewhorizons.retrofuturagradle.util.IJarOutputTask; import com.gtnewhorizons.retrofuturagradle.util.IJarTransformTask; import com.gtnewhorizons.retrofuturagradle.util.JarChain; @@ -505,31 +503,8 @@ public MCPTasks(Project project, MinecraftExtension mcExt, MinecraftTasks mcTask .configure(task -> task.from(injectedSourceSet.getOutput().getAsFileTree())); // A dummy source set to satisfy IntelliJ native launch configurations - final Configuration cfgBuiltMc = project.getConfigurations().create("builtMinecraft"); - { - cfgBuiltMc.setCanBeResolved(false); - cfgBuiltMc.setCanBeConsumed(false); - cfgBuiltMc.setVisible(false); - DependencySet builtMcDeps = cfgBuiltMc.getDependencies(); - - builtMcDeps.addLater( - mcExt.getForgeVersion().map( - forgeVer -> new FileWithSourcesDependency( - layout.files(taskPackagePatchedMc), - "rfg", - "forgeBin", - forgeVer))); - builtMcDeps.addLater( - mcExt.getMcVersion().map( - mcVer -> new FileWithSourcesDependency( - layout.files(taskPackageMcLauncher), - "rfg", - "gradleStart", - mcVer))); - } final SourceSet ideMainSet = sourceSets.create("ideVirtualMain", sourceSet -> { project.getConfigurations().named(sourceSet.getImplementationConfigurationName()).configure(ideConfig -> { - ideConfig.extendsFrom(cfgBuiltMc); ideConfig.extendsFrom(patchedConfiguration); ideConfig.extendsFrom(mcTasks.getLwjgl2Configuration()); ideConfig.extendsFrom( @@ -537,6 +512,8 @@ public MCPTasks(Project project, MinecraftExtension mcExt, MinecraftTasks mcTask }); final ConfigurableFileCollection classpath = objects.fileCollection(); + classpath.from(patchedMcSources.getOutput()); + classpath.from(launcherSources.getOutput()); classpath.from(mainSet.getOutput()); classpath.from(apiSet.getOutput()); diff --git a/plugin/src/main/java/com/gtnewhorizons/retrofuturagradle/util/FileWithSourcesDependency.java b/plugin/src/main/java/com/gtnewhorizons/retrofuturagradle/util/FileWithSourcesDependency.java deleted file mode 100644 index 764c0dd5..00000000 --- a/plugin/src/main/java/com/gtnewhorizons/retrofuturagradle/util/FileWithSourcesDependency.java +++ /dev/null @@ -1,65 +0,0 @@ -package com.gtnewhorizons.retrofuturagradle.util; - -import java.util.Objects; - -import org.gradle.api.artifacts.Dependency; -import org.gradle.api.artifacts.component.ComponentIdentifier; -import org.gradle.api.file.FileCollection; -import org.gradle.api.internal.artifacts.dependencies.DefaultSelfResolvingDependency; -import org.gradle.api.internal.file.FileCollectionInternal; - -/** - * A simple wrapper around the Gradle file-based dependency, that can provide a custom group/name/version. - */ -public class FileWithSourcesDependency extends DefaultSelfResolvingDependency { - - private final String group; - private final String name; - private final String version; - - public FileWithSourcesDependency(FileCollection source, String group, String name, String version) { - super((FileCollectionInternal) source); - this.group = group; - this.name = name; - this.version = version; - } - - public FileWithSourcesDependency(ComponentIdentifier targetComponentId, FileCollection source, String group, - String name, String version) { - super(targetComponentId, (FileCollectionInternal) source); - this.group = group; - this.name = name; - this.version = version; - } - - @Override - public boolean contentEquals(Dependency dependency) { - if (dependency instanceof FileWithSourcesDependency fdep) { - return super.contentEquals(dependency) && Objects.equals(group, fdep.group) - && Objects.equals(name, fdep.name) - && Objects.equals(version, fdep.version); - } else { - return false; - } - } - - @Override - public FileWithSourcesDependency copy() { - return new FileWithSourcesDependency(getTargetComponentId(), getFiles(), group, name, version); - } - - @Override - public String getGroup() { - return group; - } - - @Override - public String getName() { - return name; - } - - @Override - public String getVersion() { - return version; - } -}