Skip to content
itsTyrion edited this page Mar 17, 2024 · 2 revisions

Add the Jitpack repo if you haven't already:

repositories {
    // Add your other repositories here
    maven { url 'https://jitpack.io' }
}

If you want to use the Spigot Library Loader (plugin.yml libraries section), create a new dependency config like so:
(The name is up to you, I used spigotLib here)
Keep in mind it can only load from Maven Central!

configurations {
    spigotLib
    compileOnly { extendsFrom spigotLib }
}
// Change the dependency scope from `implementation`/`compileOnly` to the config name of your choice. Example:
spigotLib 'com.google.inject:guice:7.0.0' // example dependency

Then, pass the list to the compiler/annotation processor according to the sections below.


For Java sources:

dependencies {
    // Add your other dependencies here
    compileOnly 'de.itsTyrion:PluginAnnotationProcessor:1.4'
    annotationProcessor 'de.itsTyrion:PluginAnnotationProcessor:1.4'
}

tasks.withType(JavaCompile).configureEach {
    // Add other annotation processor arguments as/if needed or use different values, this is just what I use.
    options.compilerArgs +=
            "-AmcPluginVersion=${"$version".contains("SNAPSHOT") ? (version + new Date().format('yyyyMMdd_HHmm')) : version}"
    // This is only needed if you use the Spigot Library Loader. If you use a different config name, replace `spigotLib` with it.
    options.compilerArgs +=
            "-AspigotLibraries=${configurations.spigotLib.dependencies.collect { "$it.group:$it.name:$it.version" }.join(' ')}"
}

For Kotlin sources:

plugins {
    // Add your other gradle plugins here
    id 'org.jetbrains.kotlin.kapt' version 'current.kotlin.version'
}

dependencies {
    // Add your other dependencies here
    compileOnly 'de.itsTyrion:PluginAnnotationProcessor:1.4'
    kapt 'de.itsTyrion:PluginAnnotationProcessor:1.4'
}

kapt.arguments {
    // Add other annotation processor arguments as/if needed or use different values, this is just what I use.
    arg 'mcPluginVersion', version.contains("SNAPSHOT") ? (version + new Date().format('yyyyMMdd_HHmm')) : version
    // This is only needed if you use the Spigot Library Loader. If you use a different config name, replace `spigotLib` with it.
    arg 'spigotLibraries', configurations.spigotLib.dependencies.collect { "$it.group:$it.name:$it.version" }.join(';')
}
Clone this wiki locally