Gradle utilities to simplify Bukkit/Spigot plugins writing and debugging.
- Sets up compiler encoding to UTF-8
- Provides short extension functions to add common repositories and dependencies
- Generates plugin.yml from Gradle project information
- Allows running dev server from IDE
- Runs server using jpenilla/run-task
Note
BukkitGradle requires Gradle 8.0+ to run
plugins {
    id("ru.endlesscode.bukkitgradle") version "1.0.0"
}BukkitGradle on plugins.gradle.org
Using snapshots
To use snapshots, add jitpack repository to the settings.gradle.kts and specify version develop-SNAPSHOT:
// settings.gradle
pluginManagement {
    repositories {
        gradlePluginPortal()
        maven { setUrl("https://jitpack.io") }
    }
}
rootProject.name = "<your project name>"// build.gradle
plugins {
    id("ru.endlesscode.bukkitgradle") version "develop-SNAPSHOT"
}Apply the plugin and configure project's group, description and version.
These values will be used to generate the plugin.yml file:
plugins {
    id("ru.endlesscode.bukkitgradle") version "1.0.0"
}
group = "com.example.myplugin"
description = "My first Bukkit plugin built with Gradle"
version = "0.1"
bukkit {
    // Target API version. Will be used both for plugin.yml and for dependencies
    apiVersion = "1.21.5"
}
// Add the necessary API to the project
dependencies {
    compileOnly(paperApi)
    // See the 'Dependencies' section for more info
}
repositories {
    papermc()
}That's it!
During the plugin compilation plugin.yml will be generated with the following content:
api-version: 1.21.5
name: MyPlugin
version: '0.1'
main: com.example.myplugin.MyPlugin
description: My first Bukkit plugin built with GradleNote
By default, main class is built by the following pattern: <groupId>.<name>
Next, you might need to configure plugin.yml content or run dev server.
The plugin.yml content can be configured using bukkit.plugin { ... } block.
bukkit {
    plugin {
        name = "MyPlugin"
        description = "My amazing plugin"
        main = "com.example.plugin.MyPlugin"
        version = "1.0"
        authors = listOf("osipxd", "contributors")
        depend = listOf("Vault", "Mimic")
    }
}BukkitGradle provides shortcuts to add common repositories and dependencies:
repositories {
    papermc()
}
dependencies {
    compileOnly(paperApi)
}When adding dependencies, make sure you've added the corresponding repository.
| Name | Signature | Official repository | 
|---|---|---|
| spigot | org.spigotmc:spigot:$apiVersion | mavenLocal()* | 
| spigotApi | org.spigotmc:spigot-api:$apiVersion | spigot() | 
| bukkitApi | org.bukkit:bukkit:$apiVersion | mavenLocal()** | 
| paperApi | io.papermc.paper:paper-api:$apiVersion | papermc() | 
* Spigot is available in mavenLocal() only if you've built it locally using Spigot BuildTools. 
** Bukkit should be built locally. However, some versions are available in spigot() repository.  
*** $apiVersion - is ${version}-R0.1-SNAPSHOT (where $version is bukkit.apiVersion).
If you need more shortcuts, file an issue.
This plugin pre-configures jpenilla/run-task according to the specified configuration.
Use :runServer task to run the dev server:
./gradlew runServerTip
It is possible to create a run configuration for IDEA by running :buildIdeaRun task.
The configuration will be stored in <projectDir>/.run directory so it can be shared through VCS.
The directory can be changed by configuring the :buildIdeaRun task:
tasks.buildIdeaRun {
    configurationsDir = file(".idea/runConfigurations")
}By default, the server will be located at <projectDir>/run but you can change it by providing Gradle property bukkitgradle.server.dir:
# gradle.properties
bukkitgradle.server.dir=build/runAlternatively, you can configure runServer task:
tasks.runServer {
    runDirectory.set(file("build/run"))
}Tip
It is possible to configure a server directory shared between multiple projects.
Set the bukkitgradle.server.dir property in $HOME/.gradle/gradle.properties.
This file contains local configurations to be used for all Gradle projects.
The value specified in project's gradle.properties takes precedence over the global one.
Use bukkit.server section to accept EULA and configure the server:
bukkit {
    // INFO: Default values are used here
    server {
        // Server version
        version = "1.21.5" // If not specified, bukkit.apiVersion will be used
        // Accept EULA
        eula = false
        // Set online-mode flag
        onlineMode = false
        // Debug mode (listen to 5005 port)
        debug = true
        // Set default file encoding (flag -Dfile.encoding)
        encoding = "UTF-8"
        // JVM arguments
        javaArgs("-Xmx1G")
        // Bukkit arguments
        bukkitArgs()
    }
}Note
eula and online-mode options specified in bukkit.server always take precedence over the values specified
in eula.txt and server.properties
- 
Update Gradle to 8.0 or newer (the latest version is recommended): ./gradlew wrapper --gradle-version 8.13 
- 
Replace deprecated and removed APIs: bukkit { - meta { + plugin { name = "MyPlugin" - url = "https://example.com/" + website = "https://example.com/" } }
- 
Specify bukkit.apiVersionexplicitly. Previously it was implicitly set to1.16.4:bukkit { apiVersion = "1.21.5" }
- 
Remove server core selection: bukkit.server.coreTypeandbukkit.server.setCore(...). Paper is the only supported server core now.
- 
If you have plugin.yml, move it's content tobukkit.plugin { ... }block and delete the file.
- 
Explicitly add mavenCentral()to the repositories if you're using dependencies from it:repositories { mavenCentral() }Add repositories for Bukkit/Spigot/Paper according to the dependency table. 
- Use bukkit.apiVersioninstead ofbukkit.version:bukkit { - version = "1.16.4" + apiVersion = "1.16.4" }
- Use build.serverblock instead ofbuild.run:bukkit { - run { + server { core = "paper" } }
- Update arguments assignment syntax:
bukkit { server { - jvmArgs = "-Xmx2G -Xms512M" + jvmArgs = ["-Xmx2G", "-Xms512M"] + //or jvmArgs("-Xms512M") if you don't want to override defaults } }
- Replace removed APIs:
repositories { - destroystokyo() + papermc() - vault() + jitpack() } dependencies { - compileOnly(craftbikkit()) + compileOnly(spigot()) }
- Remove qandqqfunctions calls inmeta { ... }
- Check generated plugin.yml contents after build.
If there are any problems, create an issue.
MIT (c) 2020 EndlessCode Group