I want to generate BUILD files for actually compiling code in the main workspace.
To some extend I am looking at rebuilding something similar to Maven polyglot (1). We do have a Maven extension that let developers write a simplified yaml file for dependency management. The Maven extension translates that into a full blown Maven module POM at Maven runtime. The generated pom.xml only exists temporarily on disc and is deleted when the Maven process exits.
For Bazel I can only think of two separate processes right now:
a) Run a tool to generate BUILD files
b) Bazel build //...
That leaves users with the issues of cleanup and accidental commits, etc. Ideally I would like to avoid having users run two different processes. Hence my investigation of a repository rule. But when defining this a repository I would loose the ability to reference dependencies between Bazel packages generated from the repository rule and the main workspace easily, i.e. users hand writing BUILD files would need to know which packages come from the repository and which don't.
To some extend it's similar to dynamic dependencies, which is not supported in Bazel yet.