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?
No good support for inheritance (super) No methods with same name Basic support in metaClass No packages, no classes with same name No metainfo, expandoMetaClass, … Only AST transformations applied in semantic phase No complex Java / Groovy types (Thread, Stack,…) … see documentation for more info on grooscript.org
fragment code String jsResult = GrooScript.convert(“println ‘Hello!’”) ! //Convert some file or folder, generate .js files with same name GrooScript.convert(‘path/to/file.groovy’, ‘destination/folder’) GrooScript.convert(‘path/to/folder’, ‘destination/folder’) GrooScript.convert(listOfFilesAndOrFolders, ‘destination/folder’)
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’]
assert $(element).size() == expectedSize, ‘Unexpected size’ } Mandatory Screen capture Accepts basic parameters Works fine in GroovyTestCase Not so well in Spock Have to define Phantom.js path Feature: PhantomJsTest
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
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
From resources plugin to Require.js or Asset pipeline plugin Improve domain options PhantomJs tests improvements Move to websockets/sockJs/stomp with Spring 4 in grails 2.4 … Remote domain class to grails REST support
{ mavenCentral() } dependencies { classpath 'org.grooscript:grooscript-gradle-plugin:0.3' } } ! apply plugin: 'grooscript' ! //If you need to change any conversion option, can do this way, optional grooscript { source = [‘src/main/groovy/presenters'] }
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
will continue improving grooscript Never will support full Groovy / Java I’m learning a lot, very fun New grails plugin in summer Focus next version: more and better java and groovy support