matrei opened a new pull request, #16433: URL: https://github.com/apache/grails-core/pull/16433
## Description Fixes #16431. `runCommand`, `runScript`, `console`, `shell` and the application command tasks, such as `configReport`, are registered in every Grails project. They run against the application, using the application class found by `findMainClass`. In a project without one, such as a plugin, the provider of that class has no value, and the tasks failed with Gradle's generic error: ``` > Cannot query the value of this provider because it has no value available. ``` Whether a project has an application class is only known once `findMainClass` has run, which is after the tasks are registered, so the tasks stay registered. Instead, they now fail with a message that names what is missing, in line with what `FindMainClassTask` already logs for plugins: ``` > The 'runCommand' task requires an application class with a main method, but none was found. Add an Application class, or set 'springBoot.mainClass' if the project already has one. ``` The five call sites that read the main class in `GrailsCliGradlePlugin` now go through a shared `requireMainClass` helper. ### Tests `MainClassRequiredSpec` runs `runCommand`, `runScript`, `console` and `shell` in a plugin without an application class (`test-projects/main-class-required`) and checks the message. The application command tasks are not registered in that test build, since no command factories are on its classpath, but they use the same helper. The spec fails without the change and passes with it. `:grails-gradle-plugins:test` (317 tests) and `:grails-gradle-plugins:codeStyle` pass. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
