Eclipse project fixes (#192)
* If the Eclipse project name is overridden by the build script, use the actual name. * Clean up Eclipse launch files after cleanEclipse task.dev/0.11
parent
93820f0d65
commit
6c02535304
|
@ -275,6 +275,7 @@ public class AbstractPlugin implements Plugin<Project> {
|
||||||
|
|
||||||
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"));
|
project1.getTasks().getByName("eclipse").finalizedBy(project1.getTasks().getByName("genEclipseRuns"));
|
||||||
|
project1.getTasks().getByName("cleanEclipse").finalizedBy(project1.getTasks().getByName("cleanEclipseRuns"));
|
||||||
|
|
||||||
if (extension.autoGenIDERuns && isRootProject(project1)) {
|
if (extension.autoGenIDERuns && isRootProject(project1)) {
|
||||||
SetupIntelijRunConfigs.setup(project1);
|
SetupIntelijRunConfigs.setup(project1);
|
||||||
|
|
|
@ -37,6 +37,7 @@ import org.gradle.api.tasks.TaskContainer;
|
||||||
import net.fabricmc.loom.providers.MappingsProvider;
|
import net.fabricmc.loom.providers.MappingsProvider;
|
||||||
import net.fabricmc.loom.providers.MinecraftLibraryProvider;
|
import net.fabricmc.loom.providers.MinecraftLibraryProvider;
|
||||||
import net.fabricmc.loom.task.AbstractDecompileTask;
|
import net.fabricmc.loom.task.AbstractDecompileTask;
|
||||||
|
import net.fabricmc.loom.task.CleanEclipseRunsTask;
|
||||||
import net.fabricmc.loom.task.CleanLoomBinaries;
|
import net.fabricmc.loom.task.CleanLoomBinaries;
|
||||||
import net.fabricmc.loom.task.CleanLoomMappings;
|
import net.fabricmc.loom.task.CleanLoomMappings;
|
||||||
import net.fabricmc.loom.task.DownloadAssetsTask;
|
import net.fabricmc.loom.task.DownloadAssetsTask;
|
||||||
|
@ -151,6 +152,10 @@ public class LoomGradlePlugin extends AbstractPlugin {
|
||||||
t.setGroup("ide");
|
t.setGroup("ide");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
tasks.register("cleanEclipseRuns", CleanEclipseRunsTask.class, t -> {
|
||||||
|
t.setGroup("ide");
|
||||||
|
});
|
||||||
|
|
||||||
tasks.register("vscode", GenVsCodeProjectTask.class, t -> {
|
tasks.register("vscode", GenVsCodeProjectTask.class, t -> {
|
||||||
t.dependsOn("downloadAssets");
|
t.dependsOn("downloadAssets");
|
||||||
t.setGroup("ide");
|
t.setGroup("ide");
|
||||||
|
|
|
@ -0,0 +1,48 @@
|
||||||
|
/*
|
||||||
|
* 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 java.io.File;
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
|
import org.gradle.api.tasks.TaskAction;
|
||||||
|
import org.gradle.plugins.ide.eclipse.model.EclipseModel;
|
||||||
|
|
||||||
|
public class CleanEclipseRunsTask extends AbstractLoomTask {
|
||||||
|
@TaskAction
|
||||||
|
public void cleanRuns() throws IOException {
|
||||||
|
EclipseModel eclipseModel = getProject().getExtensions().getByType(EclipseModel.class);
|
||||||
|
File clientRunConfigs = new File(getProject().getRootDir(), eclipseModel.getProject().getName() + "_client.launch");
|
||||||
|
File serverRunConfigs = new File(getProject().getRootDir(), eclipseModel.getProject().getName() + "_server.launch");
|
||||||
|
|
||||||
|
if (clientRunConfigs.exists()) {
|
||||||
|
clientRunConfigs.delete();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (serverRunConfigs.exists()) {
|
||||||
|
serverRunConfigs.delete();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -30,14 +30,16 @@ import java.nio.charset.StandardCharsets;
|
||||||
|
|
||||||
import org.apache.commons.io.FileUtils;
|
import org.apache.commons.io.FileUtils;
|
||||||
import org.gradle.api.tasks.TaskAction;
|
import org.gradle.api.tasks.TaskAction;
|
||||||
|
import org.gradle.plugins.ide.eclipse.model.EclipseModel;
|
||||||
|
|
||||||
import net.fabricmc.loom.util.RunConfig;
|
import net.fabricmc.loom.util.RunConfig;
|
||||||
|
|
||||||
public class GenEclipseRunsTask extends AbstractLoomTask {
|
public class GenEclipseRunsTask extends AbstractLoomTask {
|
||||||
@TaskAction
|
@TaskAction
|
||||||
public void genRuns() throws IOException {
|
public void genRuns() throws IOException {
|
||||||
File clientRunConfigs = new File(getProject().getRootDir(), getProject().getName() + "_client.launch");
|
EclipseModel eclipseModel = getProject().getExtensions().getByType(EclipseModel.class);
|
||||||
File serverRunConfigs = new File(getProject().getRootDir(), getProject().getName() + "_server.launch");
|
File clientRunConfigs = new File(getProject().getRootDir(), eclipseModel.getProject().getName() + "_client.launch");
|
||||||
|
File serverRunConfigs = new File(getProject().getRootDir(), eclipseModel.getProject().getName() + "_server.launch");
|
||||||
|
|
||||||
String clientRunConfig = RunConfig.clientRunConfig(getProject()).fromDummy("eclipse_run_config_template.xml");
|
String clientRunConfig = RunConfig.clientRunConfig(getProject()).fromDummy("eclipse_run_config_template.xml");
|
||||||
String serverRunConfig = RunConfig.serverRunConfig(getProject()).fromDummy("eclipse_run_config_template.xml");
|
String serverRunConfig = RunConfig.serverRunConfig(getProject()).fromDummy("eclipse_run_config_template.xml");
|
||||||
|
|
|
@ -46,6 +46,7 @@ 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;
|
||||||
import org.gradle.api.Project;
|
import org.gradle.api.Project;
|
||||||
|
import org.gradle.plugins.ide.eclipse.model.EclipseModel;
|
||||||
|
|
||||||
import net.fabricmc.loom.LoomGradleExtension;
|
import net.fabricmc.loom.LoomGradleExtension;
|
||||||
import net.fabricmc.loom.providers.MinecraftProvider;
|
import net.fabricmc.loom.providers.MinecraftProvider;
|
||||||
|
@ -95,7 +96,7 @@ public class RunConfig {
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void populate(Project project, LoomGradleExtension extension, RunConfig runConfig, String mode) {
|
private static void populate(Project project, LoomGradleExtension extension, RunConfig runConfig, String mode) {
|
||||||
runConfig.projectName = project.getName();
|
runConfig.projectName = project.getExtensions().getByType(EclipseModel.class).getProject().getName();
|
||||||
runConfig.runDir = "file://$PROJECT_DIR$/" + extension.runDir;
|
runConfig.runDir = "file://$PROJECT_DIR$/" + extension.runDir;
|
||||||
runConfig.vmArgs = "";
|
runConfig.vmArgs = "";
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue