update libraries; move asset downloading to task that does not run on every build, but only when it is required (runClient and IDEs)
parent
03fb478166
commit
085021dcbb
|
@ -34,15 +34,15 @@ dependencies {
|
||||||
implementation ('org.zeroturnaround:zt-zip:1.13')
|
implementation ('org.zeroturnaround:zt-zip:1.13')
|
||||||
implementation ('com.google.code.gson:gson:2.8.5')
|
implementation ('com.google.code.gson:gson:2.8.5')
|
||||||
implementation ('com.google.guava:guava:27.1-jre')
|
implementation ('com.google.guava:guava:27.1-jre')
|
||||||
implementation ('net.fabricmc:stitch:0.1.2.47') {
|
implementation ('net.fabricmc:stitch:0.1.2.49') {
|
||||||
exclude module: 'enigma'
|
exclude module: 'enigma'
|
||||||
}
|
}
|
||||||
implementation ('net.fabricmc:tiny-remapper:0.1.0.29') {
|
implementation ('net.fabricmc:tiny-remapper:0.1.0.29') {
|
||||||
transitive = false
|
transitive = false
|
||||||
}
|
}
|
||||||
implementation ('org.jetbrains:intellij-fernflower:1.0.0.7')
|
implementation ('org.jetbrains:intellij-fernflower:1.0.0.8')
|
||||||
|
|
||||||
implementation ('net.fabricmc:sponge-mixin:0.7.11.17') {
|
implementation ('net.fabricmc:sponge-mixin:0.7.11.21') {
|
||||||
exclude module: 'launchwrapper'
|
exclude module: 'launchwrapper'
|
||||||
exclude module: 'guava'
|
exclude module: 'guava'
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,13 +39,15 @@ public class LoomGradlePlugin extends AbstractPlugin {
|
||||||
|
|
||||||
makeTask("genSources", GenSourcesTask.class);
|
makeTask("genSources", GenSourcesTask.class);
|
||||||
|
|
||||||
makeTask("genIdeaWorkspace", GenIdeaProjectTask.class).dependsOn("idea").setGroup("ide");
|
makeTask("downloadAssets", DownloadAssetsTask.class);
|
||||||
makeTask("vscode", GenVsCodeProjectTask.class).setGroup("ide");
|
|
||||||
makeTask("genEclipseRuns", GenEclipseRunsTask.class).setGroup("ide");
|
makeTask("genIdeaWorkspace", GenIdeaProjectTask.class).dependsOn("idea", "downloadAssets").setGroup("ide");
|
||||||
|
makeTask("genEclipseRuns", GenEclipseRunsTask.class).dependsOn("downloadAssets").setGroup("ide");
|
||||||
|
makeTask("vscode", GenVsCodeProjectTask.class).dependsOn("downloadAssets").setGroup("ide");
|
||||||
|
|
||||||
makeTask("remapSourcesJar", RemapSourcesJar.class);
|
makeTask("remapSourcesJar", RemapSourcesJar.class);
|
||||||
|
|
||||||
makeTask("runClient", RunClientTask.class).dependsOn("buildNeeded").setGroup("minecraftMapped");
|
makeTask("runClient", RunClientTask.class).dependsOn("buildNeeded", "downloadAssets").setGroup("minecraftMapped");
|
||||||
makeTask("runServer", RunServerTask.class).dependsOn("buildNeeded").setGroup("minecraftMapped");
|
makeTask("runServer", RunServerTask.class).dependsOn("buildNeeded").setGroup("minecraftMapped");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,97 @@
|
||||||
|
/*
|
||||||
|
* This file is part of fabric-loom, licensed under the MIT License (MIT).
|
||||||
|
*
|
||||||
|
* Copyright (c) 2016, 2017, 2018 FabricMC
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
* in the Software without restriction, including without limitation the rights
|
||||||
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
* copies of the Software, and to permit persons to whom the Software is
|
||||||
|
* furnished to do so, subject to the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be included in all
|
||||||
|
* copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
* SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package net.fabricmc.loom.providers;
|
||||||
|
|
||||||
|
import com.google.gson.Gson;
|
||||||
|
import net.fabricmc.loom.LoomGradleExtension;
|
||||||
|
import net.fabricmc.loom.util.Checksum;
|
||||||
|
import net.fabricmc.loom.util.Constants;
|
||||||
|
import net.fabricmc.loom.util.DownloadUtil;
|
||||||
|
import net.fabricmc.loom.util.MinecraftVersionInfo;
|
||||||
|
import net.fabricmc.loom.util.assets.AssetIndex;
|
||||||
|
import net.fabricmc.loom.util.assets.AssetObject;
|
||||||
|
import net.fabricmc.loom.util.progress.ProgressLogger;
|
||||||
|
import org.gradle.api.Project;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.FileReader;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.lang.ref.SoftReference;
|
||||||
|
import java.net.URL;
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
public class MinecraftAssetsProvider {
|
||||||
|
public static void provide(MinecraftProvider minecraftProvider, Project project) throws IOException {
|
||||||
|
LoomGradleExtension extension = project.getExtensions().getByType(LoomGradleExtension.class);
|
||||||
|
MinecraftVersionInfo versionInfo = minecraftProvider.versionInfo;
|
||||||
|
|
||||||
|
MinecraftVersionInfo.AssetIndex assetIndex = versionInfo.assetIndex;
|
||||||
|
|
||||||
|
// get existing cache files
|
||||||
|
File assets = new File(extension.getUserCache(), "assets");
|
||||||
|
if (!assets.exists()) {
|
||||||
|
assets.mkdirs();
|
||||||
|
}
|
||||||
|
|
||||||
|
File assetsInfo = new File(assets, "indexes" + File.separator + assetIndex.getFabricId(minecraftProvider.minecraftVersion) + ".json");
|
||||||
|
if (!assetsInfo.exists() || !Checksum.equals(assetsInfo, assetIndex.sha1)) {
|
||||||
|
project.getLogger().lifecycle(":downloading asset index");
|
||||||
|
DownloadUtil.downloadIfChanged(new URL(assetIndex.url), assetsInfo, project.getLogger());
|
||||||
|
}
|
||||||
|
|
||||||
|
ProgressLogger progressLogger = ProgressLogger.getProgressFactory(project, MinecraftAssetsProvider.class.getName());
|
||||||
|
progressLogger.start("Downloading assets...", "assets");
|
||||||
|
FileReader fileReader = new FileReader(assetsInfo);
|
||||||
|
AssetIndex index = new Gson().fromJson(fileReader, AssetIndex.class);
|
||||||
|
fileReader.close();
|
||||||
|
Map<String, AssetObject> parent = index.getFileMap();
|
||||||
|
final int totalSize = parent.size();
|
||||||
|
int position = 0;
|
||||||
|
project.getLogger().lifecycle(":downloading assets...");
|
||||||
|
for (Map.Entry<String, AssetObject> entry : parent.entrySet()) {
|
||||||
|
AssetObject object = entry.getValue();
|
||||||
|
String sha1 = object.getHash();
|
||||||
|
String filename = "objects" + File.separator + sha1.substring(0, 2) + File.separator + sha1;
|
||||||
|
File file = new File(assets, filename);
|
||||||
|
|
||||||
|
if (!file.exists() || !Checksum.equals(file, sha1)) {
|
||||||
|
project.getLogger().debug(":downloading asset " + entry.getKey());
|
||||||
|
DownloadUtil.downloadIfChanged(new URL(Constants.RESOURCES_BASE + sha1.substring(0, 2) + "/" + sha1), file, project.getLogger(), true);
|
||||||
|
}
|
||||||
|
String assetName = entry.getKey();
|
||||||
|
int end = assetName.lastIndexOf("/") + 1;
|
||||||
|
if (end > 0) {
|
||||||
|
assetName = assetName.substring(end);
|
||||||
|
}
|
||||||
|
progressLogger.progress(assetName + " - " + position + "/" + totalSize + " (" + (int) ((position / (double) totalSize) * 100) + "%) assets downloaded");
|
||||||
|
position++;
|
||||||
|
}
|
||||||
|
|
||||||
|
progressLogger.completed();
|
||||||
|
}
|
||||||
|
}
|
|
@ -46,7 +46,6 @@ import java.util.Map;
|
||||||
public class MinecraftLibraryProvider {
|
public class MinecraftLibraryProvider {
|
||||||
|
|
||||||
public File MINECRAFT_LIBS;
|
public File MINECRAFT_LIBS;
|
||||||
public File MINECRAFT_NATIVES;
|
|
||||||
|
|
||||||
private Collection<File> libs = new HashSet<>();
|
private Collection<File> libs = new HashSet<>();
|
||||||
|
|
||||||
|
@ -69,50 +68,6 @@ public class MinecraftLibraryProvider {
|
||||||
project.getDependencies().add(Constants.MINECRAFT_DEPENDENCIES, project.getDependencies().module(library.getArtifactName()));
|
project.getDependencies().add(Constants.MINECRAFT_DEPENDENCIES, project.getDependencies().module(library.getArtifactName()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
MinecraftVersionInfo.AssetIndex assetIndex = versionInfo.assetIndex;
|
|
||||||
|
|
||||||
// get existing cache files
|
|
||||||
File assets = new File(extension.getUserCache(), "assets");
|
|
||||||
if (!assets.exists()) {
|
|
||||||
assets.mkdirs();
|
|
||||||
}
|
|
||||||
|
|
||||||
File assetsInfo = new File(assets, "indexes" + File.separator + assetIndex.getFabricId(minecraftProvider.minecraftVersion) + ".json");
|
|
||||||
if (!assetsInfo.exists() || !Checksum.equals(assetsInfo, assetIndex.sha1)) {
|
|
||||||
project.getLogger().lifecycle(":downloading asset index");
|
|
||||||
DownloadUtil.downloadIfChanged(new URL(assetIndex.url), assetsInfo, project.getLogger());
|
|
||||||
}
|
|
||||||
|
|
||||||
ProgressLogger progressLogger = ProgressLogger.getProgressFactory(project, getClass().getName());
|
|
||||||
progressLogger.start("Downloading assets...", "assets");
|
|
||||||
FileReader fileReader = new FileReader(assetsInfo);
|
|
||||||
AssetIndex index = new Gson().fromJson(fileReader, AssetIndex.class);
|
|
||||||
fileReader.close();
|
|
||||||
Map<String, AssetObject> parent = index.getFileMap();
|
|
||||||
final int totalSize = parent.size();
|
|
||||||
int position = 0;
|
|
||||||
project.getLogger().lifecycle(":downloading assets...");
|
|
||||||
for (Map.Entry<String, AssetObject> entry : parent.entrySet()) {
|
|
||||||
AssetObject object = entry.getValue();
|
|
||||||
String sha1 = object.getHash();
|
|
||||||
String filename = "objects" + File.separator + sha1.substring(0, 2) + File.separator + sha1;
|
|
||||||
File file = new File(assets, filename);
|
|
||||||
|
|
||||||
if (!file.exists() || !Checksum.equals(file, sha1)) {
|
|
||||||
project.getLogger().debug(":downloading asset " + entry.getKey());
|
|
||||||
DownloadUtil.downloadIfChanged(new URL(Constants.RESOURCES_BASE + sha1.substring(0, 2) + "/" + sha1), file, project.getLogger(), true);
|
|
||||||
}
|
|
||||||
String assetName = entry.getKey();
|
|
||||||
int end = assetName.lastIndexOf("/") + 1;
|
|
||||||
if (end > 0) {
|
|
||||||
assetName = assetName.substring(end);
|
|
||||||
}
|
|
||||||
progressLogger.progress(assetName + " - " + position + "/" + totalSize + " (" + (int) ((position / (double) totalSize) * 100) + "%) assets downloaded");
|
|
||||||
position++;
|
|
||||||
}
|
|
||||||
|
|
||||||
progressLogger.completed();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Collection<File> getLibraries() {
|
public Collection<File> getLibraries() {
|
||||||
|
|
|
@ -0,0 +1,42 @@
|
||||||
|
/*
|
||||||
|
* This file is part of fabric-loom, licensed under the MIT License (MIT).
|
||||||
|
*
|
||||||
|
* Copyright (c) 2016, 2017, 2018 FabricMC
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
* in the Software without restriction, including without limitation the rights
|
||||||
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
* copies of the Software, and to permit persons to whom the Software is
|
||||||
|
* furnished to do so, subject to the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be included in all
|
||||||
|
* copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
* SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package net.fabricmc.loom.task;
|
||||||
|
|
||||||
|
import net.fabricmc.loom.LoomGradleExtension;
|
||||||
|
import net.fabricmc.loom.providers.MinecraftAssetsProvider;
|
||||||
|
import org.gradle.api.Project;
|
||||||
|
import org.gradle.api.tasks.TaskAction;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
|
public class DownloadAssetsTask extends DefaultLoomTask {
|
||||||
|
@TaskAction
|
||||||
|
public void downloadAssets() throws IOException {
|
||||||
|
Project project = this.getProject();
|
||||||
|
LoomGradleExtension extension = project.getExtensions().getByType(LoomGradleExtension.class);
|
||||||
|
|
||||||
|
MinecraftAssetsProvider.provide(extension.getMinecraftProvider(), project);
|
||||||
|
}
|
||||||
|
}
|
|
@ -24,6 +24,7 @@
|
||||||
|
|
||||||
package net.fabricmc.loom.task;
|
package net.fabricmc.loom.task;
|
||||||
|
|
||||||
|
import net.fabricmc.fernflower.api.IFabricResultSaver;
|
||||||
import org.jetbrains.java.decompiler.main.decompiler.BaseDecompiler;
|
import org.jetbrains.java.decompiler.main.decompiler.BaseDecompiler;
|
||||||
import org.jetbrains.java.decompiler.main.decompiler.ConsoleDecompiler;
|
import org.jetbrains.java.decompiler.main.decompiler.ConsoleDecompiler;
|
||||||
import org.jetbrains.java.decompiler.main.extern.IBytecodeProvider;
|
import org.jetbrains.java.decompiler.main.extern.IBytecodeProvider;
|
||||||
|
@ -37,7 +38,7 @@ import java.util.jar.JarEntry;
|
||||||
import java.util.jar.JarOutputStream;
|
import java.util.jar.JarOutputStream;
|
||||||
import java.util.jar.Manifest;
|
import java.util.jar.Manifest;
|
||||||
|
|
||||||
public class LoomFernflowerDecompiler extends ConsoleDecompiler {
|
public class LoomFernflowerDecompiler extends ConsoleDecompiler implements IFabricResultSaver {
|
||||||
private final Map<String, int[]> differingMappings = new HashMap<>();
|
private final Map<String, int[]> differingMappings = new HashMap<>();
|
||||||
private final String jarName;
|
private final String jarName;
|
||||||
|
|
||||||
|
@ -82,13 +83,19 @@ public class LoomFernflowerDecompiler extends ConsoleDecompiler {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void saveClassEntry(String s, String s1, String s2, String s3, String s4) {
|
||||||
|
System.err.println("Warning: No line mapping provided for " + s1 + " : " + s2 + "!");
|
||||||
|
super.saveClassEntry(s, s1, s2, s3, s4);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void saveClassEntry(String s, String s1, String s2, String s3, String s4, int[] mapping) {
|
public void saveClassEntry(String s, String s1, String s2, String s3, String s4, int[] mapping) {
|
||||||
if (mapping != null) {
|
if (mapping != null) {
|
||||||
differingMappings.put(s2, mapping);
|
differingMappings.put(s2, mapping);
|
||||||
}
|
}
|
||||||
|
|
||||||
super.saveClassEntry(s, jarName, s2, s3, s4, mapping);
|
super.saveClassEntry(s, jarName, s2, s3, s4);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
Loading…
Reference in New Issue