plugins {
    id 'java'
}

apply plugin: 'com.gradleup.shadow'
apply plugin: 'com.modrinth.minotaur'
apply plugin: 'io.papermc.hangar-publish-plugin'
apply plugin: 'xyz.jpenilla.run-velocity'

apply from: "https://raw.githubusercontent.com/henkelmax/mod-gradle-scripts/${mod_gradle_script_version}/mod.gradle"

repositories {
    mavenCentral()
    maven { url = 'https://repo.papermc.io/repository/maven-public/' }
}

dependencies {
    compileOnly "com.velocitypowered:velocity-api:${velocity_version}"
    annotationProcessor "com.velocitypowered:velocity-api:${velocity_version}"
    implementation "io.netty:netty-handler:${netty_version}"
    implementation "io.netty:netty-buffer:${netty_version}"
    implementation "io.netty:netty-transport:${netty_version}"
}

sourceSets {
    template {
        java {
            srcDir 'src/template/java'
        }
    }
    main {
        compileClasspath += sourceSets.template.output
        runtimeClasspath += sourceSets.template.output
    }
}

tasks.register('generateJava', Copy) {
    from file('src/template/java')
    into "${layout.buildDirectory.asFile.get()}/generated/java"
    expand 'mod_version': mod_version
}

sourceSets.main.java {
    srcDir "${layout.buildDirectory.asFile.get()}/generated/java"
}

tasks {
    runVelocity {
        velocityVersion("${velocity_version}")
    }
}

compileJava.dependsOn generateJava
build.dependsOn shadowJar
runVelocity.dependsOn(build)