littlerobots / version-catalog-update-plugin

Gradle plugin for updating a project version catalog
Apache License 2.0
544 stars 22 forks source link

allow setting the order of sections #113

Closed FyiurAmron closed 12 months ago

FyiurAmron commented 1 year ago

Currently, the order matches the "official" one, provided by Gradle/Android docs (i.e.

the [versions] section is used to declare versions which can be referenced by dependencies

the [libraries] section is used to declare the aliases to coordinates

the [bundles] section is used to declare dependency bundles

the [plugins] section is used to declare plugins

, however, the usual order in the build scripts is to have plugins declared before the libraries. Also, there are less plugins and they are somewhat more important - that's probably why https://github.com/Splitties/refreshVersions uses that "swapped" ordering by default, so maybe we could just provide a config option to allow setting the order of the sections by the user?

At first glance it looks that just refactoring https://github.com/littlerobots/version-catalog-update-plugin/blob/main/catalog/src/main/kotlin/nl/littlerobots/vcu/VersionCatalogWriter.kt#L29 into 4 sub-functions that would be matched and executed in order based on config would do the trick.

hvisser commented 1 year ago

What I was planning to do is to just keep the order of the tables to whatever they were. It came up before that someone had a preferred order.

FyiurAmron commented 1 year ago

@hvisser yeah, that also seems like a completely acceptable solution, I guess it would be on par with UX, since both ways are simple and straightforward enough.