Skip to content
Cerial edited this page Sep 13, 2024 · 23 revisions

Gradle

First you will need to add the repositories (you should already have Spigot) and the dependency to your build.gradle. You will also need to shadow the library into your plugin jar.

plugins {
    id 'com.github.johnrengelman.shadow' version '7.1.2'
    id 'java'
}

sourceCompatibility = targetCompatibility = JavaVersion.VERSION_1_8

repositories {
    maven { url = "https://repo.aikar.co/content/groups/aikar/" }
    maven { url = "https://hub.spigotmc.org/nexus/content/groups/public/" }
}

compileJava {
    options.compilerArgs += ["-parameters"]
    options.fork = true
    options.forkOptions.executable = System.getProperty("java.home") + "/bin/javac"
}

dependencies {
    compileOnly "org.spigotmc:spigot-api:1.15.2-R0.1-SNAPSHOT"
    implementation "co.aikar:acf-[PLATFORM]:[ACF VERSION]" // Replace PLATFORM with bukkit, paper, sponge, etc 
    // Example line:
    // implementation "co.aikar:acf-paper:0.5.1-SNAPSHOT"
}

shadowJar {
   relocate 'co.aikar.commands', '[YOUR PLUGIN PACKAGE].acf'
   relocate 'co.aikar.locales', '[YOUR PLUGIN PACKAGE].locales'
}

build.dependsOn shadowJar

Replace [ACF VERSION] with the latest version found on the ACF Repo

Replace [YOUR PLUGIN PACKAGE] with a package to your plugin so that ACF is relocated to it.

Replace the spigot-api version with your version. Make sure to use compileOnly for runtime dependencies. Don't use implementation, this will shade the dependency without relocation in your jar.

Enabling -parameters on the compiler lets ACF automatically generate Syntax messages for you using the parameter names. If you do not set this, syntax messages will use confusing names.

If you have kotlin, add this:

compileKotlin {
    kotlinOptions.javaParameters = true
}