About me
Developer, I love it
Lazy in english at school
Living in Madrid
Working at Osoco
Grooscript developer
@jfrancoleza
jorge.franco.leza@gmail.com
Groovy to Javascript converter
Groovy 2 to Javascript ECMAScript 5
Open source project, Apache 2 license
Library with Groovy and GPars dependencies
No special Javascript objects or functions
Converted code requires grooscript.js to run
Different conversion options
Grails plugin, npm package, gradle plugin
What is grooscript?
Limitations
Groovy / Java not fully supported
Working in groovy-core
No good support for inheritance
No methods with same name
Basic support in metaClass
No packages, no classes with same name
No metainfo, expandoMetaClass, class info
Only AST transformations applied in semantic phase
No complex Java / Groovy types
… see documentation for more info on grooscript.org
Main context scope
Customization
• Requires Groovy 2.1, the closure is passed to withConfig(conf)
• More info in http://docs.codehaus.org/display/GROOVY/Advanced+compiler+configuration
• Sometimes you don’t know where to find a variable
• When conversion is done, some variables come from other contexts
• grooscript.js sometimes tries to find missed variables with eval
• Node.js eval not working same way that browsers do
• You can define variables or function names with this option
• Ex. [‘$’, ‘myAwesomeFunction’, ‘myMissedVariable’]
Mandatory Screen capture Before start test
More console info
Accept basic parameters
Works fine in GroovyTestCase
Not so well in Spock
Have to
define
Phantom.js
path
Feature: PhantomJsTest
Grooscript Vert.x Plugin
Convert Groovy code to Javascript
Run conversion daemon
Websockets
Eventbus bridge
New port open
Events in the client
Auto reload pages
Both are optional
http://grooscript.org/pluginManual/
v 1.3.1
Requires Java 1.7
More eventsBuilder
Where
Listen events Render on load
Send event message
= println
Execute on event message
Don’t use ${} in grooscript tags
Strong dependency Resources plugin
Can put code in a .groovy file
Domain classes in the client*
*Experimental, it requires Groovy 2.1 (grails 2.3)
• validate, clientValidations **
• hasErrors
• count
• list * without params
• get
• save * without params
• delete
Domain classes connected with the server*
*Experimental, it requires Groovy 2.1 (grails 2.3)
• list
• get
• save
• delete
PhantomJs Tests*
*Not working in Grails 2.3, need improvements
New test phase phantomjs
Tests in test/phantomjs
More features
features, features…
next release 0.5
Change resources plugin dependencies to Require.js
Improve domain options
PhantomJs tests improvements
Move to websockets with Spring 4 in 2.4
and many more…
Remote domain class to grails REST support
Gradle plugin
Add in your build.gradle
http://grooscript.wordpress.com/2014/02/22/starting-with-grooscript/
Create more conversion tasks: http://grooscript.wordpress.com/2014/01/31/61/
Converted files destination
Require.js setup file
Files to be converted
Bind id’s to presenter properties
Coming next months…
grooscript 0.5
gradle plugin 0.3
Improve Groovy support (Java 8 too) and Javascript friendly
Add jQuery and binder utilities
Do tests also with Node.js
Wait function in PhantomJs tests
Remove binder and integrates with web frameworks
website
Back to dynamic, online conversions and robots!
Improve documentation
Why would I use grooscript?
• Create small modules to use in your views
• You can continue developing in Groovy
• Can use dsl’s, typeCheck, AST’s,… in the browser
• You have all the java tools and IDE’s
• You can work with new Javascript tools from Groovy
• Don’t repeat code in two languages
• Single development environment
• Create your own architecture in Groovy
• Don’t learn another “to Javascript” tool
Thank you!
All people reading this
680 motivation clicks
Jetbrains for IntelliJ IDEA v13 open source license
Special thanks to René, @glaforge and @marioggar
Community, I love your feedback
Please…
Version 0.4.4, time to improve
Questions?