Update Gradle, Fix mappings not being extracted when using local mappings.

dev/0.11
modmuss50 2017-05-11 13:02:53 +01:00
parent cc56011035
commit aa483181c0
No known key found for this signature in database
GPG Key ID: 203A5ED4D3E48BEA
7 changed files with 16 additions and 40 deletions

Binary file not shown.

View File

@ -1,6 +1,6 @@
#Thu Sep 22 09:58:14 BST 2016 #Wed May 10 22:17:52 BST 2017
distributionBase=GRADLE_USER_HOME distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-3.1-bin.zip distributionUrl=https\://services.gradle.org/distributions/gradle-3.5-bin.zip

View File

@ -29,7 +29,6 @@ import com.google.gson.Gson;
import com.google.gson.JsonElement; import com.google.gson.JsonElement;
import com.google.gson.JsonObject; import com.google.gson.JsonObject;
import net.fabricmc.loom.task.DownloadTask; import net.fabricmc.loom.task.DownloadTask;
import net.fabricmc.loom.task.GenIdeaProjectTask;
import net.fabricmc.loom.util.Constants; import net.fabricmc.loom.util.Constants;
import net.fabricmc.loom.util.ModRemapper; import net.fabricmc.loom.util.ModRemapper;
import net.fabricmc.loom.util.Version; import net.fabricmc.loom.util.Version;
@ -44,10 +43,7 @@ import org.gradle.api.tasks.compile.JavaCompile;
import org.gradle.api.tasks.javadoc.Javadoc; import org.gradle.api.tasks.javadoc.Javadoc;
import org.gradle.plugins.ide.eclipse.model.EclipseModel; import org.gradle.plugins.ide.eclipse.model.EclipseModel;
import org.gradle.plugins.ide.idea.model.IdeaModel; import org.gradle.plugins.ide.idea.model.IdeaModel;
import org.xml.sax.SAXException;
import javax.xml.parsers.ParserConfigurationException;
import javax.xml.transform.TransformerException;
import java.io.File; import java.io.File;
import java.io.FileNotFoundException; import java.io.FileNotFoundException;
import java.io.FileReader; import java.io.FileReader;
@ -264,14 +260,8 @@ public class AbstractPlugin implements Plugin<Project> {
}); });
project.afterEvaluate(project12 -> { project.afterEvaluate(project12 -> {
project12.getTasks().getByName("idea").dependsOn(project12.getTasks().getByName("cleanIdea")).dependsOn(project12.getTasks().getByName("extractNatives")); project12.getTasks().getByName("idea").dependsOn(project12.getTasks().getByName("cleanIdea")).dependsOn(project12.getTasks().getByName("setupFabric")).dependsOn(project12.getTasks().getByName("extractNatives"));
project12.getTasks().getByName("idea").doLast(task -> { project12.getTasks().getByName("idea").finalizedBy(project12.getTasks().getByName("genIdeaWorkspace"));
try {
GenIdeaProjectTask.genIdeaRuns(project12);
} catch (IOException | ParserConfigurationException | SAXException | TransformerException e) {
e.printStackTrace();
}
});
}); });
} }

View File

@ -40,6 +40,7 @@ public class LoomGradlePlugin extends AbstractPlugin {
makeTask("setupFabric", DefaultTask.class).dependsOn("processMods"); makeTask("setupFabric", DefaultTask.class).dependsOn("processMods");
makeTask("extractNatives", ExtractNativesTask.class).dependsOn("download"); makeTask("extractNatives", ExtractNativesTask.class).dependsOn("download");
makeTask("genIdeaWorkspace", GenIdeaProjectTask.class).dependsOn("idea");
makeTask("vscode", GenVSCodeProjectTask.class).dependsOn("extractNatives"); makeTask("vscode", GenVSCodeProjectTask.class).dependsOn("extractNatives");

View File

@ -131,7 +131,7 @@ public class DownloadTask extends DefaultTask {
} }
// Force add LaunchWrapper // Force add LaunchWrapper
dependencyHandler.add(Constants.CONFIG_MC_DEPENDENCIES, "net.minecraft:launchwrapper:1.11"); dependencyHandler.add(Constants.CONFIG_MC_DEPENDENCIES, "net.minecraft:launchwrapper:1.12");
Version.AssetIndex assetIndex = version.assetIndex; Version.AssetIndex assetIndex = version.assetIndex;

