raphiz / buildGradleApplication

A Nix builder function for packaging Gradle applications.
MIT License
23 stars 2 forks source link

Extract Repositories from `settings.gradle.kts` #7

Open raphiz opened 8 months ago

raphiz commented 8 months ago

Currently, the Repositories must be hard coded twice, once in the settings.gradle.kts and once in nix. It would be nice if the nix expression could extract the Repositories used from the settings.gradle.kts

raphiz commented 1 month ago

Using an IFD + Gradle init script should work. Here is a quick proof of concept:

gradle -q -I ./listRepositories.gradle listRepositories
// listRepositories.gradle
gradle.settingsEvaluated { settings ->
    rootProject {
        tasks.register("listRepositories") {
            doLast {
                settings.pluginManagement.repositories.forEach { repo ->
                    if(repo.url != null) println(repo.url)
                }
                settings.dependencyResolutionManagement.repositories.forEach { repo ->
                    if(repo.url != null) println(repo.url)
                }
            }
        }
    }
}