We currently resolve the main class for bootJar, bootRun, and bootWar using subtly different class paths. Each time a subtly different class path is used, there's a small change that a different main class will be resolved which could lead to very confusing behaviour. If we follow the current pattern, the introduction of AOT support will make the situation worse by adding a fourth, subtly different, class path into the mix.

We could simplify things considerably if, by default, we always used the same class path to resolve the main class. I think it would be sufficient for this class path to be the outputs of the main source set. If this proves to be insufficient in some isolated cases, users can configure the class path used by the resolveMainClassName task to suit their needs.