grails / grails-gradle-plugin-archived

142 stars 40 forks source link

Grails args aren't being honored by grails launcher #20

Open ellerycrane opened 11 years ago

ellerycrane commented 11 years ago

Setting grails args using -Pargs="" or setting the args property explicitly in your GrailsTask configuration does not seem to carry over to the grails launcher. For instance:

gradle -Pargs="--verbose --stacktrace" grails-run-app

The preceding command fails when the app hits an OutOfMemoryError, yielding following log lines:

| Error PermGen space (NOTE: Stack trace has been filtered. Use --verbose to see entire trace.)
java.lang.OutOfMemoryError: PermGen space
| Error Server failed to start: java.lang.OutOfMemoryError: PermGen space

I would have expected the --verbose arg to have been passed through to the grails command, but it is not.

ellerycrane commented 11 years ago

The fault for this appears to be in the GrailsScriptRunner; the GrailsLauncher is calling this executeCommand:

public int executeCommand(String scriptName, String args) {
    return executeCommand(scriptName, args, null);
}

Normally, the GrailsScriptRunner's main() method is invoked, which sets up the CommandLine instance differently- namely, it calls the private processArgumentsAndReturnScriptName() method, which is what processes the 'verbose' and 'stacktrace' command line arguments. This is not called from the executeCommand method invoked by the launcher, which is why those two arguments are not being set properly. We could work around this by processing these arguments manually on the GrailsConsole instance, though the GrailsScriptLoader should also be fixed so this is unnecessary.

ellerycrane commented 11 years ago

I have also created an issue on the Grails Jira for this problem.

ldaley commented 11 years ago

This needs to be fixed in Grails for sure, but we can workaround this in Grails launcher for existing Grails version. See the workaround for interactive mode in DelegatingGrailsLaunchContext.

justenwalker commented 10 years ago

It's been almost a year with no activity. Is it difficult to add the work-around to grails-launcher?