plugins {
    id "com.gradleup.shadow" version "9.2.2" apply false
    id "architectury-plugin" version "3.4-SNAPSHOT"
    id "dev.architectury.loom" version "1.11-SNAPSHOT" apply false
    id "net.neoforged.licenser" version "0.7.5" apply false
    id "io.github.p03w.machete" version "2.0.1" apply false
}

architectury {
    minecraft = rootProject.minecraft_version
}

subprojects {
    apply plugin: "dev.architectury.loom"
    apply plugin: "io.github.p03w.machete"
    apply plugin: "net.neoforged.licenser"

    loom {
        silentMojangMappingsLicense()
    }

    dependencies {
        minecraft "com.mojang:minecraft:${rootProject.minecraft_version}"
        mappings loom.layered() {
            officialMojangMappings()
            parchment("org.parchmentmc.data:parchment-1.21.8:${rootProject.parchment_version}@zip")
        }
    }

    machete {
        ignoredTasks.add("shadowJar")
        ignoredTasks.add("jar")
    }

    license {
        header = rootProject.file('HEADER')
        skipExistingHeaders = false

        tasks {
            rrls {
                files.from rootProject.fileTree("src", {
                    include "**/*.java"
                })
            }
        }
    }

    processResources {
        inputs.property "version", version
        inputs.property "minecraft_version", minecraft_version
        inputs.property "fabric_version", loader_version
        inputs.property "neo_version", forge_version
        inputs.property "fcapip_version", fcapip_version

        filesMatching(["META-INF/neoforge.mods.toml", "fabric.mod.json"]) {
            expand "version": version,
                    "minecraft_version": minecraft_version,
                    "fabric_version": loader_version,
                    "neo_version": forge_version,
                    "fcapip_version": fcapip_version
        }
    }
}

allprojects {
    apply plugin: "java"
    apply plugin: "architectury-plugin"
    apply plugin: "maven-publish"

    base.archivesName = rootProject.archives_base_name
    version = "${rootProject.mod_version}+mc${rootProject.minecraft_version}-${project.name}"
    group = rootProject.maven_group

    repositories {
        maven {
            name = "NeoForged"
            url = "https://maven.neoforged.net/releases"
        }
        maven {
            name = "Fuzs Mod Resources"
            url = "https://raw.githubusercontent.com/Fuzss/modresources/main/maven/"
        }
    }

    tasks.withType(JavaCompile).configureEach {
        options.encoding = "UTF-8"
        options.release.set 21
    }

    java {
        withSourcesJar()
    }

    publishing {
        repositories {
        }
    }
}