Add mod setup tools and project initialization support.

This commit is contained in:
Overlord committed 2026-10-10 19:16:56 +02:00
1 parent a5766f3a1b
commit 32fab0c1d4
9 files changed
+684 -55

No files matched your search

+60 -45
View File
@@ -5,54 +5,68 @@ described in the [README](README.md#mods).
## Project setup
A mod is a normal Gradle project with the ZomboidForge plugin. It needs JDK 25 (Project
Zomboid's runtime); the plugin sets the Java toolchain to 25.
A mod project starts as one file. It needs JDK 25 (Project Zomboid's runtime); the plugin sets
the Java toolchain to 25.
`settings.gradle.kts`:
1. Create a directory with this `settings.gradle.kts`, with your mod's id, version, and entry
point:
```kotlin
pluginManagement {
repositories {
maven("https://git.security-command.org/api/packages/overlord/maven")
gradlePluginPortal()
}
}
```kotlin
pluginManagement {
repositories { maven("https://git.security-command.org/api/packages/overlord/maven") }
}
dependencyResolutionManagement {
repositories {
maven("https://git.security-command.org/api/packages/overlord/maven")
mavenCentral() // the API depends on org.jetbrains:annotations
}
}
plugins {
id("dev.overlord.zomboidforge") version "0.6.0" // the plugin's version is the API version
}
rootProject.name = "shop"
zomboidForge {
id = "shop"
version = "1.0.0"
entrypoint = "com.example.shop.ShopMod"
}
```
2. Run in that directory (Linux, macOS, Windows; on Windows PowerShell 5.1 write `curl.exe`):
```
curl -fsSL https://git.security-command.org/Overlord/ZomboidForge/raw/branch/master/zomboidforge.jsh | jshell -
```
The command sets the newest ZomboidForge version in `settings.gradle.kts`, writes the Gradle
wrapper (`gradlew`, `gradlew.bat`, `gradle/wrapper/`), creates `.gitignore` and the entry point
class when they are missing, and builds the mod. It needs no installed Gradle.
The same command updates a project to the newest version; a given version goes in
`-R-Dzomboidforge.version`:
```
curl -fsSL https://git.security-command.org/Overlord/ZomboidForge/raw/branch/master/zomboidforge.jsh | jshell -R-Dzomboidforge.version=0.7.0 -
```
`build.gradle.kts`:
It prints links to this document in the new version and to the changes since the old one, and
ends with a build, so code that the new version breaks shows at once. Files other than the
version line in `settings.gradle.kts` and the wrapper stay as they are.
The root project is named after the mod id. The plugin adds the API
(`dev.overlord.zomboidforge:api`) as a compile-only dependency, and the game jar for mods that
declare `game` versions. Default settings go into
`src/main/resources/META-INF/zomboidforge/config.toml`.
Libraries and other mods go into an optional `build.gradle.kts`, which can also set any
`zomboidForge { }` setting:
```kotlin
plugins {
id("dev.overlord.zomboidforge.mod") version "0.6.0" // the plugin's version is the API version
}
version = "1.2.0"
zomboidForge {
id = "shop"
entrypoint = "com.example.shop.ShopMod"
game("42") // only when the mod uses game classes
dependsOn("economy", "2.1") // other mods: id and minimum version
}
dependencies {
implementation("com.google.code.gson:gson:2.11.0") // libraries go into the mod's lib/
forgeMods("com.example:economy:2.1") // other mods to compile against
}
```
The plugin adds the API (`dev.overlord.zomboidforge:api`) as a compile-only dependency, and the
game jar for mods that declare `game` versions. Default settings go into
`src/main/resources/META-INF/zomboidforge/config.toml`.
zomboidForge {
game("42") // only when the mod uses game classes
dependsOn("economy", "2.1") // other mods: id and minimum version
}
```
### `zomboidForge { }`
@@ -61,7 +75,7 @@ game jar for mods that declare `game` versions. Default settings go into
| `id` | (required) | lowercase letters, digits, single underscores; at most 32 characters |
| `entrypoint` | (required) | the class that extends `Mod` |
| `name` | the id | display name |
| `version` | the project version | the mod's version |
| `version` | (required) | the mod's version, such as `1.2.0` |
| `api` | the plugin's version | ZomboidForge API version the mod is built against |
| `game(...)` | none | supported Project Zomboid versions: `"42"`, `"42.21"`, `"42.21.0"` |
| `dependsOn(id, version)` | none | another mod this one needs, with its minimum version |
@@ -98,15 +112,16 @@ The game jar has to be one of the declared `game` versions; the check below fail
### Tasks
| Task | Does |
|----------------|---------------------------------------------------------------------------------------------|
| `build` | compiles, runs `checkMod`, and assembles the mod |
| `checkMod` | the server's load checks, at build time (see [Checks at startup](#checks-at-startup)) |
| `modFolder` | `build/mod/<id>/` with `<id>.jar` and `lib/`, as a server expects it in `<forge>/mods` |
| `modZip` | the same as `build/distributions/<id>-<version>.zip` |
| `runServer` | a ZomboidForge server in a container with the mod; Ctrl+C stops it after it saved the world |
| `deployMod` | copies the mod folder into `deployDirectory`; keeps the server's `config.toml` of the mod |
| `downloadGame` | installs the dedicated server for its game jar; runs only when needed |
| Task | Does |
|---------------------|---------------------------------------------------------------------------------------------|
| `build` | compiles, runs `checkMod`, and assembles the mod |
| `checkMod` | the server's load checks, at build time (see [checks at startup](#checks-at-startup)) |
| `modFolder` | `build/mod/<id>/` with `<id>.jar` and `lib/`, as a server expects it in `<forge>/mods` |
| `modZip` | the same as `build/distributions/<id>-<version>.zip` |
| `runServer` | a ZomboidForge server in a container with the mod; Ctrl+C stops it after it saved the world |
| `deployMod` | copies the mod folder into `deployDirectory`; keeps the server's `config.toml` of the mod |
| `downloadGame` | installs the dedicated server for its game jar; runs only when needed |
| `zomboidForgeSetup` | creates `.gitignore` and the entry point class when they are missing |
`runServer` is reachable from this machine only, unless `serverAddress` says otherwise. Without
`adminPassword`, the first run generates a random admin password for the volume, prints it, and