Skip to content

Commit

Permalink
Have userdev gradle attach the clean path to run configs automatically
Browse files Browse the repository at this point in the history
  • Loading branch information
Su5eD committed Jul 30, 2024
1 parent df49049 commit c3233f4
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 4 deletions.
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import java.time.LocalDateTime
import java.time.format.DateTimeFormatter

plugins {
id("net.neoforged.moddev") version "0.1.126"
id("net.neoforged.moddev") version "1.0.15"
id("org.sinytra.adapter.userdev")
id("org.sinytra.adapter.gradle")
`maven-publish`
Expand Down
4 changes: 2 additions & 2 deletions userdev/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ plugins {
}

group = "org.sinytra.adapter"
version = "1.0-SNAPSHOT"
version = "1.1-SNAPSHOT"

java {
toolchain {
Expand All @@ -27,7 +27,7 @@ repositories {
}

dependencies {
compileOnly("net.neoforged:moddev-gradle:0.1.124")
compileOnly("net.neoforged:moddev-gradle:1.0.15")
}

publishing {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.sinytra.adapter.userdev;

import net.neoforged.moddevgradle.dsl.InternalModelHelper;
import net.neoforged.moddevgradle.dsl.NeoForgeExtension;
import org.gradle.api.Plugin;
import org.gradle.api.Project;
Expand All @@ -17,7 +18,8 @@ public void apply(Project project) {
}

public static void applyPlugin(Project project) {
Property<String> neoForgeVersion = project.getExtensions().getByType(NeoForgeExtension.class).getVersion();
NeoForgeExtension neoForge = project.getExtensions().getByType(NeoForgeExtension.class);
Property<String> neoForgeVersion = neoForge.getVersion();

Configuration neoForgeUserdevArtifact = project.getConfigurations().create("neoForgeUserdevArtifact", spec -> {
spec.setCanBeResolved(true);
Expand Down Expand Up @@ -46,6 +48,7 @@ public static void applyPlugin(Project project) {
task.getOutputFile().set(project.file("build/%s/joined.lzma".formatted(task.getName())));
});

// Used by org.sinytra.adapter.gradle plugin
TaskProvider<CreateBinpatchedArtifactTask> createBinpatchedArtifact = project.getTasks().register("createBinpatchedArtifact", CreateBinpatchedArtifactTask.class, task -> {
task.dependsOn("extractBinPatches");
task.setGroup("sinytra");
Expand All @@ -54,5 +57,13 @@ public static void applyPlugin(Project project) {
task.getPatches().set(extractBinPatches.flatMap(ExtractBinPatches::getOutputFile));
task.getOutputFile().set(project.file("build/%s/minecraft-binpatched.jar".formatted(task.getName())));
});

// Attach clean artifact path to run configs
neoForge.getRuns().configureEach(runModel -> {
runModel.systemProperty("connector.clean.path", createCleanArtifact.get().getOutputFile().get().getAsFile().getAbsolutePath());
project.getTasks().named(InternalModelHelper.nameOfRun(runModel, "prepare", "run")).configure(task -> {
task.dependsOn(createCleanArtifact);
});
});
}
}

0 comments on commit c3233f4

Please sign in to comment.