View File

@ -29,7 +29,9 @@ import net.fabricmc.loom.LoomGradleExtension;
import net.fabricmc.loom.util.Constants; import net.fabricmc.loom.util.Constants;
import net.fabricmc.loom.util.IdeaRunConfig; import net.fabricmc.loom.util.IdeaRunConfig;
import net.fabricmc.loom.util.Version; import net.fabricmc.loom.util.Version;
import org.gradle.api.DefaultTask;
import org.gradle.api.Project; import org.gradle.api.Project;
import org.gradle.api.tasks.TaskAction;
import org.w3c.dom.Document; import org.w3c.dom.Document;
import org.w3c.dom.Element; import org.w3c.dom.Element;
import org.w3c.dom.Node; import org.w3c.dom.Node;
@ -49,10 +51,13 @@ import java.io.File;
import java.io.FileReader; import java.io.FileReader;
import java.io.IOException; import java.io.IOException;
public class GenIdeaProjectTask { public class GenIdeaProjectTask extends DefaultTask {
public static void genIdeaRuns(Project project) throws IOException, ParserConfigurationException, SAXException, TransformerException { @TaskAction
public void genIdeaRuns() throws IOException, ParserConfigurationException, SAXException, TransformerException {
Project project = this.getProject();
LoomGradleExtension extension = project.getExtensions().getByType(LoomGradleExtension.class); LoomGradleExtension extension = project.getExtensions().getByType(LoomGradleExtension.class);
project.getLogger().lifecycle(":Building idea workspace");
File file = new File(project.getName() + ".iml"); File file = new File(project.getName() + ".iml");
DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance(); DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance();
@ -101,27 +106,6 @@ public class GenIdeaProjectTask {
Version version = gson.fromJson(new FileReader(Constants.MINECRAFT_JSON.get(extension)), Version.class); Version version = gson.fromJson(new FileReader(Constants.MINECRAFT_JSON.get(extension)), Version.class);
for (Version.Library library : version.libraries) {
if (library.allowed() && library.getFile(extension) != null && library.getFile(extension).exists()) {
Element node = doc.createElement("orderEntry");
node.setAttribute("type", "module-library");
Element libraryElement = doc.createElement("library");
Element classes = doc.createElement("CLASSES");
Element javadoc = doc.createElement("JAVADOC");
Element sources = doc.createElement("SOURCES");
Element root = doc.createElement("root");
root.setAttribute("url", "jar://" + library.getFile(extension).getAbsolutePath() + "!/");
classes.appendChild(root);
libraryElement.appendChild(classes);
libraryElement.appendChild(javadoc);
libraryElement.appendChild(sources);
node.appendChild(libraryElement);
component.appendChild(node);
} else if (!library.allowed()) {
project.getLogger().info(":" + library.getFile(extension).getName() + " is not allowed on this os");
}
}
TransformerFactory transformerFactory = TransformerFactory.newInstance(); TransformerFactory transformerFactory = TransformerFactory.newInstance();
Transformer transformer = transformerFactory.newTransformer(); Transformer transformer = transformerFactory.newTransformer();
DOMSource source = new DOMSource(doc); DOMSource source = new DOMSource(doc);

View File

@ -58,8 +58,9 @@ public class MapJarsTask extends DefaultTask {
FileUtils.copyFile(Constants.MINECRAFT_MERGED_JAR.get(extension), Constants.MINECRAFT_MAPPED_JAR.get(extension)); FileUtils.copyFile(Constants.MINECRAFT_MERGED_JAR.get(extension), Constants.MINECRAFT_MAPPED_JAR.get(extension));
return; return;
} }
this.getLogger().lifecycle(":unpacking mappings"); if (!Constants.MAPPINGS_DIR.get(extension).exists() || extension.localMappings) {
if (!Constants.MAPPINGS_DIR.get(extension).exists()) { this.getLogger().lifecycle(":unpacking mappings");
FileUtils.deleteDirectory(Constants.MAPPINGS_DIR.get(extension));
ZipUtil.unpack(Constants.MAPPINGS_ZIP.get(extension), Constants.MAPPINGS_DIR.get(extension)); ZipUtil.unpack(Constants.MAPPINGS_ZIP.get(extension), Constants.MAPPINGS_DIR.get(extension));
} }