plugins {
    id 'fabric-loom' version '1.8-SNAPSHOT'
    id 'maven-publish'
    id 'java'
    id 'com.github.johnrengelman.shadow' version '8.1.1'
}

version = project.mod_version
group = project.maven_group

base {
    archivesName = project.archives_base_name
}

repositories {
    mavenCentral()
    gradlePluginPortal()
    maven { url = "https://maven.fabricmc.net/" }
    maven { url = 'https://maven.wispforest.io/releases/' }
    maven { url = 'https://repo.u-team.info' }
    maven { url = 'https://jitpack.io' }
    maven { url = "https://maven.terraformersmc.com/releases/" }
    maven { url = "https://maven.izzel.io" }
    maven { url = "https://raw.githubusercontent.com/Fuzss/modresources/main/maven/" }
    maven { url "https://dl.cloudsmith.io/public/geckolib3/geckolib/maven/" }
}

dependencies {
    minecraft "com.mojang:minecraft:1.21.1"
    mappings "net.fabricmc:yarn:${project.yarn_mappings}:v2"

    modImplementation "net.fabricmc:fabric-loader:0.16.14"
    modImplementation "net.fabricmc.fabric-api:fabric-api:0.105.0+1.21.1"
    modImplementation "io.wispforest:owo-lib:0.12.15.4+1.21"

    include(implementation("org.reflections:reflections:0.10.2"))
    include(implementation("com.google.guava:guava:32.1.2-jre"))
    include(implementation("org.javassist:javassist:3.29.2-GA"))
    include(implementation("org.slf4j:slf4j-api:2.0.9"))
    include(implementation("org.apache.httpcomponents:httpclient:4.5.13"))
    include(implementation("com.google.code.gson:gson:2.10.1"))
    include(implementation("io.socket:socket.io-client:2.1.0"))

    implementation "com.github.JnCrMx:discord-game-sdk4j:v0.5.5"
    include(implementation("net.hycrafthd:minecraft_authenticator:3.0.6"))

    implementation "io.github.jaredmdobson:concentus:1.0.2"
    implementation "org.java-websocket:Java-WebSocket:1.5.6"

    implementation "icyllis.modernui:ModernUI-Core:3.12.0"
    implementation "icyllis.modernui:ModernUI-Markflow:3.12.0"
    modImplementation("icyllis.modernui:ModernUI-Fabric:1.21.1-3.12.0.2")
    modImplementation "fuzs.forgeconfigapiport:forgeconfigapiport-fabric:21.1.0"

    modImplementation "software.bernie.geckolib:geckolib-fabric-1.21:4.5.8"

    modImplementation "com.terraformersmc:modmenu:11.0.3"
}

processResources {
    inputs.property "version", "1.0.0"
    inputs.property "loader_version", "0.16.14"
    inputs.property "minecraft_version", "1.21.1"

    filesMatching("fabric.mod.json") {
        expand(
                "version": "1.0.0",
                "loader_version": "0.16.14",
                "minecraft_version": "1.21.1"
        )
    }
}

def targetJavaVersion = 21
tasks.withType(JavaCompile).configureEach {
    it.options.encoding = "UTF-8"
    if (targetJavaVersion >= 10 || JavaVersion.current().isJava10Compatible()) {
        it.options.release.set(targetJavaVersion)
    }
}

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

remapJar {
    archiveClassifier.set("")
}
build.dependsOn remapJar

jar {
}

sourceSets {
    main {
        java {
            srcDirs = ['src/main/java', 'src/main/kotlin']
        }
        resources {
            srcDirs = ['src/main/resources']
        }
    }
}

loom {
    mixin {
        defaultRefmapName = "citrus.refmap.json"
    }
}

publishing {
    publications {
        create("mavenJava", MavenPublication) {
            artifactId = project.archives_base_name
            from components.java
        }
    }
}
