Remove need to use genIdeaRuns, now just use the idea task
Remove making everything public - breaks a lot of shitdev/0.11
parent
22f1743a08
commit
85d51cb1a1
|
@ -1,6 +1,6 @@
|
|||
# fabric-loom
|
||||
Gradle plugin for Fabric
|
||||
|
||||
Usage: `gradlew setupFabric genIdeaRuns`
|
||||
Usage: `gradlew setupFabric idea`
|
||||
(Prefix with `./` on macOS and Linux)
|
||||
|
||||
|
|
|
@ -29,8 +29,11 @@ import com.google.gson.Gson;
|
|||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonObject;
|
||||
import net.fabricmc.loom.task.DownloadTask;
|
||||
import net.fabricmc.loom.task.GenIdeaProjectTask;
|
||||
import net.fabricmc.loom.util.BuidRemapper;
|
||||
import net.fabricmc.loom.util.Constants;
|
||||
import net.fabricmc.loom.util.Version;
|
||||
import org.gradle.api.Action;
|
||||
import org.gradle.api.Plugin;
|
||||
import org.gradle.api.Project;
|
||||
import org.gradle.api.Task;
|
||||
|
@ -42,7 +45,10 @@ import org.gradle.api.tasks.compile.JavaCompile;
|
|||
import org.gradle.api.tasks.javadoc.Javadoc;
|
||||
import org.gradle.plugins.ide.eclipse.model.EclipseModel;
|
||||
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.FileNotFoundException;
|
||||
import java.io.FileReader;
|
||||
|
@ -237,6 +243,24 @@ public class AbstractPlugin implements Plugin<Project> {
|
|||
}
|
||||
project1.getDependencies().add(Constants.PROCESS_MODS_DEPENDENCIES, "net.fabricmc:fabric-base:16w38a-0.0.4-SNAPSHOT");
|
||||
});
|
||||
|
||||
project.getTasks().getByName("build").doLast(task -> {
|
||||
project.getLogger().lifecycle(":remapping mods");
|
||||
BuidRemapper.reamp(project);
|
||||
});
|
||||
|
||||
project.afterEvaluate(project12 -> {
|
||||
project12.getTasks().getByName("idea").dependsOn(project12.getTasks().getByName("cleanIdea")).dependsOn(project12.getTasks().getByName("extractNatives"));
|
||||
project12.getTasks().getByName("idea").doLast(task -> {
|
||||
try {
|
||||
GenIdeaProjectTask.genIdeaRuns(project12);
|
||||
} catch (IOException | ParserConfigurationException | SAXException | TransformerException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
|
||||
protected void readModJson(LoomGradleExtension extension) {
|
||||
|
|
|
@ -40,7 +40,6 @@ public class LoomGradlePlugin extends AbstractPlugin {
|
|||
makeTask("setupFabric", DefaultTask.class).dependsOn("processMods");
|
||||
|
||||
makeTask("extractNatives", ExtractNativesTask.class).dependsOn("download");
|
||||
makeTask("genIdeaRuns", GenIdeaProjectTask.class).dependsOn("cleanIdea").dependsOn("idea").dependsOn("extractNatives");
|
||||
|
||||
makeTask("vscode", GenVSCodeProjectTask.class).dependsOn("extractNatives");
|
||||
|
||||
|
|
|
@ -30,6 +30,7 @@ import net.fabricmc.loom.util.Constants;
|
|||
import net.fabricmc.loom.util.IdeaRunConfig;
|
||||
import net.fabricmc.loom.util.Version;
|
||||
import org.gradle.api.DefaultTask;
|
||||
import org.gradle.api.Project;
|
||||
import org.gradle.api.tasks.TaskAction;
|
||||
import org.w3c.dom.Document;
|
||||
import org.w3c.dom.Element;
|
||||
|
@ -50,12 +51,12 @@ import java.io.File;
|
|||
import java.io.FileReader;
|
||||
import java.io.IOException;
|
||||
|
||||
public class GenIdeaProjectTask extends DefaultTask {
|
||||
@TaskAction
|
||||
public void genIdeaRuns() throws IOException, ParserConfigurationException, SAXException, TransformerException {
|
||||
LoomGradleExtension extension = this.getProject().getExtensions().getByType(LoomGradleExtension.class);
|
||||
public class GenIdeaProjectTask {
|
||||
|
||||
File file = new File(getProject().getName() + ".iml");
|
||||
public static void genIdeaRuns(Project project) throws IOException, ParserConfigurationException, SAXException, TransformerException {
|
||||
LoomGradleExtension extension = project.getExtensions().getByType(LoomGradleExtension.class);
|
||||
|
||||
File file = new File(project.getName() + ".iml");
|
||||
DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance();
|
||||
DocumentBuilder docBuilder = docFactory.newDocumentBuilder();
|
||||
Document doc = docBuilder.parse(file);
|
||||
|
@ -70,7 +71,7 @@ public class GenIdeaProjectTask extends DefaultTask {
|
|||
}
|
||||
|
||||
if (component == null) {
|
||||
this.getLogger().lifecycle(":failed to generate intellij run configurations");
|
||||
project.getLogger().lifecycle(":failed to generate intellij run configurations");
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -84,7 +85,7 @@ public class GenIdeaProjectTask extends DefaultTask {
|
|||
}
|
||||
|
||||
if (content == null) {
|
||||
this.getLogger().lifecycle(":failed to generate intellij run configurations");
|
||||
project.getLogger().lifecycle(":failed to generate intellij run configurations");
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -119,7 +120,7 @@ public class GenIdeaProjectTask extends DefaultTask {
|
|||
node.appendChild(libraryElement);
|
||||
component.appendChild(node);
|
||||
} else if (!library.allowed()) {
|
||||
this.getLogger().info(":" + library.getFile(extension).getName() + " is not allowed on this os");
|
||||
project.getLogger().info(":" + library.getFile(extension).getName() + " is not allowed on this os");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -131,7 +132,7 @@ public class GenIdeaProjectTask extends DefaultTask {
|
|||
transformer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "2");
|
||||
transformer.transform(source, result);
|
||||
|
||||
file = new File(getProject().getName() + ".iws");
|
||||
file = new File(project.getName() + ".iws");
|
||||
docFactory = DocumentBuilderFactory.newInstance();
|
||||
docBuilder = docFactory.newDocumentBuilder();
|
||||
doc = docBuilder.parse(file);
|
||||
|
@ -147,13 +148,13 @@ public class GenIdeaProjectTask extends DefaultTask {
|
|||
}
|
||||
|
||||
if (runManager == null) {
|
||||
this.getLogger().lifecycle(":failed to generate intellij run configurations");
|
||||
project.getLogger().lifecycle(":failed to generate intellij run configurations");
|
||||
return;
|
||||
}
|
||||
|
||||
IdeaRunConfig ideaClient = new IdeaRunConfig();
|
||||
ideaClient.mainClass = "net.minecraft.launchwrapper.Launch";
|
||||
ideaClient.projectName = getProject().getName();
|
||||
ideaClient.projectName = project.getName();
|
||||
ideaClient.configName = "Minecraft Client";
|
||||
ideaClient.runDir = "file://$PROJECT_DIR$/" + extension.runDir;
|
||||
ideaClient.vmArgs = "-Djava.library.path=" + Constants.MINECRAFT_NATIVES.get(extension).getAbsolutePath() + " -Dfabric.development=true";
|
||||
|
@ -163,7 +164,7 @@ public class GenIdeaProjectTask extends DefaultTask {
|
|||
|
||||
IdeaRunConfig ideaServer = new IdeaRunConfig();
|
||||
ideaServer.mainClass = "net.minecraft.launchwrapper.Launch";
|
||||
ideaServer.projectName = getProject().getName();
|
||||
ideaServer.projectName = project.getName();
|
||||
ideaServer.configName = "Minecraft Server";
|
||||
ideaServer.runDir = "file://$PROJECT_DIR$/" + extension.runDir;
|
||||
ideaServer.vmArgs = "-Dfabric.development=true";
|
||||
|
|
|
@ -95,36 +95,10 @@ public class MapJarsTask extends DefaultTask {
|
|||
|
||||
@Override
|
||||
public CtClass transform(CtClass ctClass) throws Exception {
|
||||
return publify(loader.transformClass(ctClass));
|
||||
return loader.transformClass(ctClass);
|
||||
}
|
||||
}
|
||||
|
||||
//Taken from enigma, anc changed a little
|
||||
public static CtClass publify(CtClass c) {
|
||||
|
||||
for (CtField field : c.getDeclaredFields()) {
|
||||
field.setModifiers(publify(field.getModifiers()));
|
||||
}
|
||||
for (CtBehavior behavior : c.getDeclaredBehaviors()) {
|
||||
behavior.setModifiers(publify(behavior.getModifiers()));
|
||||
}
|
||||
InnerClassesAttribute attr = (InnerClassesAttribute) c.getClassFile().getAttribute(InnerClassesAttribute.tag);
|
||||
if (attr != null) {
|
||||
for (int i = 0; i < attr.tableLength(); i++) {
|
||||
attr.setAccessFlags(i, publify(attr.accessFlags(i)));
|
||||
}
|
||||
}
|
||||
|
||||
return c;
|
||||
}
|
||||
|
||||
private static int publify(int flags) {
|
||||
if (!AccessFlag.isPublic(flags)) {
|
||||
flags = AccessFlag.setPublic(flags);
|
||||
}
|
||||
return flags;
|
||||
}
|
||||
|
||||
public static class ProgressListener implements Deobfuscator.ProgressListener {
|
||||
@Override
|
||||
public void init(int i, String s) {
|
||||
|
|
|
@ -0,0 +1,34 @@
|
|||
/*
|
||||
* This file is part of fabric-loom, licensed under the MIT License (MIT).
|
||||
*
|
||||
* Copyright (c) 2016 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.util;
|
||||
|
||||
import org.gradle.api.Project;
|
||||
|
||||
public class BuidRemapper {
|
||||
|
||||
public static void reamp(Project project){
|
||||
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue