Looking at #32919 has shown that the way that the classpath of the processAot and processTestAot is configured is not ideal. At the moment, AOT tasks are configured to use the compile classpath of the source set that they populate as their classpath:
https://github.com/spring-projects/spring-boot/blob/ec0d598ba43fa235c8022aa4c782916b031b5a70/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/main/java/org/springframework/boot/gradle/plugin/SpringBootAotPlugin.java#L135
This doesn't feel right as it creates a bidirectional relationship between the processAot and the aot source set and processTestAot and the aotTest source set. This is likely to cause a cycle between tasks and that's exactly what happens when trying to fix #32919.
Both processAot and processTestAot should be configured with their own classpaths that are independent of the aot and aotTest source sets.