Skip to content

Commit

Permalink
chore: Improve README metadata generation example
Browse files Browse the repository at this point in the history
  • Loading branch information
phinner committed Jun 20, 2024
1 parent 7585000 commit 9696282
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,14 +101,19 @@ The following examples assume you are using a kotlin build script.
mainClass = "org.example.mod.ModMain"
)

tasks.jar {
// Doing it in doFirst makes sure it's only executed when this task runs
doFirst {
val temp = temporaryDir.resolve("mod.json")
temp.writeText(Metadata.toJson(metadata, true))
from(temp)
val generateMetadataFile by tasks.registering {
// Regenerates the file if the metadata changes
inputs.property("metadata", metadata)
val output = temporaryDir.resolve("mod.json")
outputs.file(output)
doLast {
output.writeText(ModMetadata.toJson(metadata))
}
}

tasks.jar {
from(generateMetadataFile)
}
```

And voilà, you have a minimal toxopid setup for your mod/plugin.
Expand Down

0 comments on commit 9696282

Please sign in to comment.