Introduce gradle-plugin and mod-tools modules. Add ZomboidForge Gradle plugin for building, checking, and packaging mods. Include support for local test servers, automated game jar downloads, and mod descriptor generation. Add mod-tools for runtime mod checks and validations.

This commit is contained in:
Overlord committed 2026-10-02 15:36:10 +02:00
1 parent 68cd9fc4f9
commit 063ad8a3e1
27 files changed
+1976 -30

No files matched your search

Executable
+96
View File
@@ -0,0 +1,96 @@
#!/usr/bin/env bash
#
# Publishes the mod API (dev.overlord.zomboidforge:api), the mod tools (mod-tools), and the
# Gradle plugin (dev.overlord.zomboidforge.mod) to the Maven registry of the ZomboidForge Gitea,
# in the version of the newest v* git tag reachable from HEAD, without the "v".
#
# A pre-release version (containing "-", e.g. 0.3.0-rc.1) is built and tested but never
# published. Without any v* tag nothing is published.
#
# Environment:
# ORG_GRADLE_PROJECT_giteaUsername Gitea user with package write access
# ORG_GRADLE_PROJECT_giteaPassword Token of that user
# PUBLISH true: publish after the tests. Default: false (test only)
set -o errexit
set -o nounset
set -o pipefail
REPO_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
readonly REPO_ROOT
readonly REQUESTED_PUBLISH="${PUBLISH:-false}"
readonly MODULES=(
api
mod-tools
gradle-plugin
)
log() {
echo "[publish] $*" >&2
}
# Prints the newest v* tag reachable from HEAD without its "v", or nothing.
release_tag_version() {
local tag
if tag="$(git -C "${REPO_ROOT}" describe --tags --abbrev=0 --match 'v*' 2> /dev/null)"; then
echo "${tag#v}"
fi
}
# Gradle tasks for every module, e.g. ":api:check".
module_tasks() {
local task="$1"
local module
for module in "${MODULES[@]}"; do
echo ":${module}:${task}"
done
}
run_gradle() {
local version="$1"
shift
"${REPO_ROOT}/gradlew" \
--no-daemon \
--project-dir "${REPO_ROOT}" \
"-Pversion=${version}" \
"$@"
}
main() {
local version
local publish="${REQUESTED_PUBLISH}"
local check_tasks
local publish_tasks
version="$(release_tag_version)"
if [[ -z "${version}" ]]; then
log "No v* git tag found (shallow clone without tags?); nothing to publish."
exit 1
fi
if [[ "${version}" == *-* ]]; then
publish=false
log "${version} is a pre-release version; nothing will be published."
fi
mapfile -t check_tasks < <(module_tasks check)
mapfile -t publish_tasks < <(module_tasks publishAllPublicationsToGiteaRepository)
log "Testing ZomboidForge ${version}: ${MODULES[*]}"
run_gradle "${version}" :core:check "${check_tasks[@]}"
if [[ "${publish}" != "true" ]]; then
log "Not publishing (PUBLISH=${REQUESTED_PUBLISH})."
return
fi
log "Publishing ZomboidForge ${version}"
run_gradle "${version}" "${publish_tasks[@]}"
log "Published ${MODULES[*]} ${version}"
}
main "$@"