plugins {
    id 'com.github.johnrengelman.shadow'
}

architectury {
    platformSetupLoomIde()
    fabric()
}

loom {
    accessWidenerPath = project(":common").loom.accessWidenerPath
}

configurations {
    common {
        canBeResolved = true
        canBeConsumed = false
    }
    compileClasspath.extendsFrom common
    runtimeClasspath.extendsFrom common
    developmentFabric.extendsFrom common

    // Files in this configuration will be bundled into your mod using the Shadow plugin.
    // Don't use the `shadow` configuration from the plugin itself as it's meant for excluding files.
    shadowBundle {
        canBeResolved = true
        canBeConsumed = false
    }
}

dependencies {
    // Mappings
    mappings "net.fabricmc:yarn:${project.yarn_mappings_version}:v2"

    // Fabric Loader
    modImplementation "net.fabricmc:fabric-loader:${project.fabric_loader_version}"

    // Fabric API
    modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_api_version}"

    // Architectury
    modImplementation("dev.architectury:architectury-fabric:${project.architectury_version}")

    // Cloth Config
    modRuntimeOnly("me.shedaniel.cloth:cloth-config-fabric:${project.cloth_config_version}")

    // Debug Utils
    modImplementation("io.github.flemmli97:debugutils:${project.debugutils_version}-fabric") {
        transitive = false
    }

    // Fabric Language Kotlin
    modRuntimeOnly("net.fabricmc:fabric-language-kotlin:${project.fabric_language_kotlin_version}")

    // Mod Menu
    modImplementation("com.terraformersmc:modmenu:${project.modmenu_version}") {
        transitive = false
    }

    // NBT Autocomplete
    modRuntimeOnly("maven.modrinth:nbt-autocomplete:${project.nbt_autocomplete_version}-fabric,1.21.1")

    // Observable
    modRuntimeOnly("maven.modrinth:observable:${project.observable_version}")

    // Smart Brain Lib
    modImplementation("net.tslat.smartbrainlib:SmartBrainLib-fabric-${project.minecraft_version}:${project.sbl_version}")

    // Suggestion Tweaker
    modRuntimeOnly("maven.modrinth:suggestion-tweaker:${project.suggestion_tweaker_version}+fabric")

    // Yet Another Config Lib
    modImplementation("dev.isxander:yet-another-config-lib:${project.yacl_version}-fabric")

    common(project(path: ':common', configuration: 'namedElements')) { transitive false }
    shadowBundle project(path: ':common', configuration: 'transformProductionFabric')
}

fabricApi {
    configureDataGeneration()
}

shadowJar {
    exclude "architectury.common.json"

    configurations = [project.configurations.shadowBundle]
    archiveClassifier = 'dev-shadow'
    archiveClassifier.set("dev-shadow")
}

remapJar {
    input.set shadowJar.archiveFile
    injectAccessWidener = true
    inputFile.set shadowJar.archiveFile
    dependsOn shadowJar
    archiveClassifier.set(null)
}
