Auto generate eclipse launch files
parent
f61b06f616
commit
96e0dd30be
|
@ -11,7 +11,7 @@ targetCompatibility = 1.8
|
||||||
|
|
||||||
group = 'net.fabricmc'
|
group = 'net.fabricmc'
|
||||||
archivesBaseName = project.name
|
archivesBaseName = project.name
|
||||||
version = '0.1.0-SNAPSHOT'
|
version = '0.1.1-SNAPSHOT'
|
||||||
|
|
||||||
def build = "local"
|
def build = "local"
|
||||||
def ENV = System.getenv()
|
def ENV = System.getenv()
|
||||||
|
|
|
@ -222,6 +222,7 @@ public class AbstractPlugin implements Plugin<Project> {
|
||||||
dependencyManager.handleDependencies(project1);
|
dependencyManager.handleDependencies(project1);
|
||||||
|
|
||||||
project1.getTasks().getByName("idea").finalizedBy(project1.getTasks().getByName("genIdeaWorkspace"));
|
project1.getTasks().getByName("idea").finalizedBy(project1.getTasks().getByName("genIdeaWorkspace"));
|
||||||
|
project1.getTasks().getByName("eclipse").finalizedBy(project1.getTasks().getByName("genEclipseRuns"));
|
||||||
|
|
||||||
SetupIntelijRunConfigs.setup(project1);
|
SetupIntelijRunConfigs.setup(project1);
|
||||||
|
|
||||||
|
|
|
@ -40,6 +40,7 @@ public class LoomGradlePlugin extends AbstractPlugin {
|
||||||
|
|
||||||
makeTask("genIdeaWorkspace", GenIdeaProjectTask.class).dependsOn("idea").setGroup("ide");
|
makeTask("genIdeaWorkspace", GenIdeaProjectTask.class).dependsOn("idea").setGroup("ide");
|
||||||
makeTask("vscode", GenVsCodeProjectTask.class).setGroup("ide");
|
makeTask("vscode", GenVsCodeProjectTask.class).setGroup("ide");
|
||||||
|
makeTask("genEclipseRuns", GenEclipseRunsTask.class).setGroup("ide");
|
||||||
|
|
||||||
makeTask("runClient", RunClientTask.class).dependsOn("buildNeeded").setGroup("minecraftMapped");
|
makeTask("runClient", RunClientTask.class).dependsOn("buildNeeded").setGroup("minecraftMapped");
|
||||||
makeTask("runServer", RunServerTask.class).dependsOn("buildNeeded").setGroup("minecraftMapped");
|
makeTask("runServer", RunServerTask.class).dependsOn("buildNeeded").setGroup("minecraftMapped");
|
||||||
|
|
|
@ -0,0 +1,53 @@
|
||||||
|
/*
|
||||||
|
* 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.util.RunConfig;
|
||||||
|
import org.apache.commons.io.FileUtils;
|
||||||
|
import org.gradle.api.DefaultTask;
|
||||||
|
import org.gradle.api.tasks.TaskAction;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.nio.charset.StandardCharsets;
|
||||||
|
|
||||||
|
public class GenEclipseRunsTask extends DefaultTask {
|
||||||
|
|
||||||
|
@TaskAction
|
||||||
|
public void genRuns() throws IOException {
|
||||||
|
File clientRunConfigs = new File(getProject().getRootDir(), "Minecraft_Client.launch");
|
||||||
|
File serverRunConfigs = new File(getProject().getRootDir(), "Minecraft_Server.launch");
|
||||||
|
|
||||||
|
String clientRunConfig = RunConfig.clientRunConfig(getProject()).fromDummy("eclipse_run_config_template.xml");
|
||||||
|
String serverRunConfig = RunConfig.serverRunConfig(getProject()).fromDummy("eclipse_run_config_template.xml");
|
||||||
|
|
||||||
|
if(!clientRunConfigs.exists())
|
||||||
|
FileUtils.writeStringToFile(clientRunConfigs, clientRunConfig, StandardCharsets.UTF_8);
|
||||||
|
if(!serverRunConfigs.exists())
|
||||||
|
FileUtils.writeStringToFile(serverRunConfigs, serverRunConfig, StandardCharsets.UTF_8);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -25,7 +25,7 @@
|
||||||
package net.fabricmc.loom.task;
|
package net.fabricmc.loom.task;
|
||||||
|
|
||||||
import net.fabricmc.loom.LoomGradleExtension;
|
import net.fabricmc.loom.LoomGradleExtension;
|
||||||
import net.fabricmc.loom.util.IdeaRunConfig;
|
import net.fabricmc.loom.util.RunConfig;
|
||||||
import org.gradle.api.DefaultTask;
|
import org.gradle.api.DefaultTask;
|
||||||
import org.gradle.api.Project;
|
import org.gradle.api.Project;
|
||||||
import org.gradle.api.tasks.TaskAction;
|
import org.gradle.api.tasks.TaskAction;
|
||||||
|
@ -73,8 +73,8 @@ public class GenIdeaProjectTask extends DefaultTask {
|
||||||
throw new RuntimeException("Failed to generate intellij run configurations (runManager was not found)");
|
throw new RuntimeException("Failed to generate intellij run configurations (runManager was not found)");
|
||||||
}
|
}
|
||||||
|
|
||||||
runManager.appendChild(IdeaRunConfig.clientRunConfig(project).genRuns(runManager));
|
runManager.appendChild(RunConfig.clientRunConfig(project).genRuns(runManager));
|
||||||
runManager.appendChild(IdeaRunConfig.serverRunConfig(project).genRuns(runManager));
|
runManager.appendChild(RunConfig.serverRunConfig(project).genRuns(runManager));
|
||||||
|
|
||||||
TransformerFactory transformerFactory = TransformerFactory.newInstance();
|
TransformerFactory transformerFactory = TransformerFactory.newInstance();
|
||||||
Transformer transformer = transformerFactory.newTransformer();
|
Transformer transformer = transformerFactory.newTransformer();
|
||||||
|
|
|
@ -27,7 +27,7 @@ package net.fabricmc.loom.task;
|
||||||
import com.google.gson.Gson;
|
import com.google.gson.Gson;
|
||||||
import com.google.gson.GsonBuilder;
|
import com.google.gson.GsonBuilder;
|
||||||
import net.fabricmc.loom.LoomGradleExtension;
|
import net.fabricmc.loom.LoomGradleExtension;
|
||||||
import net.fabricmc.loom.util.IdeaRunConfig;
|
import net.fabricmc.loom.util.RunConfig;
|
||||||
import org.apache.commons.io.FileUtils;
|
import org.apache.commons.io.FileUtils;
|
||||||
import org.gradle.api.DefaultTask;
|
import org.gradle.api.DefaultTask;
|
||||||
import org.gradle.api.tasks.TaskAction;
|
import org.gradle.api.tasks.TaskAction;
|
||||||
|
@ -57,8 +57,8 @@ public class GenVsCodeProjectTask extends DefaultTask {
|
||||||
}
|
}
|
||||||
|
|
||||||
VsCodeLaunch launch = new VsCodeLaunch();
|
VsCodeLaunch launch = new VsCodeLaunch();
|
||||||
launch.add(IdeaRunConfig.clientRunConfig(getProject()));
|
launch.add(RunConfig.clientRunConfig(getProject()));
|
||||||
launch.add(IdeaRunConfig.serverRunConfig(getProject()));
|
launch.add(RunConfig.serverRunConfig(getProject()));
|
||||||
|
|
||||||
Gson gson = new GsonBuilder().setPrettyPrinting().create();
|
Gson gson = new GsonBuilder().setPrettyPrinting().create();
|
||||||
String json = gson.toJson(launch);
|
String json = gson.toJson(launch);
|
||||||
|
@ -79,7 +79,7 @@ public class GenVsCodeProjectTask extends DefaultTask {
|
||||||
public String version = "0.2.0";
|
public String version = "0.2.0";
|
||||||
public List<VsCodeConfiguration> configurations = new ArrayList<>();
|
public List<VsCodeConfiguration> configurations = new ArrayList<>();
|
||||||
|
|
||||||
public void add(IdeaRunConfig runConfig) {
|
public void add(RunConfig runConfig) {
|
||||||
configurations.add(new VsCodeConfiguration(runConfig));
|
configurations.add(new VsCodeConfiguration(runConfig));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -95,7 +95,7 @@ public class GenVsCodeProjectTask extends DefaultTask {
|
||||||
public String vmArgs;
|
public String vmArgs;
|
||||||
public String args;
|
public String args;
|
||||||
|
|
||||||
public VsCodeConfiguration(IdeaRunConfig runConfig) {
|
public VsCodeConfiguration(RunConfig runConfig) {
|
||||||
this.name = runConfig.configName;
|
this.name = runConfig.configName;
|
||||||
this.mainClass = runConfig.mainClass;
|
this.mainClass = runConfig.mainClass;
|
||||||
this.vmArgs = runConfig.vmArgs;
|
this.vmArgs = runConfig.vmArgs;
|
||||||
|
|
|
@ -42,7 +42,7 @@ import java.io.InputStream;
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
public class IdeaRunConfig {
|
public class RunConfig {
|
||||||
public String configName;
|
public String configName;
|
||||||
public String projectName;
|
public String projectName;
|
||||||
public String mainClass;
|
public String mainClass;
|
||||||
|
@ -82,12 +82,12 @@ public class IdeaRunConfig {
|
||||||
return e;
|
return e;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static IdeaRunConfig clientRunConfig(Project project){
|
public static RunConfig clientRunConfig(Project project){
|
||||||
LoomGradleExtension extension = project.getExtensions().getByType(LoomGradleExtension.class);
|
LoomGradleExtension extension = project.getExtensions().getByType(LoomGradleExtension.class);
|
||||||
MinecraftProvider minecraftProvider = extension.getMinecraftProvider();
|
MinecraftProvider minecraftProvider = extension.getMinecraftProvider();
|
||||||
MinecraftVersionInfo minecraftVersionInfo = minecraftProvider.versionInfo;
|
MinecraftVersionInfo minecraftVersionInfo = minecraftProvider.versionInfo;
|
||||||
|
|
||||||
IdeaRunConfig ideaClient = new IdeaRunConfig();
|
RunConfig ideaClient = new RunConfig();
|
||||||
ideaClient.mainClass = "net.minecraft.launchwrapper.Launch";
|
ideaClient.mainClass = "net.minecraft.launchwrapper.Launch";
|
||||||
ideaClient.projectName = project.getName();
|
ideaClient.projectName = project.getName();
|
||||||
ideaClient.configName = "Minecraft Client";
|
ideaClient.configName = "Minecraft Client";
|
||||||
|
@ -98,10 +98,10 @@ public class IdeaRunConfig {
|
||||||
return ideaClient;
|
return ideaClient;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static IdeaRunConfig serverRunConfig(Project project){
|
public static RunConfig serverRunConfig(Project project){
|
||||||
LoomGradleExtension extension = project.getExtensions().getByType(LoomGradleExtension.class);
|
LoomGradleExtension extension = project.getExtensions().getByType(LoomGradleExtension.class);
|
||||||
|
|
||||||
IdeaRunConfig ideaServer = new IdeaRunConfig();
|
RunConfig ideaServer = new RunConfig();
|
||||||
ideaServer.mainClass = "net.minecraft.launchwrapper.Launch";
|
ideaServer.mainClass = "net.minecraft.launchwrapper.Launch";
|
||||||
ideaServer.projectName = project.getName();
|
ideaServer.projectName = project.getName();
|
||||||
ideaServer.configName = "Minecraft Server";
|
ideaServer.configName = "Minecraft Server";
|
||||||
|
@ -112,8 +112,8 @@ public class IdeaRunConfig {
|
||||||
return ideaServer;
|
return ideaServer;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String fromDummy() throws IOException {
|
public String fromDummy(String dummy) throws IOException {
|
||||||
InputStream input = SetupIntelijRunConfigs.class.getClassLoader().getResourceAsStream("idea_run_config_template.xml");
|
InputStream input = SetupIntelijRunConfigs.class.getClassLoader().getResourceAsStream(dummy);
|
||||||
String dummyConfig = IOUtils.toString(input, StandardCharsets.UTF_8);
|
String dummyConfig = IOUtils.toString(input, StandardCharsets.UTF_8);
|
||||||
input.close();
|
input.close();
|
||||||
|
|
|
@ -63,8 +63,8 @@ public class SetupIntelijRunConfigs {
|
||||||
runConfigsDir.mkdirs();
|
runConfigsDir.mkdirs();
|
||||||
}
|
}
|
||||||
|
|
||||||
String clientRunConfig = IdeaRunConfig.clientRunConfig(project).fromDummy();
|
String clientRunConfig = RunConfig.clientRunConfig(project).fromDummy("idea_run_config_template.xml");
|
||||||
String serverRunConfig = IdeaRunConfig.serverRunConfig(project).fromDummy();
|
String serverRunConfig = RunConfig.serverRunConfig(project).fromDummy("idea_run_config_template.xml");
|
||||||
|
|
||||||
if(!clientRunConfigs.exists())
|
if(!clientRunConfigs.exists())
|
||||||
FileUtils.writeStringToFile(clientRunConfigs, clientRunConfig, StandardCharsets.UTF_8);
|
FileUtils.writeStringToFile(clientRunConfigs, clientRunConfig, StandardCharsets.UTF_8);
|
||||||
|
|
|
@ -0,0 +1,15 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||||
|
<launchConfiguration type="org.eclipse.jdt.launching.localJavaApplication">
|
||||||
|
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS">
|
||||||
|
<listEntry value="/%NAME%"/>
|
||||||
|
</listAttribute>
|
||||||
|
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
|
||||||
|
<listEntry value="4"/>
|
||||||
|
</listAttribute>
|
||||||
|
<booleanAttribute key="org.eclipse.jdt.launching.ATTR_USE_START_ON_FIRST_THREAD" value="true"/>
|
||||||
|
<stringAttribute key="org.eclipse.jdt.launching.CLASSPATH_PROVIDER" value="org.eclipse.buildship.core.classpathprovider"/>
|
||||||
|
<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="%MAIN_CLASS%"/>
|
||||||
|
<stringAttribute key="org.eclipse.jdt.launching.PROGRAM_ARGUMENTS" value="%PROGRAM_ARGS%"/>
|
||||||
|
<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="%MODULE%"/>
|
||||||
|
<stringAttribute key="org.eclipse.jdt.launching.VM_ARGUMENTS" value="%VM_ARGS%"/>
|
||||||
|
</launchConfiguration>
|
Loading…
Reference in New Issue