plugins {
    id 'java'
    id 'eclipse'
    id 'com.github.johnrengelman.shadow' version '8.1.1'
}

group 'link.star_dust'
version '1.7.7'

sourceCompatibility = 17

repositories {
    mavenCentral()
    maven {
        name = 'spigotmc-repo'
        url = 'https://hub.spigotmc.org/nexus/content/repositories/snapshots/'
    }
    maven {
        name = 'papermc-repo'
        url = 'https://repo.papermc.io/repository/maven-public/'
    }
    maven {
        name = 'bStats'
        url = 'https://repo.codemc.org/repository/maven-public/'
    }
    maven {
        name = 'Apache'
        url = 'https://maven.aliyun.com/repository/apache-snapshots'
    }
}

dependencies {
    compileOnly 'dev.folia:folia-api:1.20.1-R0.1-SNAPSHOT'
    implementation 'org.bstats:bstats-bukkit:3.0.0'
    implementation 'org.json:json:20230227'
    implementation 'org.apache.httpcomponents.client5:httpclient5:5.2'
}

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

jar {
    duplicatesStrategy = DuplicatesStrategy.EXCLUDE
    manifest {
        attributes(
            'Main-Class': 'link.star_dust.MinerTrack',
            'Implementation-Title': project.name,
            'Implementation-Version': project.version
        )
    }
    exclude 'META-INF/', 'LICENSE.txt', 'LICENSE', 'org/apache/', 'org/spigotmc/', 'org/bukkit/', 'org/yaml/', 'com/', 'net/', 'mojang-translations/', 'javax/'

    from {
        configurations.compileClasspath.collect { it.isDirectory() ? it : zipTree(it) }
    }
}

shadowJar {
    relocate 'org.bstats', 'link.star_dust.bstats'
    relocate 'org.apache.httpcomponents', 'link.star_dust.httpcomponents'
    duplicatesStrategy = DuplicatesStrategy.EXCLUDE
    archiveClassifier.set('')
}

build {
    dependsOn shadowJar
}
