plugins {
    id 'multiloader-loader'
    id 'fabric-loom'
    id "com.modrinth.minotaur" version "2.+"
}

repositories {
    maven { url 'https://api.modrinth.com/maven' }
}

apply plugin: 'com.modrinth.minotaur'
modrinth {
    token = System.getenv("MODRINTH_TOKEN")
    projectId = "async"
    versionNumber = project.version
    versionName = project.version
    versionType = "alpha"
    uploadFile = fileTree(dir: "${project.buildDir}/libs", include: "*.jar").files.find()
    gameVersions = ["1.21.6", "1.21.7", "1.21.8"]
    loaders = ["fabric", "quilt"]
    dependencies {
        required.project "fabric-api"
        optional.project "lithium"
        optional.project "c2me-fabric"
        incompatible.project "moonrise-opt"
    }
    changelog = """
"""
}

dependencies {
    minecraft "com.mojang:minecraft:${minecraft_version}"
    mappings loom.layered {
        officialMojangMappings()
        parchment("org.parchmentmc.data:parchment-${parchment_minecraft}:${parchment_version}@zip")
    }
    modImplementation "net.fabricmc:fabric-loader:${fabric_loader_version}"
    modImplementation "net.fabricmc.fabric-api:fabric-api:${fabric_version}"

    include(implementation(annotationProcessor("com.github.bawnorton.mixinsquared:mixinsquared-fabric:${mixinsquared_version}")))
    modImplementation 'com.electronwill.night-config:toml:3.8.1'
    include group: 'com.electronwill.night-config', name: 'toml', version: '3.8.1'
    include group: 'com.electronwill.night-config', name: 'core', version: '3.8.1'
    compileOnly 'org.projectlombok:lombok:1.18.32'
    annotationProcessor 'org.projectlombok:lombok:1.18.32'

    implementation 'maven.modrinth:lithium:mc1.21.8-0.18.0-neoforge'
}

loom {
    def aw = project(':common').file("src/main/resources/async.accesswidener")
    accessWidenerPath.set(project(":common").file("src/main/resources/async.accesswidener"))
    if (aw.exists()) {
        accessWidenerPath.set(aw)
    }
    mixin {
        defaultRefmapName.set("async.refmap.json")
    }
    runs {
        client {
            client()
            setConfigName('Fabric Client')
            ideConfigGenerated(true)
            runDir('runs/client')
        }
        server {
            server()
            setConfigName('Fabric Server')
            ideConfigGenerated(true)
            runDir('runs/server')
        }
    }
}