fix dev run, only run datagen if files changed

This commit is contained in:
deirn 2021-12-16 13:14:01 +07:00
parent 0ce0df5482
commit 98e3f44ed1
3 changed files with 23 additions and 4 deletions

2
.gitignore vendored
View file

@ -21,4 +21,4 @@ bin/
run/ run/
logs/ logs/
src/generated/ src/generated/output/

View file

@ -51,12 +51,16 @@ sourceSets {
} }
val generated by creating { val generated by creating {
compiledBy("runDatagen")
resources { resources {
compiledBy("runDatagen") srcDir(file("src/generated/output"))
} }
} }
main.runtimeClasspath += generated.output devrun.apply {
compileClasspath += generated.output
runtimeClasspath += generated.output
}
} }
loom { loom {
@ -74,7 +78,7 @@ loom {
name("Data Generation") name("Data Generation")
vmArgs( vmArgs(
"-Dfabric-api.datagen", "-Dfabric-api.datagen",
"-Dfabric-api.datagen.output-dir=${file("src/generated/resources")}", "-Dfabric-api.datagen.output-dir=${file("src/generated/output")}",
"-Dfabric-api.datagen.modid=slotlink_datagen" "-Dfabric-api.datagen.modid=slotlink_datagen"
) )
runDir("${project.buildDir}/datagen") runDir("${project.buildDir}/datagen")
@ -88,6 +92,11 @@ java {
targetCompatibility = JavaVersion.VERSION_17 targetCompatibility = JavaVersion.VERSION_17
} }
tasks.getByName("runDatagen") {
inputs.dir(file("src/datagen"))
outputs.dir(file("src/generated"))
}
tasks.withType<JavaCompile> { tasks.withType<JavaCompile> {
options.encoding = "UTF-8" options.encoding = "UTF-8"
} }
@ -100,10 +109,15 @@ tasks.withType<KotlinCompile> {
tasks.jar { tasks.jar {
from(sourceSets["generated"].output) { from(sourceSets["generated"].output) {
exclude("fabric.mod.json")
exclude(".cache/**") exclude(".cache/**")
} }
} }
tasks.getByName("processGeneratedResources") {
dependsOn("runDatagen")
}
tasks.withType<ProcessResources> { tasks.withType<ProcessResources> {
inputs.property("version", project.version) inputs.property("version", project.version)

View file

@ -0,0 +1,5 @@
{
"schemaVersion": 1,
"id" : "slotlink_generated_data",
"version" : "1"
}