Skip to content

Launch Minecraft servers using Gradle task. For Bukkit, Spigot, Paper, etc..

License

Notifications You must be signed in to change notification settings

sya-ri/minecraft-server-gradle-plugin

Repository files navigation

minecraft-server-gradle-plugin

Pre Merge Checks License Language Gradle Plugin Portal

Launch Minecraft servers using Gradle task. For Bukkit, Spigot, Paper, etc..

Installation

build.gradle

plugins {
    id 'dev.s7a.gradle.minecraft.server' version '3.2.0'
}

build.gradle.kts

plugins {
    id("dev.s7a.gradle.minecraft.server") version "3.2.0"
}

Options

Name Default Description
jarUrl Required URL to Download the .jar
jarName server.jar Jar File Name After Download
serverDirectory build/MinecraftServer Working Directory
jvmArgument [] Java Options
serverArgument [] Server Options
nogui true Without Vanilla GUI
agreeEula false Agree to the Minecraft EULA

Example

Warning

This plugin doesn't have a default task. So you have to define it yourself.

Simple usage

build.gradle.kts

task<LaunchMinecraftServerTask>("launchMinecraftServer") {
    jarUrl.set(JarUrl.Paper("1.19.2"))
    agreeEula.set(true)
}

For testing a plugin

build.gradle.kts

task<LaunchMinecraftServerTask>("testPlugin") {
    dependsOn("build")

    doFirst {
        copy {
            from(buildDir.resolve("libs/${project.name}.jar"))
            into(buildDir.resolve("MinecraftServer/plugins"))
        }
    }

    jarUrl.set(JarUrl.Paper("1.19.2"))
    agreeEula.set(true)
}

For testing a multi-version supporting plugin

build.gradle.kts

listOf(
    "8" to "1.8.8",
    "9" to "1.9.4",
    "10" to "1.10.2",
    "11" to "1.11.2",
    "12" to "1.12.2",
    "13" to "1.13.2",
    "14" to "1.14.4",
    "15" to "1.15.2",
    "16" to "1.16.5",
    "17" to "1.17.1",
    "18" to "1.18.2",
    "19" to "1.19.4",
    "20" to "1.20.4"
).forEach { (name, version) ->
    task<LaunchMinecraftServerTask>("testPlugin$name") {
        dependsOn("build")

        doFirst {
            copy {
                from(buildDir.resolve("libs/${project.name}.jar"))
                into(buildDir.resolve("MinecraftServer$name/plugins"))
            }
        }

        serverDirectory.set(buildDir.resolve("MinecraftServer$name").absolutePath)
        jarUrl.set(JarUrl.Paper(version))
        agreeEula.set(true)
    }
}

Supported JarUrl

  • Paper
  • Velocity
  • Waterfall
  • Fabric
  • Mohist
  • LocalFile