plugins {
    id 'dev.architectury.loom' version '1.10-SNAPSHOT'
    id 'maven-publish'
}

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" }
}

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')

    //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"

    modCompileOnly "curse.maven:applied-flux-965012:${applied_flux_version}"
    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"
}

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.
    }
}
