Skip to content

Commit

Permalink
Cleanly record the compile/processResources dependency for run tasks
Browse files Browse the repository at this point in the history
  • Loading branch information
Technici4n committed May 25, 2024
1 parent 8e01bd9 commit bc3f73f
Showing 1 changed file with 5 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,8 @@ public void apply(Project project) {
extension.getRuns().configureEach(run -> {
var type = RunUtils.getRequiredType(project, run);

var sourceSet = ExtensionUtils.getExtension(project, "sourceSets", SourceSetContainer.class).getByName("main");

var legacyClasspathConfiguration = configurations.create(run.nameOf("", "legacyClasspath"), spec -> {
spec.setCanBeResolved(true);
spec.setCanBeConsumed(false);
Expand Down Expand Up @@ -341,7 +343,9 @@ public void apply(Project project) {
idePostSyncTask.configure(task -> task.dependsOn(prepareRunTask));

tasks.register(run.nameOf("run", ""), RunGameTask.class, task -> {
task.getClasspathProvider().from(configurations.named("runtimeClasspath"));
// Note: this contains both the runtimeClasspath configuration and the sourceset's outputs.
// This records a dependency on compiling and processing the resources of the source set.
task.getClasspathProvider().from(sourceSet.getRuntimeClasspath());
task.getGameDirectory().set(run.getGameDirectory());

task.jvmArgs(RunUtils.getArgFileParameter(prepareRunTask.get().getVmArgsFile().get()).replace("\\", "\\\\"));
Expand All @@ -351,9 +355,6 @@ public void apply(Project project) {
task.dependsOn(prepareRunTask);

task.getJvmArgumentProviders().add(RunUtils.getGradleModFoldersProvider(project, run));

// TODO: how do we do this in a clean way for all source sets?
task.dependsOn(tasks.named("processResources"));
});
});

Expand Down

0 comments on commit bc3f73f

Please sign in to comment.