plugins {
    id 'dev.architectury.loom' version '1.10-SNAPSHOT'
    id 'maven-publish'
    id 'com.github.johnrengelman.shadow' version '8.1.1'
}

group = project.maven_group
version = project.mod_version

base {
    archivesName = project.archives_name
}

loom {
    silentMojangMappingsLicense()

    forge {
        mixinConfig 'extendedae_plus.mixins.json'
    }

    runs {
        client1 {
            client()
            name "Client 1"
            runDir "run/client1"
            programArgs "--username", "Player1"
        }
    }
}

repositories {
    flatDir {
        dirs 'libs'
    }
    mavenLocal()
    mavenCentral()
    maven {
        url = "https://cursemaven.com"
        content {
            includeGroup "curse.maven"
        }
    }
    maven {
        url = "https://maven.blamejared.com/"
    }
    maven {
        url = "https://dvs1.progwml6.com/files/maven/"
    }
    maven {
        name = "Modmaven"
        url = "https://modmaven.dev/"
    }
    maven {
        url "https://maven.shedaniel.me/"
        content {
            includeGroup "me.shedaniel"
            includeGroup "me.shedaniel.cloth"
            includeGroup "dev.architectury"
        }
    }
    maven { url "https://repo.spongepowered.org/maven" }
    maven { url "https://dl.cloudsmith.io/public/geckolib3/geckolib/maven/" }
}

dependencies {
    minecraft "net.minecraft:minecraft:${minecraft_version}"
    mappings loom.officialMojangMappings()
    forge "net.minecraftforge:forge:${forge_version}"

    //exendedae前置
    modImplementation "curse.maven:glodium-957920:${glodium_version}"
    //extendedAE
    modImplementation files('libs/ExtendedAE-1.20-1.4.2-forge.jar')
    modRuntimeOnly fileTree(dir: 'libs', includes: ['*.jar'])

    //ae2
    modImplementation "appeng:appliedenergistics2-forge:${ae2_version}"
    modImplementation "org.appliedenergistics:guideme:${guideme_version}"
    modCompileOnly "curse.maven:applied-energistics-2-wireless-terminals-459929:${wireless_terminals_version}"

    modCompileOnly "mezz.jei:jei-${minecraft_version}-forge:${jei_version}"

    annotationProcessor "org.spongepowered:mixin:${mixin_version}:processor"

    modImplementation "curse.maven:applied-flux-965012:6755986"
    modCompileOnly "curse.maven:mega-cells-622112:${mega_cells_version}"
    modCompileOnly "curse.maven:jade-324717:${jade_version}"

    // GregTech
    modCompileOnly "curse.maven:gregtechceu-modern-890405:${gregtech_version}"
    modCompileOnly "curse.maven:ldlib-626676:${ldlib_version}"

    //curios
    modRuntimeOnly "curse.maven:curios-309927:${curios_version}"
    modCompileOnly "curse.maven:curios-309927:${curios_version}"

    // Runtime test
    modRuntimeOnly "curse.maven:curios-309927:${curios_version}"
    modRuntimeOnly "curse.maven:jade-324717:${jade_version}"
    modRuntimeOnly "curse.maven:architectury-api-419699:${architectury_version}"
    modRuntimeOnly "curse.maven:applied-energistics-2-wireless-terminals-459929:${wireless_terminals_version}"
    modRuntimeOnly "mezz.jei:jei-${minecraft_version}-forge:${jei_version}"
    modRuntimeOnly "curse.maven:cloth-config-348521:5729105"

    //jec
    modCompileOnly "curse.maven:just-enough-characters-250702:6680042"


    //mae2
  //  modRuntimeOnly "curse.maven:modern-ae2-additions-1028068:6827727"
    modCompileOnly "curse.maven:modern-ae2-additions-1028068:6827727"

    //aea
    modImplementation "curse.maven:advancedae-1084104:6939473"

    //geckolib
    modRuntimeOnly "curse.maven:geckolib-388172:6920925"
    //mclib运行时
    forgeRuntimeLibrary "com.eliotlash.mclib:mclib:20"

    // compileOnly 供代码编译
    include "curse.maven:configuration-444699:4710266"
    modImplementation "curse.maven:configuration-444699:4710266"

    //ftbteams
    modCompileOnly "curse.maven:ftb-teams-forge-404468:6130786"
    modCompileOnly "curse.maven:ftb-library-forge-404465:6807424"
    modRuntimeOnly "curse.maven:ftb-teams-forge-404468:6130786"
    modRuntimeOnly "curse.maven:ftb-library-forge-404465:6807424"
}

allprojects {
    tasks.withType(JavaCompile).configureEach {
        options.compilerArgs << "-Xlint:-deprecation"
    }
}

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

    filesMatching('META-INF/mods.toml') {
        expand version: project.version
    }
}

java {
    // Loom will automatically attach sourcesJar to a RemapSourcesJar task and to the "build" task
    // if it is present.
    // If you remove this line, sources will not be generated.
    withSourcesJar()

    sourceCompatibility = JavaVersion.VERSION_17
    targetCompatibility = JavaVersion.VERSION_17
}

// 将 LICENSE 打包进发布的 jar
tasks.named('jar', Jar).configure {
    from('.') {
        include 'LICENSE'
    }
}

tasks.withType(JavaCompile).configureEach {
    it.options.release = 17
}

// Configure Maven publishing.
publishing {
    publications {
        mavenJava(MavenPublication) {
            from components.java
            pom {
                licenses {
                    license {
                        name = 'GNU Lesser General Public License v3.0'
                        url = 'https://www.gnu.org/licenses/lgpl-3.0.en.html'
                        distribution = 'repo'
                    }
                }
            }
        }
    }

    // See https://docs.gradle.org/current/userguide/publishing_maven.html for information on how to set up publishing.
    repositories {
        // Add repositories to publish to here.
        // Notice: This block does NOT have the same function as the block in the top level.
        // The repositories here will be used for publishing your artifact, not for
        // retrieving dependencies.
    }
}
