plugins {
    id "com.github.johnrengelman.shadow" version "8.+"
}

apply from: "https://raw.githubusercontent.com/Flemmli97/GradleScripts/arch-loom-v2/common.gradle"

configurations {
    shadowCommon // Don't use shadow from the shadow plugin because we don't want IDEA to index this.
}

repositories {
    mavenLocal()
    maven { url 'https://jitpack.io' }
    maven {
        name = "FTB"
        url = "https://maven.ftb.dev/releases"
    }
    maven {
        name = "CurseMaven"
        url "https://www.cursemaven.com"
    }
    maven { url "https://maven.impactdev.net/repository/development/" }
    maven {
        url "https://maven.tterrag.com/"
    }
    maven { url = "https://mvn.devos.one/snapshots/" }
    maven { // Reach Entity Attributes
        url = "https://maven.jamieswhiteshirt.com/libs-release"
        content { includeGroup("com.jamieswhiteshirt") }
    }
    maven {
        name = "LinguaBib"
        url "https://maven.blazing-coop.net/releases"
    }
}

dependencies {
    implementation group: 'org.yaml', name: 'snakeyaml', version: '2.4'
    shadowCommon group: 'org.yaml', name: 'snakeyaml', version: '2.4'

    modImplementation dynmap_fabric

    modImplementation "dev.ftb.mods:ftb-ranks:${ftb_ranks}"
    modImplementation "dev.ftb.mods:ftb-chunks:${ftb_chunks}"
    implementation 'com.github.BlueMap-Minecraft:BlueMapAPI:v2.2.1'
    implementation ("net.impactdev.impactor.api:economy:${impactor_version}"){
        exclude group: "net.kyori"
    }

    // We can actually use the fabric version as the package structure is the same
    // On forge though due to forge interfaces this is not possible
    modCompileOnly "io.github.fabricators_of_create.Porting-Lib:base:${porting_lib}"
    modCompileOnly "io.github.fabricators_of_create.Porting-Lib:entity:${porting_lib}"
    modCompileOnly "com.jamieswhiteshirt:reach-entity-attributes:${reach_entity_attributes_version}"
    modCompileOnly("com.simibubi.create:create-fabric-1.20.1:${create_fabric}") {
        transitive = false
    }
    modCompileOnly "com.tterrag.registrate_fabric:Registrate:${registrate}"

    modImplementation "io.github.flemmli97:lingua_bib:${lingua_bib}-common"
}

sourceSets.main.resources {
    srcDir "src/generated/resources"
}

shadowJar {
    relocate "org.yaml.snakeyaml", "${rootProject.maven_group}.flan.shadow.org.yaml.snakeyaml"
    configurations = [project.configurations.shadowCommon]
}

// Use the shadow jar instead of normal jar to shadow yaml lib properly into fabric builds
transformProductionFabric {
    dependsOn shadowJar
    input.set shadowJar.archiveFile
}

// Use the shadow jar instead of normal jar to shadow yaml lib properly into forge builds
transformProductionNeoForge {
    dependsOn shadowJar
    input.set shadowJar.archiveFile
}

task apiJar(type: Jar, dependsOn: classes) {
    archiveClassifier.set "common-api-source"
    from project(":common").sourceSets.main.output + sourceSets.main.output
    include "io/github/flemmli97/flan/api/**"
}

task remapApiJar(type: net.fabricmc.loom.task.RemapJarTask) {
    archiveClassifier.set "common-api"
    input.set apiJar.archiveFile
    addNestedDependencies = false
    dependsOn apiJar
}

publishing {
    publications {
        mavenJava(MavenPublication) {
            artifact(remapApiJar) {
                classifier "api"
                builtBy remapApiJar
            }
        }
    }
}