Gradle utilities for easier writing Bukkit plugins.
- Automatically applies plugins: java, idea, eclipse
- Sets up compiler encoding to UTF-8
- Adds repositories: mavenCentral, mavenLocal, spigot-repo, sk89q-repo
- Provides short extension-functions to include bukkit/craftbukkit/spigot/spigot-api
- Generates plugin.yml from Gradle project information
- Allows to run dev server from IDE
- Automatically copies your plugin to plugins dir on server running
- Add extension function for PaperApi
- Add possibility to use Paper/CraftBukkit as dev server core
- Add automatically downloading of BuildTools
- Add smart dependency system
BukkitGradle on plugins.gradle.org
plugins { id "ru.endlesscode.bukkitgradle" version "0.7.1" }buildscript { repositories { jcenter() } dependencies { classpath "gradle.plugin.ru.endlesscode:bukkit-gradle:0.7.1" } } apply plugin: "ru.endlesscode.bukkitgradle"You can clone this example project [OUTDATED], and use it for quick start.
Simple build.gradle file that use BukkitGradle:
plugins { id "ru.endlesscode.bukkitgradle" version "0.7.1" } // Project information group "com.example" description "My first Bukkit plugin with Gradle" version "0.1" // Let's add needed API to project dependencies { compileOnly bukkit() // You also can use craftbukkit(), spigot() and spigotApi() }compileOnly - it's like provided scope in Maven. It means that this dependncy will not included to your final jar. It's enough! Will be hooked latest version of Bukkit and automatically generated plugin.yml with next content:
name: MyPlugin description: My first Bukkit plugin with Gradle main: com.example.myplugin.MyPlugin version: 0.1Main class build by pattern: <groupId>.<lower case name>.<name>
You can configure attributes that will be placed to plugin.yml:
// Override default configurations bukkit { // Version of API (latest by default) version = "1.12.2" // Attributes for plugin.yml meta { name = "MyPlugin" description = "My amazing plugin, that doing nothing" main = "com.example.plugin.MyPlugin" version = "1.0" url = "http://www.example.com" // Attribute website authors = ["OsipXD", "Contributors"] } }Will be generated next plugin.yml file:
name: MyPlugin description: My amazing plugin, that doing nothing main: com.example.plugin.MyPlugin version: 1.0 website: http://www.example.com authors: [OsipXD, Contributors]Also you can add custom (unsupported by BukkitGradle) attributes like a depend etc. Just create plugin.yml file and put custom attributes into.
Before running server you should configure BuildTools and dev server location.
You can define it in local.properties file (that was automatically created in project root on refresh):
# Absolute path to directory that contains BuildTools.jar buildtools.dir=/path/to/buildtools/ # Absolute path to dev server server.dir=/path/to/buildtools/Or you can define it globally (for all projects that uses BukkitGradle) with environment variables BUKKIT_DEV_SERVER_HOME and BUILDTOOLS_HOME.
Run :buildIdeaRun task. To your IDE will be added Run Configuration that will dynamically refreshes when you change server configurations.
Run ':startServer' task.
To accept EULA and change settings use bukkit.run section:
bukkit { // INFO: Here used default values run { // Accept EULA eula = false // Set online-mode flag onlineMode = false // Debug mode (listen 5005 port, if you use running from IDEA this option will be ignored) debug = true // Set server encoding (flag -Dfile.encoding) encoding = "UTF-8" // JVM arguments javaArgs = "-Xmx1G" // Bukkit arguments bukkitArgs = "" } }EULA and online-mode settings in build.gradle always rewrites settings in eula.txt and server.properties
