plugins {
    id("java")
    id("com.github.johnrengelman.shadow") version "8.1.1"
}

group = 'ru.matveylegenda'
version = '2.2'

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

    maven {
        name = "sonatype"
        url = "https://oss.sonatype.org/content/groups/public/"
    }

    maven {
        name = "jitpack.io"
        url = "https://jitpack.io"
    }

    maven {
        name = "nickuc-repo"
        url = "https://repo.nickuc.com/maven-releases/"
    }
}

dependencies {
    compileOnly "com.destroystokyo.paper:paper-api:1.16.5-R0.1-SNAPSHOT"
    implementation "org.bstats:bstats-bukkit:3.0.2"
    compileOnly "net.elytrium:serializer:1.1.1"
    compileOnly "net.dv8tion:JDA:5.2.2"
    compileOnly "com.github.Overwrite987:UltimateServerProtector:33.3"
    compileOnly "com.github.AuthMe:AuthMeReloaded:5.6.0-beta2"
    compileOnly "com.nickuc.login:api:10.4"
    compileOnly "com.nickuc.openlogin:openlogin-universal:1.3"
    compileOnly "com.zaxxer:HikariCP:6.2.1"
}

tasks.shadowJar {
    relocate("org.bstats", "ru.matveylegenda.tidiscord2fa.utils.bstats")

    minimize()
}

def targetJavaVersion = 16
java {
    def javaVersion = JavaVersion.toVersion(targetJavaVersion)
    sourceCompatibility = javaVersion
    targetCompatibility = javaVersion
    if (JavaVersion.current() < javaVersion) {
        toolchain.languageVersion = JavaLanguageVersion.of(targetJavaVersion)
    }
}

tasks.withType(JavaCompile).configureEach {
    options.encoding = 'UTF-8'

    if (targetJavaVersion >= 10 || JavaVersion.current().isJava10Compatible()) {
        options.release.set(targetJavaVersion)
    }
}

processResources {
    def props = [version: version]
    inputs.properties props
    filteringCharset 'UTF-8'
    filesMatching('plugin.yml') {
        expand props
    }
}
