How to use multiple gradle packages in Android project

We have a lot of internal packages hosted via GitHub Enterprise packages. I’m looking for a nice way of authenticating to the various package repositories at once and exposing many packages. Our current setup includes multiple maven {...} declarations and I’m hoping to get it down to one. Maybe I need to look at creating a custom Gradle plugin similar to mavenCentral?

Example in settings.gradle.kts for an Android project:

dependencyResolutionManagement {
    repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
    repositories {
        google()
        mavenCentral()
        maven {
            name = "GitHubPackages"
            url = uri("https://git.customdomain.com/_registry/maven/org/package2")

            credentials {
                username = System.getenv("USERNAME")
                password = System.getenv("TOKEN")
            }
        }
        maven {
            name = "GitHubPackages"
            url = uri("https://git.customdomain.com/_registry/maven/org/package1")

            credentials {
                username = System.getenv("USERNAME")
                password = System.getenv("TOKEN")
            }
        }
    }
}

rootProject.name = "example-app"
include(":app")

Would become something like:

dependencyResolutionManagement {
    repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
    repositories {
        google()
        mavenCentral()
        maven {
            name = "GitHubPackages"
            urls = listOf(
              uri("https://git.customdomain.com/_registry/maven/org/package2"),
              uri("https://git.customdomain.com/_registry/maven/org/package1"),
              uri("https://git.customdomain.com/_registry/maven/org/package3")
            )

            credentials {
                username = System.getenv("USERNAME")
                password = System.getenv("TOKEN")
            }
        }
    }
}

rootProject.name = "example-app"
include(":app")