Gradle plugin

Migrating a build

Move an existing build to the plugin without changing what it builds or publishes.

Before

A copied root build.gradle usually carries allprojects { } setting group, version and mavenCentral(); subprojects { } applying java, the toolchain and, for the library modules, maven-publish with a GitHub Packages repository and a ${rootProject.name}-${project.name} artifactId; and a root clean task.

Steps

  1. Make sure gradle.properties has project-group, project-version, git-org-name and git-repository.
  2. Replace the root build.gradle with the plugins { } block, plus an mcengineBuild { } block for anything that differs from the defaults.
  3. Remove the version from every id 'com.gradleup.shadow' in the module builds. Gradle refuses a version for a plugin that is already on the classpath.
  4. Leave the module builds otherwise as they are. A module's own publishing { } block keeps working, because maven-publish is applied before the module's build file runs.
The old root buildBecomes
publishes api, common, bukkitnothing: the default
also publishes toolspublishedModules.add('tools')
has a POM url other than the GitHub repositorypomUrl = 'https://...'
names a developer in the POMdeveloperId, developerName, developerUrl
uses another Java versionjavaVersion = 21

Check the result

Terminal
./gradlew build
./gradlew publishToMavenLocal

The build passes, the engine jar is in platforms/engine/build/libs/, and ~/.m2/repository/{group path}/ holds one folder per published module, each POM with the same <url> as before.

To try an unreleased version of the plugin, put includeBuild '../gradle-plugin' in pluginManagement { } of settings.gradle and drop the version from the root plugins { } block.

← Publishing Change log →