plugins {
    id "fabric-loom" version "1.11-SNAPSHOT"
    id "com.matthewprenger.cursegradle" version "1.4.0"
}

base.archivesName.set("${mod_name}-fabric")

dependencies {
    minecraft "com.mojang:minecraft:${minecraft_version}"
    mappings loom.officialMojangMappings()
    compileOnly project(":Common")
    modImplementation "net.fabricmc:fabric-loader:${fabric_loader_version}"
    modImplementation "net.fabricmc.fabric-api:fabric-api:${fabric_version}"
    modImplementation "com.github.glitchfiend:GlitchCore-fabric:${minecraft_version}-${glitchcore_version}"
    modImplementation "com.github.glitchfiend:TerraBlender-fabric:${minecraft_version}-${terrablender_version}"
    implementation group: 'com.google.code.findbugs', name: 'jsr305', version: '3.0.2'
    include implementation("com.electronwill.night-config:toml:${nightconfig_version}")
    include implementation("com.electronwill.night-config:core:${nightconfig_version}")
    include implementation("net.jodah:typetools:0.6.3")
}

loom {
    accessWidenerPath = project(":Common").file("src/main/resources/${mod_id}.accesswidener")
    mixin {
        defaultRefmapName.set("${mod_id}.refmap.json")
    }
    runs {
        client {
            client()
            setConfigName("Fabric Client")
            ideConfigGenerated(true)
            runDir("run")
        }
        server {
            server()
            setConfigName("Fabric Server")
            ideConfigGenerated(true)
            runDir("run")
        }
    }
}

processResources {
    from project(":Common").sourceSets.main.resources
}

tasks.withType(JavaCompile) {
    source(project(":Common").sourceSets.main.allSource)
}

curseforge {
    apiKey = project.findProperty('curseApiKey') ?: 'unset'
    project {
        id = mod_curseforge_id

        if (changelog_file.exists()) {
            changelog = changelog_file
        }

        releaseType = release_channel
        addGameVersion minecraft_version
        addGameVersion name

        mainArtifact(remapJar) {
            displayName = "${mod_display_name} ${name} ${version}"
        }

        relations {
            requiredDependency 'fabric-api'
            requiredDependency 'glitchcore'
            requiredDependency 'terrablender-fabric'
        }
    }
}