Skip to content

Commit

Permalink
genEclipseRuns now executes when the eclipse task is run
Browse files Browse the repository at this point in the history
  • Loading branch information
Gamebuster19901 committed Oct 30, 2024
1 parent 47c4fbb commit d9ea290
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import com.wildermods.workspace.tasks.ClearLocalRuntimeTask;
import com.wildermods.workspace.tasks.CopyLocalDependenciesToWorkspaceTask;
import com.wildermods.workspace.tasks.DecompileJarsTask;
import com.wildermods.workspace.tasks.eclipse.GenerateRunConfigurationTask;
import com.wildermods.workspace.util.ExceptionUtil;

import java.io.File;
Expand Down Expand Up @@ -398,6 +399,10 @@ private void setupTasks(WWProjectContext context) {
task.into(Path.of(extension.getGameDestDir()).resolve("modDeps"));
});

project.getTasks().register("genEclipseRuns", GenerateRunConfigurationTask.class, task -> {

});

}

/**
Expand Down Expand Up @@ -450,7 +455,7 @@ private void setupEclipsePlugin(WWProjectContext context) {
if (project.getPlugins().hasPlugin("eclipse")) {
EclipseModel eclipseModel = proj.getExtensions().getByType(EclipseModel.class);
EclipseClasspath classpath = eclipseModel.getClasspath();

classpath.file(xmlFileContent -> {
xmlFileContent.getWhenMerged().add((classPathMerged) -> {
Classpath c = (Classpath) classPathMerged;
Expand All @@ -470,8 +475,10 @@ private void setupEclipsePlugin(WWProjectContext context) {
});
});

project.getTasks().getByName("eclipse").finalizedBy(project.getTasks().getByName("genEclipseRuns"));

} else {
project.getLogger().warn("Eclipse plugin is not applied. The eclipse source attachment will not be configured.");
project.getLogger().warn("Eclipse plugin is not applied. The eclipse source attachment will not be configured, and the eclipse run configurations will not be generated.");
}
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import java.nio.file.Path;

import org.gradle.api.DefaultTask;
import org.gradle.api.tasks.Input;
import org.gradle.api.tasks.OutputFile;
import org.gradle.api.tasks.TaskAction;

Expand Down Expand Up @@ -34,13 +35,19 @@ public class GenerateRunConfigurationTask extends DefaultTask {
</launchConfiguration>
""";

public @Input boolean overwrite = false;

public boolean getOverwrite() {
return overwrite;
}

@OutputFile
public Path getLaunchFile() {
return getProject().getProjectDir().toPath().resolve(".eclipse/configurations/runClient.launch");
}

@TaskAction
private void generateLaunchConfig(boolean overwrite) {
private void generateLaunchConfig() {
Path launchFile = getLaunchFile();

String projectName = getProject().getName();
Expand Down

0 comments on commit d9ea290

Please sign in to comment.