From 8789c97cb0200805d66cff5b68b5d1e6697df9a2 Mon Sep 17 00:00:00 2001 From: Liplum Date: Mon, 18 Dec 2023 20:10:03 +0800 Subject: [PATCH] renamed property in `ModHjsonGenerate` task --- main/src/plugin/Main.kt | 2 +- main/src/task/ModHjsonGenerate.kt | 13 ++++++++----- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/main/src/plugin/Main.kt b/main/src/plugin/Main.kt index 435608b..02d54dc 100644 --- a/main/src/plugin/Main.kt +++ b/main/src/plugin/Main.kt @@ -39,7 +39,7 @@ class MindustryPlugin : Plugin { tasks.register(R.task.genModHjson) { group = R.taskGroup.mindustry modMeta.set(ex._modMeta) - outputHjson.set(temporaryDir.resolve("mod.hjson")) + output.set(temporaryDir.resolve("mod.hjson")) } if (plugins.hasPlugin()) { plugins.apply() diff --git a/main/src/task/ModHjsonGenerate.kt b/main/src/task/ModHjsonGenerate.kt index 62d9ab6..1375db7 100644 --- a/main/src/task/ModHjsonGenerate.kt +++ b/main/src/task/ModHjsonGenerate.kt @@ -1,5 +1,6 @@ package io.github.liplum.mindustry +import io.github.liplum.dsl.ensureParentDir import io.github.liplum.dsl.fileProp import io.github.liplum.dsl.prop import io.github.liplum.mindustry.ModMeta.Companion.toHjson @@ -11,13 +12,15 @@ import org.gradle.api.tasks.TaskAction open class ModHjsonGenerate : DefaultTask() { val modMeta = project.prop() @Input get - val outputHjson = project.fileProp() + val output = project.fileProp() @OutputFile get + @TaskAction fun generate() { - val modHjson = outputHjson.get() - modHjson.parentFile.mkdirs() - modHjson.writeText(modMeta.get().toHjson()) - logger.info("ModHjson is generated at ${modHjson.absolutePath} .") + val output = output.get() + output.ensureParentDir() + val modMetaText = modMeta.get().toHjson() + output.writeText(modMetaText) + logger.info("mod.hjson was generated at ${output.absolutePath} .") } } \ No newline at end of file