Gradle utilities to simplify Bukkit/Spigot plugins writing and debugging.
- Automatically applies plugin: java
- Sets up compiler encoding to UTF-8
- Sets archivesBaseName to plugin name
- Supports APIs: Bukkit, CraftBukkit, Spigot, Paper
- 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
- Add smart dependency system
BukkitGradle on plugins.gradle.org
Note: Gradle 8.0+ is required
plugins {
id("ru.endlesscode.bukkitgradle") version "0.10.1"
}
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath("gradle.plugin.ru.endlesscode:bukkit-gradle:0.10.1")
}
}
apply(plugin: "ru.endlesscode.bukkitgradle")
If you want to use snapshots, you can add jitpack repository to settings.gradle
and use 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"
}
Simple build.gradle
file that use BukkitGradle:
plugins {
id("ru.endlesscode.bukkitgradle") version "0.10.1"
}
// Project information
group = "com.example.myplugin"
description = "My first Bukkit plugin with Gradle"
version = "0.1"
// Let's add needed API to project
dependencies {
compileOnly(bukkitApi())
// see section 'Dependencies' for more info
}
Note:
compileOnly
- it's likeprovided
scope in Maven. It means that this dependency will not be included to your final jar.
It's enough!
Will be hooked the 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.1
api-version: 1.16
Note: Main class built by following pattern:
<groupId>.<name>
You can configure attributes that will be placed to plugin.yml
:
// Override default configurations
bukkit {
// Version of API (if you will not set this property, will be used latest version at moment of BukkitGradle release)
apiVersion = "1.15.2"
// Attributes for plugin.yml
plugin {
name.set("MyPlugin")
description.set("My amazing plugin, that doing nothing")
main.set("com.example.plugin.MyPlugin")
version.set("1.0")
url.set("http://www.example.com") // Attribute website
authors.set(["OsipXD", "Contributors"])
}
}
Will be generated plugin.yml
file:
name: MyPlugin
description: My amazing plugin, that doing nothing
main: com.example.plugin.MyPlugin
version: 1.0
api-version: 1.15
website: http://www.example.com
authors: [OsipXD, Contributors]
If you want to add unsupported by BukkitGradle attributes, like a depend
, commands
etc.
Create plugin.yml
file and put custom attributes there.
BukkitGradle provides short extension-functions to add common repositories and dependencies. There are list of its.
Usage example:
repositories {
spigot() // Adds spigot repo
}
dependencies {
compileOnly(paperApi()) // Adds paper-api dependency
}
Some dependencies also add a repository needed for them.
Name | Signature | Adds repository |
---|---|---|
spigot | org.spigotmc:spigot:$apiVersion | mavenLocal |
spigotApi | org.spigotmc:spigot-api:$apiVersion | spigot |
bukkitApi | org.bukkit:bukkit:$apiVersion | spigot |
paperApi | io.papermc.paper:paper-api:$apiVersion | papermc |
Note: $apiVersion
- is ${version}-R0.1-SNAPSHOT
(where $version
is bukkit.version
)
If you need more extension-functions, create issue.
This plugin pre-configures jpenilla/run-task according to the specified configuration.
Use :runServer
task to run the dev server:
./gradlew runServer
Tip
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/run
Alternatively, you can configure runServer
task:
tasks.runServer {
runDirectory.set(file("build/run"))
}
Tip
It is possible to configure 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.16.4" // 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 6.6 or newer:
$ ./gradlew wrapper --gradle-version 6.7.1
- Use syntax
.set
inbukkit.meta
instead of=
:bukkit { meta { - desctiption = "My plugin's description" + description.set("My plugin's description") } }
- Use
bukkit.apiVersion
instead ofbukkit.version
:bukkit { - version = "1.16.4" + apiVersion = "1.16.4" }
- Use
build.server
block 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
q
andqq
functions calls inmeta { ... }
- Check generated plugin.yml contents after build.
If there are any problems, create an issue.
MIT (c) 2020 EndlessCode Group