plugins {
    id 'net.fabricmc.fabric-loom' version '1.15-SNAPSHOT'
    id 'maven-publish'
}

version = project.mod_version
group = project.maven_group

base {
    archivesName = project.archives_base_name
}

repositories {
    mavenCentral()
    maven { url 'https://maven.wispforest.io/releases/' }
    maven { url 'https://jitpack.io' }
    maven { url = "https://cursemaven.com" }
    maven { url 'https://maven.izzel.io/releases/' }
}

dependencies {
    minecraft "com.mojang:minecraft:${project.minecraft_version}"
    implementation "net.fabricmc:fabric-loader:${project.loader_version}"

    implementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}"

    implementation "dev.icyllis:modernui-core:${modernui_version}"
    implementation "icyllis.modernui:ModernUI-Markflow:${modernui_version}"
    implementation("icyllis.modernui:ModernUI-Fabric:${minecraft_version}-${modernui_version}.+")

    include(implementation("io.github.CDAGaming:DiscordIPC:0.10.2"))
}

processResources {
    inputs.property "version", project.version
    inputs.property "minecraft_version", project.minecraft_version
    inputs.property "loader_version", project.loader_version
    filteringCharset "UTF-8"

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

def targetJavaVersion = 25
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()
}

jar {
    from("LICENSE") {
        rename { "${it}_${project.archives_base_name}" }
    }
}

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

repositories {

    }
}
