/*
 * Super Resolution
 * Copyright (c) 2025. 187J3X1-114514
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <https://www.gnu.org/licenses/>.
 */

import groovy.json.JsonSlurper

pluginManagement {
    repositories {
        if (System.getenv().containsKey("SR_DEV")) {
            maven {
                name "minecraftdevRepository"
                url "http://127.0.0.1:8080/releases"
            }
        }
        gradlePluginPortal()
        mavenCentral()
        maven { url 'https://maven.neoforged.net' }
        maven { url "https://maven.fabricmc.net/" }
        maven { url 'https://maven.aliyun.com/repository/central' }
        maven { url 'https://maven.aliyun.com/repository/gradle-plugin' }
        maven { url "https://maven.shedaniel.me/" }
        maven { url "https://libraries.minecraft.net" }
        maven { url 'https://repo.spongepowered.org/repository/maven-public' }
        maven { url 'https://maven.parchmentmc.org/' }
    }
}

plugins {
    id 'org.gradle.toolchains.foojay-resolver-convention' version '0.8.0'
}
rootProject.name = 'superresolution'
include('common')
include('native')
gradle.ext.set(
        "versionConfigSrc",
        new JsonSlurper().parse(
                new File("$rootDir/configs/" + "$minecraft_version_config" + ".json")
        )
)
rootProject.properties.put("minecraft_version", gradle.ext.versionConfigSrc.common.minecraft_version)
gradle.ext.set("minecraft_version", gradle.ext.versionConfigSrc.common.minecraft_version)
println("❇️ 当前Minecraft版本 $gradle.ext.versionConfigSrc.common.minecraft_version")
for (loader in gradle.ext.versionConfigSrc.common.platforms) {
    def loaderName = loader.strip()
    if (loaderName.isEmpty() || loaderName.isBlank()) continue
    println "❇️ 已启用加载器 " + loaderName
    include(loaderName)
}