plugins {
    id "com.github.johnrengelman.shadow" version "7.0.0"
}

architectury {
    platformSetupLoomIde()
    fabric()
}

configurations {
    common
    shadowCommon // Don't use shadow from the shadow plugin because we don't want IDEA to index this.
    compileClasspath.extendsFrom common
    runtimeClasspath.extendsFrom common
    developmentFabric.extendsFrom common
    dev
}

loom {
    accessWidenerPath = project(":common").file("src/main/resources/ftblibrary.accesswidener")
}

artifacts {
    dev(jar)
}

dependencies {
    modApi "net.fabricmc:fabric-loader:${rootProject.fabric_loader_version}"
    modApi "net.fabricmc.fabric-api:fabric-api:${rootProject.fabric_api_version}"

    modApi "dev.architectury:architectury-fabric:${rootProject.architectury_version}"

    //modCompileOnlyApi("mezz.jei:jei-${minecraft_version}-fabric-api:${jei_version}")
//    modCompileOnlyApi("mezz.jei:jei-1.21.1-fabric-api:${jei_version}")

    common(project(path: ":common", configuration: "dev")) { transitive false }
    shadowCommon(project(path: ":common", configuration: "transformProductionFabric")) { transitive false }

//    modRuntimeOnly "curse.maven:atlasviewer-633577:6347925"
}

apply from: "https://raw.githubusercontent.com/FTBTeam/mods-meta/main/gradle/extra-local-mods.gradle"

processResources {
    inputs.property "version", project.version

    filesMatching("fabric.mod.json") {
        expand "version": project.version,
                "archversion": project.architectury_version,
                "fabricapiversionrange": project.fabric_api_version_range,
                "mcversion": project.minecraft_version
    }
}

shadowJar {
    configurations = [project.configurations.shadowCommon]
    setArchiveClassifier("dev-shadow")
}

remapJar {
    inputFile.set shadowJar.archiveFile
    dependsOn shadowJar
    archiveBaseName.set "${rootProject.archives_base_name}-${project.name}"
    archiveClassifier.set null
}

jar {
    setArchiveClassifier("dev")
}

components.java {
    withVariantsFromConfiguration(project.configurations.shadowRuntimeElements) {
        skip()
    }
}

publishing {
    publications {
        mavenFabric(MavenPublication) {
            artifactId = "${rootProject.archives_base_name}-${project.name}"
            version ftbPublishing.mavenVersion
            from components.java
        }
    }
}
