pluginManagement {
    repositories {
        val composeRepoProperties = java.util.Properties().apply {
            val propertiesFile = rootDir.parentFile.parentFile.resolve("local.properties")
            if (propertiesFile.isFile) propertiesFile.inputStream().use(::load)
        }
        composeRepoProperties.getProperty("COMPOSE_REPO_URL")
            ?.takeIf(String::isNotBlank)
            ?.let { repoUrl ->
                maven(repoUrl) {
                    credentials {
                        username = composeRepoProperties.getProperty("COMPOSE_REPO_USERNAME")
                        password = composeRepoProperties.getProperty("COMPOSE_REPO_KEY")
                    }
                }
            }
        maven("https://maven.eazytec-cloud.com/nexus/repository/maven-inner/")
        maven("https://maven.eazytec-cloud.com/nexus/repository/maven-public/")
        mavenCentral {
            url = uri("https://cache-redirector.jetbrains.com/maven-central")
        }
        gradlePluginPortal()
    }
}

dependencyResolutionManagement {
    repositories {
        val composeRepoProperties = java.util.Properties().apply {
            val propertiesFile = rootDir.parentFile.parentFile.resolve("local.properties")
            if (propertiesFile.isFile) propertiesFile.inputStream().use(::load)
        }
        composeRepoProperties.getProperty("COMPOSE_REPO_URL")
            ?.takeIf(String::isNotBlank)
            ?.let { repoUrl ->
                maven(repoUrl) {
                    credentials {
                        username = composeRepoProperties.getProperty("COMPOSE_REPO_USERNAME")
                        password = composeRepoProperties.getProperty("COMPOSE_REPO_KEY")
                    }
                }
            }
        maven("https://maven.eazytec-cloud.com/nexus/repository/maven-inner/")
        maven("https://maven.eazytec-cloud.com/nexus/repository/maven-public/")
        maven("https://packages.jetbrains.team/maven/p/cmp/dev") {
            content {
                includeGroupByRegex("org.jetbrains.compose.internal.*")
                includeModuleByRegex("org.jetbrains", ".*space.*")
            }
        }

        google {
            mavenContent {
                includeGroupByRegex(".*android.*")
                includeGroupByRegex(".*google.*")
            }
        }

        gradlePluginPortal {
            content {
                includeGroupByRegex(".*com\\.gradle.*")
                includeGroupByRegex(".*org\\.gradle.*")
                includeModule("org.jetbrains.kotlinx", "kotlinx-benchmark-plugin")
            }
        }

        mavenCentral {
            url = uri("https://cache-redirector.jetbrains.com/maven-central")
        }
    }

    versionCatalogs {
        register("libs") {
            from(files("../../dependencies.toml"))
        }
    }
}
