Gradle Setup

MicleBrick edited this page Jun 20, 2018 · 15 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.

buildscript {
    repositories {
        jcenter()
    }

    dependencies {
        classpath "com.github.jengelman.gradle.plugins:shadow:2.0.2"
    }
}

apply plugin: "com.github.johnrengelman.shadow"
apply plugin: 'java'

sourceCompatibility = '1.8'
targetCompatibility = '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 = 'javac'
}

dependencies {
    compile "co.aikar:acf-core:[ACF VERSION]"
}

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

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.

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
}
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.
Press h to open a hovercard with more details.