matrei opened a new issue, #16431:
URL: https://github.com/apache/grails-core/issues/16431
### Versions
- Grails 8.0.0-RC2
- Gradle 9.8.0
- Java 21
### Description
The Grails Gradle plugin registers the `configReport` task, and the other
application command tasks, in every Grails
project, including plugin projects
(`org.apache.grails.gradle.grails-plugin`) that have no application class.
These tasks run `GrailsApplicationContextCommandRunner`, which loads the
application class found by `findMainClass`
and uses it as the source of the application context the command runs in. In
a project without an application class
there is nothing to find, and the task fails with a generic Gradle provider
error that does not say what is missing:
```
Execution failed for task ':configReport' (registered by plugin class
'org.grails.gradle.plugin.commands.GrailsCliGradlePlugin').
> Cannot query the value of this provider because it has no value available.
```
```
Caused by: org.gradle.api.internal.provider.MissingValueException: Cannot
query the value of this provider because it has no value available.
at
org.gradle.api.internal.provider.AbstractMinimalProvider.get(AbstractMinimalProvider.java:100)
at
org.grails.gradle.plugin.commands.GrailsCliGradlePlugin$_configureApplicationCommands_closure12$_closure19$_closure20.doCall(GrailsCliGradlePlugin.groovy:401)
```
### Steps to reproduce
1. Take a Grails plugin project without an application class (no
`grails-app/init/.../Application.groovy`).
2. Run `./gradlew configReport`.
### Expected
Either the application command tasks are not registered for a project
without an application class, or they fail with
a message saying that they have to be run in a Grails application.
### Actual
The task fails with `Cannot query the value of this provider because it has
no value available.`
### Cause
`GrailsCliGradlePlugin.configureApplicationCommands` adds the main class to
the arguments in `doFirst` with
`appClassProvider.get()`. `GrailsGradlePlugin.getMainClassProvider` has no
value when `findMainClass` found no main
class, so `get()` throws `MissingValueException`.
### Possible fixes
- Register the application command tasks only for projects that have an
application class.
- Or check `appClassProvider.isPresent()` in `doFirst` and throw a
`GradleException` with a clear message, for example:
"The configReport task requires a Grails application with an Application
class."
--
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]