`grails-markup` does not support g.render(), g.link(), etc
- Dominant language
- Groovy
- Stars
- 2.9k
- Forks
- 975
- Avg merge
- 1d 22h
- Merged PRs (30d)
- 92
Description
### Issue description
In https://github.com/apache/grails-core/issues/14804 it was discovered that the markup plugin fails if g.render() is called as a grails-forge app would generate for the object.gml:
> Task :compileGmlViews FAILED
Exception in thread "main" java.util.concurrent.ExecutionException: org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
grails_markup_plugin_issue_object__object_gml: 6: [Static type checking] - Cannot find matching method java.lang.Object#render(java.lang.Object). Please check if the declared type is correct and if the method exists.
@ line 6, column 1.
g.render(object)
^
1 error
at java.base/java.util.concurrent.FutureTask.report(FutureTask.java:122)
at java.base/java.util.concurrent.FutureTask.get(FutureTask.java:191)
at grails.views.AbstractGroovyTemplateCompiler.compile(AbstractGroovyTemplateCompiler.groovy:128)
at grails.views.AbstractGroovyTemplateCompiler.run(AbstractGroovyTemplateCompiler.groovy:184)
at grails.plugin.markup.view.MarkupViewCompiler.main(MarkupViewCompiler.groovy:62)
Caused by: org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
grails_markup_plugin_issue_object__object_gml: 6: [Static type checking] - Cannot find matching method java.lang.Object#render(java.lang.Object). Please check if the declared type is correct and if the method exists.
@ line 6, column 1.
g.render(object)
^
I've added functional tests here: https://github.com/apache/grails-core/tree/markup-issue to reproduce this issue.
`getG()` off of the template base class doesn't appear to be found and is the likely cause of this.
This appears to have been broken in 6.x too: https://github.com/jdaugherty/markup-grails-6-compile-issue
And per user feedback, it was also broken in prior Grails versions back to 3.3. (3.3.18, 4.1.4, 5.0.3 were all tested)
Contributor guide
Research direction
Start by reproducing the compileGmlViews failure with the functional tests on the markup-issue branch. Read grails.views.AbstractGroovyTemplateCompiler.groovy, grails.plugin.markup.view.MarkupViewCompiler.groovy, and the template base class around getG(); done means markup templates can compile calls such as g.render() and g.link() without the reported static type-checking error.
Written by the indexing model from the issue text.
Assessment
- Domain
- web-dev
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100