Getting started with gradle (outdated)

Genref is code generator, that simplify the plugin class code

Step 1 - adding dependensies

Add this plugins to your build:

kotlin("jvm") version "1.8.21"
id("java")
id("net.minecrell.plugin-yml.bukkit") version "0.6.0"
id("com.github.johnrengelman.shadow") version "7.1.2"
id("com.google.devtools.ksp") version "1.8.21-1.0.11"

kotlin and java we need for support this langs,

net.minecrell.plugin-yml.bukkit we need for simplify generation of plugin.yml

com.github.johnrengelman.shadow we need for remove excess dependencies (for example kotlin std lib) from build.

com.google.devtools.ksp is kotlin code generator plugin

Set group and version

group = "me.redtea"
version = "1.0.0-SNAPSHOT"

Add this dependencies to your build:

repositories {
    mavenCentral()
    maven {
        name = "spigotmc-repo"
        url = uri("https://hub.spigotmc.org/nexus/content/repositories/snapshots/")
    }
}

dependencies {
    //spigot api library
    compileOnly("org.spigotmc:spigot-api:1.16.5-R0.1-SNAPSHOT")
    
    //kotlin std lib and other jetbrains libs
    library("org.jetbrains.kotlin:kotlin-stdlib")
    library("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.7.2")
    library("org.jetbrains:annotations:24.0.0")
    //implementation files('libs/MiniMessages-0.1.0.jar')

    //dependencies for genref
    library("tech.carcadex:kotlinbukkitkit-architecture:1.0.0.3")
    library("tech.carcadex:kotlinbukkitkit-genref:1.0.0.3")
    
    // additonal libs
    library("tech.carcadex:kotlinbukkitkit-utility:1.0.0.3")
    library("tech.carcadex:kotlinbukkitkit-menu:1.0.0.3")
    library("tech.carcadex:kotlinbukkitkit-extensions:1.0.0.3")
    
    ksp("tech.carcadex:kotlinbukkitkit-genref:1.0.0.3")
}

You need two dependencies (without jetbrains libs and spigot api) for use genref: kotlinbukkitkit-architecture and kotlinbukkitkit-genref:

library("tech.carcadex:kotlinbukkitkit-architecture:1.0.0.3")
library("tech.carcadex:kotlinbukkitkit-genref:1.0.0.3")

Step 2 - configuring bukkit plugin-yml

Change author in this configuration

bukkit {
    main = "${project.group}.${project.name.toLowerCase()}.${project.name}Plugin"
    author = "itzRedTea"
    apiVersion = "1.13"
}

Step 3 - remove kotlin std lib from build

tasks {
    shadowJar {
        dependencies {
            exclude(dependency("org.jetbrains:*:*"))
        }
    }
}

Step 4 - writing main function

@Plugin
fun KotlinPluign.start() {
    
}

Also you can create function for disable process

@OnDisable
fun KotlinPluign.stop() {
    
}

Step 5 - start ksp task

Start kspKotlin task. Done!

Last updated