plugins {
    id 'java'
}

group = 'ru.redguy'
version = '1.0.0'

repositories {
    mavenCentral()
    maven {
        name = 'papermc-repo'
        url = 'https://papermc.io/repo/repository/maven-public/'
    }
    maven {
        name = 'sonatype'
        url = 'https://oss.sonatype.org/content/groups/public/'
    }
    maven {
        name = 'redguy-repo'
        url = 'https://repo.redguy.ru/repository/maven-public/'
    }
}

dependencies {
    compileOnly 'com.destroystokyo.paper:paper-api:1.12.2-R0.1-SNAPSHOT'
    compileOnly 'me.clip:placeholderapi:2.11.1'
    compileOnly "com.github.MilkBowl:VaultAPI:1.7"
    compileOnly "net.citizensnpcs:citizensapi:2.0.29-SNAPSHOT"

    implementation 'com.github.IPVP-MC:canvas:1fa1956b89'
    implementation 'mysql:mysql-connector-java:8.0.16'
    implementation 'com.zaxxer:HikariCP:4.0.3'
    implementation 'org.jetbrains:annotations:20.1.0'
    implementation 'com.h2database:h2:1.4.200'
}

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

compileJava.options.encoding = 'UTF-8'
tasks.withType(JavaCompile).configureEach {
    if (targetJavaVersion >= 10 || JavaVersion.current().isJava10Compatible()) {
        options.release = targetJavaVersion
    }
}

jar {
    configurations.implementation.canBeResolved = true
    from {
        duplicatesStrategy = DuplicatesStrategy.EXCLUDE
        configurations.implementation.collect { it.isDirectory() ? it : zipTree(it) }
    }
}

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

task copytorun(type: Copy) {
    delete file("$projectDir/Server/plugins/QSeller*")
    from file("$projectDir/build/libs/QSeller-${version}.jar")
    into file("$projectDir/Server/plugins/")
}
