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
- Make sure
gradle.propertieshasproject-group,project-version,git-org-nameandgit-repository. - Replace the root
build.gradlewith theplugins { }block, plus anmcengineBuild { }block for anything that differs from the defaults. - 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. - Leave the module builds otherwise as they are. A module's own
publishing { }block keeps working, becausemaven-publishis applied before the module's build file runs.
| The old root build | Becomes |
|---|---|
publishes api, common, bukkit | nothing: the default |
also publishes tools | publishedModules.add('tools') |
has a POM url other than the GitHub repository | pomUrl = 'https://...' |
| names a developer in the POM | developerId, developerName, developerUrl |
| uses another Java version | javaVersion = 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.