Closed madchicken closed 12 years ago
Looks good, but I have trouble getting the changes to work with the provided compilerOptions. I get this error in my test project:
012-10-31 20:07:43,579 [localhost-startStop-1] ERROR plugins.DefaultGrailsPluginManager - Error configuring dynamic methods for plugin [resources:1.2-RC1]: Cannot cast object '{}' with class 'groovy.util.ConfigObject' to class 'com.google.javascript.jscomp.CompilerOptions$LanguageMode' due to: groovy.lang.GroovyRuntimeException: Could not find matching constructor for: com.google.javascript.jscomp.CompilerOptions$LanguageMode(groovy.util.ConfigObject)
org.codehaus.groovy.runtime.typehandling.GroovyCastException: Cannot cast object '{}' with class 'groovy.util.ConfigObject' to class 'com.google.javascript.jscomp.CompilerOptions$LanguageMode' due to: groovy.lang.GroovyRuntimeException: Could not find matching constructor for: com.google.javascript.jscomp.CompilerOptions$LanguageMode(groovy.util.ConfigObject)
at org.grails.plugin.gccresources.GoogleClosureCompilerResourceMapper$_map_closure1.doCall(GoogleClosureCompilerResourceMapper.groovy:35)
at org.grails.plugin.gccresources.GoogleClosureCompilerResourceMapper.map(GoogleClosureCompilerResourceMapper.groovy:33)
at org.grails.plugin.resource.mapper.ResourceMapper.invoke(ResourceMapper.groovy:139)
.....
When i use the following CompilerOption it works fine:
prettyPrint: true
Any ideas why it is causing an error?
Uhm, I can't reproduce the issue: just tried both with:
grails.resources.mappers.googleclosurecompiler.compilerOptions = [ prettyPrint: true ]
and
grails.resources.mappers.googleclosurecompiler.compilerOptions.prettyPrint = true
and it works as expected. Did you use another syntax?
Maybe it wasn't entirely clear. It's when I use the example you provided it fails for me (the prettyPrint option works):
grails.resources.mappers.googleclosurecompiler.compilerOptions = [
languageIn: CompilerOptions.LanguageMode.ECMASCRIPT5
]
Really don't know: the config pasted is the same I'm using for a project I'm currently developing. Maybe a missing import in Config.groovy? You should have
import com.google.javascript.jscomp.CompilerOptions
in the beginning of the file.
Yeah, that solved the issue :P
Thanks for the contribution!
I'll try to release the updated plugin to the grails repo within the week.
This allows to add compiler options in the configuration. I also used default resource mapper config object to adhere other plugin standard.
Now it's possible to add custom compiler configuration by adding them to the configuration:
If you want specify compiler options for a single file, it can be done using the attrs map in the ApplicationResource file: