Configuration
Koremods Gradle
Compiler Worker Daemon
The embedded Kotlin Script Compiler can take a long time to load into the JVM due to its large size, slowing down initial script compilation significantly. Subsequent scripts are then compiled up to 10-15 times faster. This can quickly become an issue when compiling multiple script sourceSets or during development, when you’ll want to reload and apply your transformer changes as quickly as possible.
As a solution, Koremods Gradle creates a separate process for compiling scripts which persists across builds. While the daemon takes an extra second to start up, keeping the compiler loaded speeds up script compilation times significantly.
The Worker Daemon is managed by Gradle, and will be terminated whenever memory gets low. Please make sure you allocate Gradle enough heap to keep it alive.
Daemon memory
By default, the daemon’s max heap is set to 512M
, which is enough for most users.
However, compiling more scripts (>10) might require bumping the limit.
- Groovy DSL
- Kotlin DSL
koremods {
workerDaemonOptions {
it.maxHeapSize = '1G' // Increase worker daemon heap size as needed
}
}
koremods {
workerDaemonOptions {
maxHeapSize = "1G" // Increase worker daemon heap size as needed
}
}
Optimizing CI Environments
If you're only compiling one source set in a CI environment, it's more efficient to disable the worker daemon
altogether and save a bit of time it would take to start up.
One way to approach this would be setting the useWorkerDaemon
based on an environment variable of your choice.
- Groovy DSL
- Kotlin DSL
koremods {
useWorkerDaemon = false // Disable worker daemon
}
koremods {
useWorkerDaemon.set(false) // Disable worker daemon
}
Koremods Script
Creating a Script Pack
Script packs are defined in a resource file located at META-INF/koremods.conf
which uses the
HOCON format,
a superset of JSON.
Namespace ID
The namespace ID is used to uniquely identify the script pack. It should be a unique, lower snake_case string.
If your script pack is embedded inside a FML mod, its namespace must match the modid of that mod.
namespace = "examplepack"
Scripts
An array of paths to your script sources, relative to the resources root directory. Script file names must only
contain alphanumeric characters and their extension must be core.kts
.
scripts = [
"scripts/transformExample.core.kts"
]