I have an android project with like 10 modules. I...
# community-support
c
I have an android project with like 10 modules. I want to sort dependencies in those modules via https://github.com/square/gradle-dependencies-sorter but unsure of how best to apply the plugin at the root, and then call a single command to check/apply sorting. I was able to get the sorter plugin to work by adding it to my app module, but then I also had to call
app:sortDependencies
. I want to make this behave like spotless plugin where I apply it to my root build.gradle and then call
./gradlew spotlessApply
and every module runs the spotless formatter.
v
./gradlew sortDependencies
(opposed to
./gradlew :sortDependencies
) runs the
sortDependencies
task in every project that has one with that name. So by applying to the relevant projects you already have what you are after.
c
oh. TIL! Is there a way to just apply the plugin once, and have it applied to all of my modules?
v
Have a convention plugin that is applied to all the modules and apply it there. Everything else is highly discouraged
c
darn. overhead to adding a convention plugin at the moment is kinda high. i wonder how spotless ends up doing it. i apply spotless in the root project and that's it.
v
Adding a convention plugin usually shouldn't really be high overhead. But just for applying one plugin it is not really helpful anyway unless you plan to add more things later. You could then also directly apply that plugin.
i wonder how spotless ends up doing it. i apply spotless in the root project and that's it.
Then I'd say you only run it on the root project. It does not register any tasks besides those on the root project, I just looked at the code and also tried.
👍 1