diff --git a/buildSrc/src/main/java/quilt/internal/plugin/MinecraftJarsPlugin.java b/buildSrc/src/main/java/quilt/internal/plugin/MinecraftJarsPlugin.java
index 25d2f1a45e..79e4fe9bc9 100644
--- a/buildSrc/src/main/java/quilt/internal/plugin/MinecraftJarsPlugin.java
+++ b/buildSrc/src/main/java/quilt/internal/plugin/MinecraftJarsPlugin.java
@@ -2,20 +2,21 @@
import org.gradle.api.Project;
import org.gradle.api.file.Directory;
+import org.gradle.api.provider.Property;
import org.gradle.api.provider.Provider;
import org.gradle.api.tasks.TaskContainer;
import org.gradle.api.tasks.TaskProvider;
import org.jetbrains.annotations.NotNull;
import quilt.internal.Constants;
import quilt.internal.plugin.abstraction.DefaultTaskedMappingsProjectPlugin;
-import quilt.internal.task.VersionDownloadInfoConsumingTask;
+import quilt.internal.task.VersionParserConsumingTask;
import quilt.internal.task.setup.DownloadMinecraftJarsTask;
import quilt.internal.task.setup.DownloadMinecraftLibrariesTask;
import quilt.internal.task.setup.DownloadVersionsManifestTask;
import quilt.internal.task.setup.DownloadWantedVersionManifestTask;
import quilt.internal.task.setup.ExtractServerJarTask;
import quilt.internal.task.setup.MergeJarsTask;
-import quilt.internal.util.VersionDownloadInfo;
+import quilt.internal.util.serializable.VersionParser;
/**
* {@linkplain TaskContainer#register Registers} tasks that download and extract
@@ -26,15 +27,14 @@
*
{@link TaskContainer#register registers} {@value MergeJarsTask#MERGE_JARS_TASK_NAME}
* which merges the client and server jars
* {@linkplain org.gradle.api.tasks.TaskCollection#configureEach configures} the default value of
- * {@link VersionDownloadInfoConsumingTask}s'
- * {@link VersionDownloadInfoConsumingTask#getVersionDownloadInfo versionDownloadInfo} to
+ * {@link VersionParserConsumingTask}s'
+ * {@link VersionParserConsumingTask#getVersionParser versionParser} to
* {@value DownloadWantedVersionManifestTask#DOWNLOAD_WANTED_VERSION_MANIFEST_TASK_NAME}'s
- * {@linkplain DownloadWantedVersionManifestTask#provideVersionDownloadInfo provided}
- * {@link VersionDownloadInfo}
+ * {@linkplain DownloadWantedVersionManifestTask#provideVersionParser provided}
+ * {@link VersionParser}
*
*/
public abstract class MinecraftJarsPlugin extends DefaultTaskedMappingsProjectPlugin {
-
@Override
protected Tasks applyImpl(@NotNull Project project) {
final Provider minecraftDir = this.getMinecraftDir();
@@ -65,13 +65,13 @@ protected Tasks applyImpl(@NotNull Project project) {
);
// put mapped provider in a property so all tasks use the same cached value
- final Provider versionDownloadInfo =
- this.getObjects().property(VersionDownloadInfo.class).convention(
- downloadWantedVersionManifest.flatMap(DownloadWantedVersionManifestTask::provideVersionDownloadInfo)
- );
+ final Property versionParser = this.getObjects().property(VersionParser.class);
+ versionParser.set(
+ downloadWantedVersionManifest.flatMap(DownloadWantedVersionManifestTask::provideVersionParser)
+ );
- tasks.withType(VersionDownloadInfoConsumingTask.class).configureEach(task -> {
- task.getVersionDownloadInfo().convention(versionDownloadInfo);
+ tasks.withType(VersionParserConsumingTask.class).configureEach(task -> {
+ task.getVersionParser().convention(versionParser);
});
}
diff --git a/buildSrc/src/main/java/quilt/internal/plugin/TargetDiffPlugin.java b/buildSrc/src/main/java/quilt/internal/plugin/TargetDiffPlugin.java
index 1b8768050c..2d94429154 100644
--- a/buildSrc/src/main/java/quilt/internal/plugin/TargetDiffPlugin.java
+++ b/buildSrc/src/main/java/quilt/internal/plugin/TargetDiffPlugin.java
@@ -109,7 +109,8 @@ public void apply(@NotNull Project project) {
);
// put mapped provider in a property so all tasks use the same cached value
- final Provider targetVersion = this.getObjects().property(String.class).convention(
+ final Property targetVersion = this.getObjects().property(String.class);
+ targetVersion.set(
downloadTargetMetaFile.flatMap(DownloadTargetMetaFileTask::provideTargetVersion)
);
diff --git a/buildSrc/src/main/java/quilt/internal/task/VersionDownloadInfoConsumingTask.java b/buildSrc/src/main/java/quilt/internal/task/VersionParserConsumingTask.java
similarity index 50%
rename from buildSrc/src/main/java/quilt/internal/task/VersionDownloadInfoConsumingTask.java
rename to buildSrc/src/main/java/quilt/internal/task/VersionParserConsumingTask.java
index d927f5da93..0309a7d49f 100644
--- a/buildSrc/src/main/java/quilt/internal/task/VersionDownloadInfoConsumingTask.java
+++ b/buildSrc/src/main/java/quilt/internal/task/VersionParserConsumingTask.java
@@ -3,14 +3,14 @@
import org.gradle.api.provider.Property;
import org.gradle.api.tasks.Input;
import quilt.internal.plugin.MinecraftJarsPlugin;
-import quilt.internal.util.VersionDownloadInfo;
+import quilt.internal.util.serializable.VersionParser;
/**
- * A task that takes {@link VersionDownloadInfo} as input.
+ * A task that takes {@link VersionParser} as input.
*
* @see MinecraftJarsPlugin MinecraftJarsPlugin's configureEach
*/
-public interface VersionDownloadInfoConsumingTask extends MappingsTask {
+public interface VersionParserConsumingTask extends MappingsTask {
@Input
- Property getVersionDownloadInfo();
+ Property getVersionParser();
}
diff --git a/buildSrc/src/main/java/quilt/internal/task/setup/DownloadMinecraftJarsTask.java b/buildSrc/src/main/java/quilt/internal/task/setup/DownloadMinecraftJarsTask.java
index 5d587505fe..8923e7bf6e 100644
--- a/buildSrc/src/main/java/quilt/internal/task/setup/DownloadMinecraftJarsTask.java
+++ b/buildSrc/src/main/java/quilt/internal/task/setup/DownloadMinecraftJarsTask.java
@@ -6,23 +6,24 @@
import com.google.common.hash.HashCode;
import com.google.common.hash.Hashing;
import com.google.common.io.Files;
+import org.gradle.api.GradleException;
import org.gradle.api.file.RegularFileProperty;
import org.gradle.api.tasks.OutputFile;
import org.gradle.api.tasks.TaskAction;
+import org.quiltmc.launchermeta.version.v1.DownloadableFile;
+import org.quiltmc.launchermeta.version.v1.Downloads;
import quilt.internal.Constants.Groups;
import quilt.internal.plugin.MinecraftJarsPlugin;
import quilt.internal.task.DefaultMappingsTask;
-import quilt.internal.task.VersionDownloadInfoConsumingTask;
+import quilt.internal.task.VersionParserConsumingTask;
import quilt.internal.util.DownloadUtil;
-import quilt.internal.util.VersionDownloadInfo;
/**
- * Downloads the Minecraft client and server jars for the passed {@linkplain #getVersionDownloadInfo version}.
+ * Downloads the Minecraft client and server jars for the passed {@linkplain #getVersionParser version}.
*
* @see MinecraftJarsPlugin MinecraftJarsPlugin's configureEach
*/
-public abstract class DownloadMinecraftJarsTask extends DefaultMappingsTask implements
- VersionDownloadInfoConsumingTask {
+public abstract class DownloadMinecraftJarsTask extends DefaultMappingsTask implements VersionParserConsumingTask {
/**
* {@linkplain org.gradle.api.tasks.TaskContainer#register Registered} by
* {@link MinecraftJarsPlugin MinecraftJarsPlugin}.
@@ -39,7 +40,7 @@ public DownloadMinecraftJarsTask() {
super(Groups.SETUP);
// TODO I'm not sure that this is necessary
- // VersionDownloadInfoConsumingTasks indirectly depend on
+ // VersionParserConsumingTasks indirectly depend on
// DownloadVersionManifestFileTask which has @DisableCachingByDefault.
// I'm not sure if gradle considers output files to have been updated when they're overwritten with
// the same content.
@@ -49,11 +50,11 @@ public DownloadMinecraftJarsTask() {
try {
final File clientJar = this.getClientJar().get().getAsFile();
final File serverBootstrapJar = this.getServerBootstrapJar().get().getAsFile();
- final VersionDownloadInfo info = this.getVersionDownloadInfo().get();
+ final Downloads downloads = this.getVersionParser().get().get().getDownloads();
return clientJar.exists() && serverBootstrapJar.exists()
- && validateChecksum(clientJar, info.getClient().getSha1())
- && validateChecksum(serverBootstrapJar, info.getServer().getSha1());
+ && validateChecksum(clientJar, downloads.getClient().getSha1())
+ && validateChecksum(serverBootstrapJar, getServerOrThrow(downloads).getSha1());
} catch (Exception e) {
return false;
}
@@ -64,23 +65,28 @@ && validateChecksum(clientJar, info.getClient().getSha1())
public void download() {
this.getLogger().lifecycle(":downloading minecraft jars");
- final VersionDownloadInfo info = this.getVersionDownloadInfo().get();
+ final Downloads downloads = this.getVersionParser().get().get().getDownloads();
DownloadUtil.download(
- info.getClient().getUrl(),
+ downloads.getClient().getUrl(),
this.getClientJar().get().getAsFile(),
false,
this.getLogger()
);
DownloadUtil.download(
- info.getServer().getUrl(),
+ getServerOrThrow(downloads).getUrl(),
this.getServerBootstrapJar().get().getAsFile(),
false,
this.getLogger()
);
}
+ private static DownloadableFile getServerOrThrow(Downloads downloads) {
+ return downloads.getServer()
+ .orElseThrow(() -> new GradleException("Version has no server download"));
+ }
+
@SuppressWarnings("deprecation")
private static boolean validateChecksum(File file, String checksum) throws IOException {
if (file != null) {
diff --git a/buildSrc/src/main/java/quilt/internal/task/setup/DownloadMinecraftLibrariesTask.java b/buildSrc/src/main/java/quilt/internal/task/setup/DownloadMinecraftLibrariesTask.java
index 0591283446..01519480d3 100644
--- a/buildSrc/src/main/java/quilt/internal/task/setup/DownloadMinecraftLibrariesTask.java
+++ b/buildSrc/src/main/java/quilt/internal/task/setup/DownloadMinecraftLibrariesTask.java
@@ -10,13 +10,15 @@
import org.gradle.api.tasks.OutputFiles;
import org.gradle.api.tasks.TaskAction;
import org.gradle.work.DisableCachingByDefault;
+import org.quiltmc.launchermeta.version.v1.DownloadableFile;
+import org.quiltmc.launchermeta.version.v1.Version;
import quilt.internal.Constants.Groups;
import quilt.internal.plugin.MapMinecraftJarsPlugin;
import quilt.internal.plugin.MinecraftJarsPlugin;
import quilt.internal.task.DefaultMappingsTask;
-import quilt.internal.task.VersionDownloadInfoConsumingTask;
+import quilt.internal.task.VersionParserConsumingTask;
import quilt.internal.util.DownloadUtil;
-import quilt.internal.util.VersionDownloadInfo;
+import quilt.internal.util.serializable.VersionParser;
import javax.inject.Inject;
import java.io.File;
@@ -25,14 +27,14 @@
import java.util.stream.Collectors;
/**
- * Downloads the Minecraft's libraries for the passed {@linkplain #getVersionDownloadInfo version}.
+ * Downloads the Minecraft's libraries for the passed {@linkplain #getVersionParser version}.
*
* @see MinecraftJarsPlugin MinecraftJarsPlugin's configureEach
*/
// TODO why?
@DisableCachingByDefault(because = "unknown")
public abstract class DownloadMinecraftLibrariesTask extends DefaultMappingsTask implements
- VersionDownloadInfoConsumingTask {
+ VersionParserConsumingTask {
/**
* {@linkplain org.gradle.api.tasks.TaskContainer#register Registered} by
* {@link MinecraftJarsPlugin MinecraftJarsPlugin}.
@@ -65,7 +67,9 @@ public DownloadMinecraftLibrariesTask() {
// put this in a property to cache it
final Provider