Decouple several Gradle modules
This is the first of some refactorings that decouple some of the modules. Some of those were unnecessary, some needed some simple refactoring, some needed more tweaking. I also moved on legacy controller into its own package, mostly to reduce the surface of the dependency on the IDM module, which is subject to change.
It should be straightforward if you follow the individual commits.