import java.text.SimpleDateFormat
import org.gradle.internal.jvm.Jvm

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

group 'cn.enaium'
version '1.3.0'

sourceCompatibility = targetCompatibility = JavaVersion.VERSION_1_8

jar {
    manifest.attributes(
            'Manifest-Version': 1.0,
            'Main-Class': 'cn.enaium.joe.Main',
            "Implementation-Title": "${project.name}",
            "Implementation-Version": "${project.version}",
            "Implementation-Vendor": "${project.group}",
            "Implementation-Timestamp": new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()),
            "Premain-Class": "cn.enaium.joe.Agent",
            "Agent-Class": "cn.enaium.joe.Agent",
            "Can-Redefine-Classes": true,
            "Can-Retransform-Classes": true
    )
}

new File(System.getProperty("user.dir"), "run").mkdir()

repositories {
    mavenCentral()
    maven { url 'https://jitpack.io' }
    maven { url 'https://maven.quiltmc.org/repository/release' }
}

dependencies {
    testImplementation 'org.junit.jupiter:junit-jupiter-api:5.9.0'
    testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.9.0'

    implementation 'com.formdev:flatlaf:2.4'
    implementation 'com.formdev:flatlaf-extras:2.4'
    //noinspection GradlePackageUpdate
    implementation 'com.miglayout:miglayout-swing:5.3'
    implementation 'com.github.bobbylight:RSyntaxTextArea:3.2.0'
    implementation 'org.ow2.asm:asm-tree:9.3'
    implementation 'org.ow2.asm:asm-util:9.3'
    implementation 'org.ow2.asm:asm-commons:9.3'
    implementation 'org.benf:cfr:0.152'
    implementation 'com.github.mstrobel.procyon:procyon-decompiler:v0.6.0'
    implementation 'org.quiltmc:quiltflower:1.8.1'
    implementation 'org.javassist:javassist:3.29.1-GA'
    implementation 'com.google.code.gson:gson:2.9.0'
    implementation 'org.tinylog:tinylog:1.3.6'
    implementation 'com.github.FabricMC:mapping-io:597f0722d6'

    compileOnly files(Jvm.current().getToolsJar())//Must use jdk8
}

test {
    useJUnitPlatform()
}

shadowJar {
    dependencies {
        include(dependency('com.formdev:.*'))
        include(dependency('com.miglayout:.*'))
        include(dependency('com.github.bobbylight:RSyntaxTextArea'))
        include(dependency('org.ow2.asm:.*'))
        include(dependency('org.benf:cfr'))
        include(dependency('com.github.mstrobel.procyon:procyon-decompiler'))
        include(dependency('org.javassist:javassist'))
        include(dependency('com.google.code.gson:gson'))
        include(dependency('org.tinylog:.*'))
        include(dependency('org.quiltmc:quiltflower'))
        include(dependency('com.github.FabricMC:mapping-io'))
    }
    archiveClassifier.set('')
}

build.dependsOn shadowJar