brian428 / grails-coffeescript-compiler-plugin Goto Github PK
View Code? Open in Web Editor NEWA simple Grails plugin that compiles .coffee source files into JavaScript files under web-app/js.
A simple Grails plugin that compiles .coffee source files into JavaScript files under web-app/js.
In documentation said:
The default compiler uses a bundled version of Rhino, but if you have node coffee-script installed that will be used instead. Hopefully this does not cause any variances amongst environments with and without node coffee-script, but note that it COULD.
Maybe it would be good to create an option for explicit selecting of compiler?
For example I don't want to use nodejs installed on my system and I prefer to use Rhyno.
Also I can't find any log messages that shows which compiler was used.
I am having this very strange output for some time. Although it says an error occured, my resources get compiled and reloaded into application properly.
It is only happening when the app is running and I update the original coffee file.
Application works but there might be something wrong, so if you could check on that, I would appreciate it. Thanks
The error has actually two steps:
By modyfing the coffee file, this is printed
grails> 2013-03-07 22:15:56,798 [Thread-10] INFO compiler.CoffeeCompiler - Compiling ...\src\coffee\user_index.coffee to ...\web-app\cs\user_index.js
| Error 2013-03-07 22:15:57,110 [main] ERROR util.ProxyFactory - exception
Message: interface ro.isdc.wro.config.ReadOnlyContext is not visible from class loader
Line | Method
->> 73 | create in ro.isdc.wro.util.ProxyFactory
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
| 49 | proxy in ''
| 272 | createReadOnlyContextProxy in ro.isdc.wro.model.group.processor.InjectorBuilder
| 126 | initMap in ''
| 290 | build . . . . . . . . . . in ''
| 65 | compileFile in org.grails.plugins.coffee.compiler.CoffeeCompiler
| 67 | compileFileFromConfig . . in org.grails.plugins.coffee.compiler.CoffeeCompilerManager
| 102 | doCall in CoffeescriptCompilerGrailsPlugin$_closure2
| 80 | run . . . . . . . . . . . in org.grails.plugins.tomcat.fork.ForkedTomcatServer
^ 56 | main in ''
| Error 2013-03-07 22:15:57,389 [main] ERROR compiler.CoffeeCompiler - Generic Exception: interface ro.isdc.wro.config.ReadOnlyContext is not visible from class loader in ...\src\coffee\user_index.coffee
| Error 2013-03-07 22:15:57,436 [main] ERROR plugins.AbstractGrailsPluginManager - Plugin [coffeescriptCompiler:0.9] could not reload changes to file [...\src\coffee\user_index.coffee]: interface ro.isdc.wro.config.ReadOnlyContext is not visible from class loader
Message: interface ro.isdc.wro.config.ReadOnlyContext is not visible from class loader
Line | Method
->> 87 | compileFile in org.grails.plugins.coffee.compiler.CoffeeCompiler
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
| 67 | compileFileFromConfig in org.grails.plugins.coffee.compiler.CoffeeCompilerManager
| 102 | doCall . . . . . . . in CoffeescriptCompilerGrailsPlugin$_closure2
| 80 | run in org.grails.plugins.tomcat.fork.ForkedTomcatServer
^ 56 | main . . . . . . . . in ''
Caused by IllegalArgumentException: interface ro.isdc.wro.config.ReadOnlyContext is not visible from class loader
->> 73 | create in ro.isdc.wro.util.ProxyFactory
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
| 49 | proxy in ''
| 272 | createReadOnlyContextProxy in ro.isdc.wro.model.group.processor.InjectorBuilder
| 126 | initMap in ''
| 290 | build . . . . . . . . in ''
| 65 | compileFile in org.grails.plugins.coffee.compiler.CoffeeCompiler
| 67 | compileFileFromConfig in org.grails.plugins.coffee.compiler.CoffeeCompilerManager
| 102 | doCall in CoffeescriptCompilerGrailsPlugin$_closure2
| 80 | run . . . . . . . . . in org.grails.plugins.tomcat.fork.ForkedTomcatServer
^ 56 | main in ''
This is immediately followed by NullPointerException.
Actually I can get this very same exception if I do modify the compiled js files manually:
Resource reload failed!:
java.lang.NullPointerException: Cannot get property 'grailsResourceProcessor' on null object
at org.codehaus.groovy.runtime.NullObject.getProperty(NullObject.java:56)
at org.codehaus.groovy.runtime.InvokerHelper.getProperty(InvokerHelper.java:169)
at org.codehaus.groovy.runtime.callsite.NullCallSite.getProperty(NullCallSite.java:44)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callGetProperty(AbstractCallSite.java:227)
at ResourcesGrailsPlugin$_closure4_closure20.doCall(ResourcesGrailsPlugin.groovy:212)
at ResourcesGrailsPlugin$_closure4_closure20.doCall(ResourcesGrailsPlugin.groovy)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:601)
at org.springsource.loaded.ri.ReflectiveInterceptor.jlrMethodInvoke(ReflectiveInterceptor.java:1243)
at org.codehaus.groovy.runtime.callsite.PogoMetaMethodSite$PogoCachedMethodSiteNoUnwrapNoCoerce.invoke(PogoMetaMethodSite.java:272)
at org.codehaus.groovy.runtime.callsite.PogoMetaMethodSite.call(PogoMetaMethodSite.java:64)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:45)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:108)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:112)
at ResourcesGrailsPlugin$_triggerReload_closure7.doCall(ResourcesGrailsPlugin.groovy:199)
at ResourcesGrailsPlugin$_triggerReload_closure7.doCall(ResourcesGrailsPlugin.groovy)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:601)
at org.springsource.loaded.ri.ReflectiveInterceptor.jlrMethodInvoke(ReflectiveInterceptor.java:1243)
at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:90)
at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:233)
at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1076)
at groovy.lang.ExpandoMetaClass.invokeMethod(ExpandoMetaClass.java:1110)
at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:906)
at groovy.lang.Closure.call(Closure.java:415)
at ResourcesGrailsPlugin$_triggerReload_closure7.call(ResourcesGrailsPlugin.groovy)
at groovy.lang.Closure.call(Closure.java:409)
at ResourcesGrailsPlugin$_triggerReload_closure7.call(ResourcesGrailsPlugin.groovy)
at groovy.lang.Closure.run(Closure.java:493)
at ResourcesGrailsPlugin$_triggerReload_closure7.run(ResourcesGrailsPlugin.groovy)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
at java.util.concurrent.FutureTask.run(FutureTask.java:166)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:178)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:292)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
at java.lang.Thread.run(Thread.java:722)
Thanks for any help or idea how to fix.
I will try to put the NullPointerException as an issue to resources plugin to see if there is not anything wrong
Lets say i have configred coffee compiler plugin in my app - app has two plugins installed both of the plugins has coffee files. Is there a way to have the coffee files inside the plugins to compiler automatically when compiling/running the main app? so that the plugins doesnt have to include the generated js files but just the coffess files. (with support for inline plugins)
During initialization my resource is not compiled.
My coffee resource is only one line (just to test the functionality) and is located at src/coffee/app:
alert "Hello CoffeeScript!"
Config.groovy contains:
"coffeescript-compiler" {
appSource {
coffeeSourcePath = "src/coffee/app"
jsOutputPath = "web-app/js/app"
}
testSource {
coffeeSourcePath = "src/coffee/spec"
jsOutputPath = "web-app/js/spec"
}
}
An empty js file is generated at web-app/js/app and there is such output on stderr:
2013-02-24 19:54:51,742 [main] INFO compiler.CoffeeCompilerManager - Compiling CoffeeScript path src/coffee/app to web-app/js/app
2013-02-24 19:54:51,814 [main] INFO compiler.CoffeeCompiler - Purging web-app/js/app...
| Error 2013-02-24 19:54:52,732 [pool-4-thread-1] ERROR compiler.CoffeeCompiler - null in src\coffee\app\user_index.coffee
The error is the same no matter what is the content of my coffee script file.
I do not have node.js installed
Please help, thanks
this would keep it consistent.
we use the overrideJS = false so it only compiles new files just like a groovy file would do.
Do we really need that this plugin was in resulting war file?
Maybe it would be good to changt dependency
compile ":coffeescript-compiler:0.9.4"
to
build ":coffeescript-compiler:0.9.4"
The coffee files are compiled twice, once to the default output directory and once to the directory of my choice.
Grails 2.2.0, using Rhino.
My Config.groovy file has:
"coffeescript-compiler" {
pluginConfig {
wrapJS = false
}
appSource {
coffeeSourcePath = "src/coffee"
jsOutputPath = "web-app/cs"
}
}
and this is what I get:
2013-03-07 22:09:04,177 [main] INFO compiler.CoffeeCompilerManager - Compiling CoffeeScript path src/coffee to web-app/js/app
2013-03-07 22:09:05,033 [pool-4-thread-1] INFO compiler.CoffeeCompiler - Compiling src\coffee\main_index.coffee to web-app\js\app\main_index.js
2013-03-07 22:09:05,033 [pool-4-thread-2] INFO compiler.CoffeeCompiler - Compiling src\coffee\user_index.coffee to web-app\js\app\user_index.js
2013-03-07 22:09:11,411 [main] INFO compiler.CoffeeCompilerManager - Compiling CoffeeScript path src/coffee to web-app/cs
2013-03-07 22:09:11,457 [pool-5-thread-1] INFO compiler.CoffeeCompiler - Compiling src\coffee\main_index.coffee to web-app\cs\main_index.js
2013-03-07 22:09:11,457 [pool-5-thread-2] INFO compiler.CoffeeCompiler - Compiling src\coffee\user_index.coffee to web-app\cs\user_index.js
Could you please document how one could disable minification under production environment?
Some people will prefer let minification concerns to the resources plugin.
Currently I don't minify my assets on production and only deploy gzip compression to them. This allows me to debug some bugs that only show up on production... Also I didn't experienced much performance improvement on page loading when minifying my assets in addition to applying gzip compression on them.
Hi Brian,
Thanks for your plugin. I'm choosing plugin to enable in my project and little bit confused because there is two similar plugins: your grails-coffeescript-compiler-plugin and grails-coffeescript-resources.The second one looks little it outdated and has a lot of unresolved issues in tracker.
But I want to be able use Coffee files as usual resources.
Could you answer to me what are the differences between this plugins and could they be merged?
Thanks
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.