Getting started
Three files turn a multi-module plugin project into a build the plugin configures.
1. Apply the plugin
Add the plugin to the root build.gradle. It resolves from the Gradle Plugin Portal, which every build searches by default:
plugins {
id 'io.github.mcengine.build-logic' version '0.2.0'
}
Releases are also published to https://maven.pkg.github.com/MCEngine/gradle-plugin. To resolve from there instead, add that repository with GITHUB_ACTOR and a GITHUB_TOKEN that can read packages to pluginManagement { repositories { } } in settings.gradle, beside gradlePluginPortal().
2. Name the project in gradle.properties
The plugin reads four properties:
| Property | Used for |
|---|---|
project-group | The group of every project |
project-version | The version of every project |
git-org-name | The GitHub owner the published modules go to |
git-repository | The GitHub repository the published modules go to |
project-group=io.github.example
project-version=1.0.0
git-org-name=Example
git-repository=example-plugin
The last two are needed only when a module is published.
3. Lay out the modules
A typical settings.gradle. Folders without a build file, such as platforms, are left alone:
plugins {
id 'org.gradle.toolchains.foojay-resolver-convention' version '1.0.0'
}
rootProject.name = 'example-plugin'
include 'api'
include 'common'
include 'bukkit'
include 'platforms:spigotmc'
include 'platforms:papermc'
include 'platforms:foliamc'
include 'platforms:engine'
Module builds keep only what is theirs: dependencies, resources and, in the engine, the Shadow configuration. The engine applies Shadow without a version, because the plugin already put it on the classpath:
platforms/engine/build.gradleplugins {
id 'com.gradleup.shadow'
}
dependencies {
implementation project(':bukkit')
implementation project(':platforms:spigotmc')
implementation project(':platforms:papermc')
implementation project(':platforms:foliamc')
}
4. Build
Terminal./gradlew build # compile and test every module
./gradlew :platforms:engine:shadowJar # the server jar
./gradlew publish # the published modules, with GITHUB_ACTOR and GITHUB_TOKEN set
Anything that differs from the defaults goes in mcengineBuild { }.