import java.text.SimpleDateFormat

//file:noinspection GroovyUnusedAssignment
//file:noinspection GrUnresolvedAccess

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

sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8

group 'cn.apisium.papershelled'
def psVersion = version = System.getenv('RELEASE_VERSION') ?: '0.0.0-DEV'

repositories {
    mavenCentral()
    maven { url 'https://hub.spigotmc.org/nexus/content/repositories/snapshots/' }
    maven { url 'https://repo.spongepowered.org/repository/maven-public/' }
}

dependencies {
    compileOnly 'org.spigotmc:spigot-api:1.17-R0.1-SNAPSHOT'
    implementation 'org.spongepowered:mixin:0.8.4'
    implementation 'com.google.guava:guava:30.1.1-jre'
    implementation 'org.jetbrains:annotations:22.0.0'
    implementation "org.ow2.asm:asm:${project.asm_version}"
    implementation "org.ow2.asm:asm-analysis:${project.asm_version}"
    implementation "org.ow2.asm:asm-commons:${project.asm_version}"
    implementation "org.ow2.asm:asm-tree:${project.asm_version}"
    implementation "org.ow2.asm:asm-util:${project.asm_version}"
}

jar {
    manifest {
        def sdf = new SimpleDateFormat('EEE, MMM d, yyyy hh:mm:ss a z', Locale.US)
        sdf.setTimeZone(TimeZone.getTimeZone('GMT'))
        attributes 'Implementation-Title': 'PaperShelled'
        attributes 'Implementation-Version': psVersion
        attributes 'Implementation-Vendor': sdf.format(new Date())
        attributes 'Can-Redefine-Classes': 'true'
        attributes 'Can-Retransform-Classes': 'true'
        attributes 'Agent-Class': 'cn.apisium.papershelled.PaperShelledAgent'
        attributes 'Premain-Class': 'cn.apisium.papershelled.PaperShelledAgent'
        attributes 'Main-Class': 'cn.apisium.papershelled.launcher.Launcher'
    }
}

shadowJar {
    relocate 'com.google.common', 'cn.apisium.papershelled.guava'
    archiveClassifier.set('')
}

build.dependsOn(shadowJar)
