Gradle convention plugin

Build logic for Minecraft server plugins

io.github.mcengine.build-logic configures a whole multi-module Bukkit, Spigot, Paper or Folia plugin build from one plugins { } line: the Java toolchain, UTF-8, repositories, GitHub Packages publishing for the modules other plugins compile against, and Shadow for the module that becomes the server jar.

v0.2.0 Gradle 9 Java 17+ to run Gradle Shadow 9.4.1 included

Why it exists

A Minecraft plugin that runs on several server platforms is usually split into modules: a pure Java api other plugins compile against, a common core, a bukkit layer, one thin entry point per platform, and an engine module that shades them all into the one jar a server loads. Every such project ends up with the same 60 line root build.gradle: allprojects { } for group, version and repositories, subprojects { } for the toolchain and encoding, publishing for the library modules, and Shadow for the jar. Copied between repositories, those blocks drift.

This plugin is that root build, versioned and tested. Applying it replaces the copied blocks, and every repository that applies the same version builds the same way.

It is used by more than fifteen plugins in the MCEngine family, but it assumes nothing about them: the names it publishes under and the modules it touches come from your own gradle.properties and an optional mcengineBuild { } block.

A whole root build

With the plugin, a root build.gradle is this:

build.gradle
plugins {
    id 'io.github.mcengine.build-logic' version '0.2.0'
}

and gradle.properties names the project:

gradle.properties
project-group=io.github.example
project-version=1.0.0
git-org-name=Example
git-repository=example-plugin

Every module with a build file then compiles with the Java 25 toolchain; api, common and bukkit publish to https://maven.pkg.github.com/Example/example-plugin as example-plugin-api and so on; and engine builds the shaded jar. Each of those choices can be changed in mcengineBuild { }.

What it configures

ProjectsGets
Every projectgroup and version from project-group and project-version; mavenCentral()
Every subproject with a build fileThe java plugin, the Java toolchain (25 by default) and UTF-8 compilation
Modules in publishedModulesmaven-publish, the GitHub Packages repository, a {rootProject.name}-{module} artifactId and the POM
Modules in shadowModulescom.gradleup.shadow, which the plugin puts on the build classpath
The root projectA clean task, unless the root build declares one

The details, and when each step runs, are in What it configures.

Documentation

Requirements