Closed jeffscottbrown closed 4 days ago
in the build.gradle
, you should add the mainClass path.
application {
mainClass.set("t621.Application")
}
But even with this path set, it does not work, stating:
> Task :runCommand FAILED
| Error Command not found for name: <name-of-the-command>
I can provide a test case if needed. I think a dependency is missing in my case (using default create-app deps).
I can provide a test case if needed.
Thank you @Taack!
It is working from ./grailsw
or IntelliJ Grails Run Command.
grails> url-mappings-report
> Task :urlMappingsReport
Grails application running at http://localhost:0 in environment: development
Dynamic Mappings
| * | ERROR: 404 | View: /notFound |
| * | ERROR: 500 | View: /error |
| * | / | View: /index |
| * | /${controller}/${action}?/${id}?(.${format)? | Action: (default action) |
BUILD SUCCESSFUL in 10s
6 actionable tasks: 3 executed, 3 up-to-date
It does not appear that url-mappings-report has been migrated to work with ./gradlew runCommand.
Interesting, it does appear to work if I generate the app explicitly requesting JDK 11.
% sdk use grails 6.2.1
% sdk use java 11.0.22-zulu
% grails create-app --jdk=11 demoapp
% cd demoapp
% ./gradlew runCommand -Pargs="url-mappings-report"
> Task :runCommand
Grails application running at http://localhost:0 in environment: development
Dynamic Mappings
| * | ERROR: 404 | View: /notFound |
| * | ERROR: 500 | View: /error |
| * | / | View: /index |
| * | /${controller}/${action}?/${id}?(.${format)? | Action: (default action) |
BUILD SUCCESSFUL in 5s
6 actionable tasks: 5 executed, 1 from cache
in the build.gradle, you should add the mainClass path.
I don't think that is the issue. The generated build file does contain the following...
application {
mainClass.set("demoapp.Application")
}
Interesting, it does appear to work if I generate the app explicitly requesting JDK 11.
I have also verified that it appears to work when using JDK 17. I think the initial error reported above may be just a misleading indicator, and the JDK version incompatibility may be the root cause. When I filed the ticket I overlooked the fact that the source compatibility expressed in build.gradle is set to 17 by default when the app is created using create-app.
https://github.com/grails/grails-forge/issues/383 is related the Java version issue.
I think a dependency is missing in my case (using default create-app deps).
@Taack Do you know which dependency that is?
@jamesfredley Do you feel that as far as we know, runCommand is working fine, and this report would be eligible to close as not-a-bug?
@osscontributor I do believe we can attribute this to Java version and close it.
It is working from
./grailsw
or IntelliJ Grails Run Command.grails> url-mappings-report > Task :urlMappingsReport Grails application running at http://localhost:0 in environment: development Dynamic Mappings | * | ERROR: 404 | View: /notFound | | * | ERROR: 500 | View: /error | | * | / | View: /index | | * | /${controller}/${action}?/${id}?(.${format)? | Action: (default action) | BUILD SUCCESSFUL in 10s 6 actionable tasks: 3 executed, 3 up-to-date
@jamesfredley Unfortunately, the Grails wrapper does not seem to work correctly in our case, because of our project's layout. See modular directory layout
Our layout:
intranet/grailsw
intranet/gradle*
intranet/server <- Grails main AND commands
intranet/app <- Apps plugin
Using gradlew we need to pass the gradle module where the command is, we cannot launch the command from server
directly, unless we change all the completely the build:
./gradlew server:runCommand -Pargs="some-name"
I do not know how to do the same using the Grails Wrapper...
@Taack it sounds like we have this solved for ./gradlew server:runCommand -Pargs="some-name"
, by ensuring the java version matches the one generated in build.gradle.
If you would also like to run this from grails-shell CLI for a multi-project build:
Grails-wrapper: I believe you would want to place the grails wrapper files in /server and /app and make the necessary configuration available which grails wrapper requires to start.
props.load(new FileInputStream("gradle.properties"))
grailsVersion = props.getProperty("grailsVersion")
grailsShellVersion = props.getProperty("grailsShellVersion")
groovyVersion = props.getProperty("groovyVersion")
or run from IntelliJ Run Grails Command:
Expected Behavior
The gradle runCommand task should work.
Actual Behaviour
In a default generated app, runCommand generates an error.
Steps To Reproduce
Invoke the runCommand task in a Grails 6.2.1 app.
Environment Information
No response
Example Application
No response
Version
6.2.1