Grooscript greach
-
Upload
jorge-franco-leza -
Category
Technology
-
view
1.125 -
download
1
description
Transcript of Grooscript greach
![Page 1: Grooscript greach](https://reader033.fdocuments.in/reader033/viewer/2022052310/554f6b1ab4c9058a148b4f3e/html5/thumbnails/1.jpg)
grooscript@grooscript
http://grooscript.org
Jorge Franco
![Page 2: Grooscript greach](https://reader033.fdocuments.in/reader033/viewer/2022052310/554f6b1ab4c9058a148b4f3e/html5/thumbnails/2.jpg)
About me
Developer, I love it
Lazy in english at school
Living in Madrid
Working at Osoco
Grooscript developer
@jfrancoleza
![Page 3: Grooscript greach](https://reader033.fdocuments.in/reader033/viewer/2022052310/554f6b1ab4c9058a148b4f3e/html5/thumbnails/3.jpg)
The players
![Page 4: Grooscript greach](https://reader033.fdocuments.in/reader033/viewer/2022052310/554f6b1ab4c9058a148b4f3e/html5/thumbnails/4.jpg)
Web developer
Leave your comfort zone
Move to the client side
![Page 5: Grooscript greach](https://reader033.fdocuments.in/reader033/viewer/2022052310/554f6b1ab4c9058a148b4f3e/html5/thumbnails/5.jpg)
![Page 6: Grooscript greach](https://reader033.fdocuments.in/reader033/viewer/2022052310/554f6b1ab4c9058a148b4f3e/html5/thumbnails/6.jpg)
Doesn’t run!
on browsers
![Page 7: Grooscript greach](https://reader033.fdocuments.in/reader033/viewer/2022052310/554f6b1ab4c9058a148b4f3e/html5/thumbnails/7.jpg)
Do something! No excuses
You can do a library, resolve issues, create a plugin, give feedback,
help other projects, … !
You will learn a lot
![Page 8: Grooscript greach](https://reader033.fdocuments.in/reader033/viewer/2022052310/554f6b1ab4c9058a148b4f3e/html5/thumbnails/8.jpg)
The wire
![Page 9: Grooscript greach](https://reader033.fdocuments.in/reader033/viewer/2022052310/554f6b1ab4c9058a148b4f3e/html5/thumbnails/9.jpg)
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?
![Page 10: Grooscript greach](https://reader033.fdocuments.in/reader033/viewer/2022052310/554f6b1ab4c9058a148b4f3e/html5/thumbnails/10.jpg)
File.groovy File.js
Conversion!Options
grooscript.js
Convert Groovy files
![Page 11: Grooscript greach](https://reader033.fdocuments.in/reader033/viewer/2022052310/554f6b1ab4c9058a148b4f3e/html5/thumbnails/11.jpg)
Groovy code
![Page 12: Grooscript greach](https://reader033.fdocuments.in/reader033/viewer/2022052310/554f6b1ab4c9058a148b4f3e/html5/thumbnails/12.jpg)
Javascript result
![Page 13: Grooscript greach](https://reader033.fdocuments.in/reader033/viewer/2022052310/554f6b1ab4c9058a148b4f3e/html5/thumbnails/13.jpg)
Javascript
GroovyJava
More Ja
vasc
ript fr
iendly
Types, inheritance, java 8, …
metaClass
ListsClosures
Operators
Dsl’s
ExpandoMaps
beans
methodMissingMixins
Categories
![Page 14: Grooscript greach](https://reader033.fdocuments.in/reader033/viewer/2022052310/554f6b1ab4c9058a148b4f3e/html5/thumbnails/14.jpg)
LimitationsGroovy / 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
![Page 15: Grooscript greach](https://reader033.fdocuments.in/reader033/viewer/2022052310/554f6b1ab4c9058a148b4f3e/html5/thumbnails/15.jpg)
Directly convert code
![Page 16: Grooscript greach](https://reader033.fdocuments.in/reader033/viewer/2022052310/554f6b1ab4c9058a148b4f3e/html5/thumbnails/16.jpg)
Conversion options
convertDependencies - boolean - default false
classPath - List<String> or String - default null - Ex: ‘src/groovy’
customization - Closure - default null
mainContextScope - List<String> - default null
initialText / finalText - String - default null
recursive - boolean - default false
![Page 17: Grooscript greach](https://reader033.fdocuments.in/reader033/viewer/2022052310/554f6b1ab4c9058a148b4f3e/html5/thumbnails/17.jpg)
Convert dependencies option
Car.groovy
Wheel.groovy
Car.jsconvert
== optionwheel code
included
![Page 18: Grooscript greach](https://reader033.fdocuments.in/reader033/viewer/2022052310/554f6b1ab4c9058a148b4f3e/html5/thumbnails/18.jpg)
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’]
![Page 19: Grooscript greach](https://reader033.fdocuments.in/reader033/viewer/2022052310/554f6b1ab4c9058a148b4f3e/html5/thumbnails/19.jpg)
Feature: Annotations
@GsNotConvert @GsNative
![Page 20: Grooscript greach](https://reader033.fdocuments.in/reader033/viewer/2022052310/554f6b1ab4c9058a148b4f3e/html5/thumbnails/20.jpg)
Feature: Daemon
![Page 21: Grooscript greach](https://reader033.fdocuments.in/reader033/viewer/2022052310/554f6b1ab4c9058a148b4f3e/html5/thumbnails/21.jpg)
>phantomjs myTest.js
Inject grooscript.js and jquery
Use Groovy script abilities
I want to be Groovier
@AST
http://phantomjs.org/
Please code in Groovy!
![Page 22: Grooscript greach](https://reader033.fdocuments.in/reader033/viewer/2022052310/554f6b1ab4c9058a148b4f3e/html5/thumbnails/22.jpg)
Mandatory Screen capture Before start test
More console infoAccept basic parameters
Works fine in GroovyTestCaseNot so well in Spock
Have to define
Phantom.js path
Feature: PhantomJsTest
![Page 23: Grooscript greach](https://reader033.fdocuments.in/reader033/viewer/2022052310/554f6b1ab4c9058a148b4f3e/html5/thumbnails/23.jpg)
Example
![Page 24: Grooscript greach](https://reader033.fdocuments.in/reader033/viewer/2022052310/554f6b1ab4c9058a148b4f3e/html5/thumbnails/24.jpg)
Feature: builder
grooscript-builder.js
![Page 25: Grooscript greach](https://reader033.fdocuments.in/reader033/viewer/2022052310/554f6b1ab4c9058a148b4f3e/html5/thumbnails/25.jpg)
Demo websockets with Vert.xhttps://github.com/chiquitinxx/demoGroovyMeteor
http://www.meteor.com
https://vimeo.com/59395085
![Page 26: Grooscript greach](https://reader033.fdocuments.in/reader033/viewer/2022052310/554f6b1ab4c9058a148b4f3e/html5/thumbnails/26.jpg)
https://github.com/chiquitinxx/grooscript-vertx-plugin
http://www.grails.org/plugin/grooscript-vertx
v 0.4
![Page 27: Grooscript greach](https://reader033.fdocuments.in/reader033/viewer/2022052310/554f6b1ab4c9058a148b4f3e/html5/thumbnails/27.jpg)
Grooscript Vert.x Plugin
Convert Groovy code to Javascript
Run conversion daemon
Websockets
Eventbus bridge
New port openEvents in the client
Auto reload pages
Both are optional
http://grooscript.org/pluginManual/
v 1.3.1
Requires Java 1.7
![Page 28: Grooscript greach](https://reader033.fdocuments.in/reader033/viewer/2022052310/554f6b1ab4c9058a148b4f3e/html5/thumbnails/28.jpg)
Differences?Renders on server
Renders on the client
Conversions are cached with cache plugin
Grooscript tags auto - import js files needed
![Page 29: Grooscript greach](https://reader033.fdocuments.in/reader033/viewer/2022052310/554f6b1ab4c9058a148b4f3e/html5/thumbnails/29.jpg)
Grails port 8080
Vert.x port 8085
Browser gsp
eventBus
http
websockets
Config.groovy
BootStrap.groovy Chat sample
main.gsp
![Page 30: Grooscript greach](https://reader033.fdocuments.in/reader033/viewer/2022052310/554f6b1ab4c9058a148b4f3e/html5/thumbnails/30.jpg)
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
![Page 31: Grooscript greach](https://reader033.fdocuments.in/reader033/viewer/2022052310/554f6b1ab4c9058a148b4f3e/html5/thumbnails/31.jpg)
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
![Page 32: Grooscript greach](https://reader033.fdocuments.in/reader033/viewer/2022052310/554f6b1ab4c9058a148b4f3e/html5/thumbnails/32.jpg)
Domain classes connected with the server**Experimental, it requires Groovy 2.1 (grails 2.3)
• list • get • save • delete
![Page 33: Grooscript greach](https://reader033.fdocuments.in/reader033/viewer/2022052310/554f6b1ab4c9058a148b4f3e/html5/thumbnails/33.jpg)
PhantomJs Tests**Not working in Grails 2.3, need improvements
New test phase phantomjs
Tests in test/phantomjs
More features
![Page 34: Grooscript greach](https://reader033.fdocuments.in/reader033/viewer/2022052310/554f6b1ab4c9058a148b4f3e/html5/thumbnails/34.jpg)
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
![Page 35: Grooscript greach](https://reader033.fdocuments.in/reader033/viewer/2022052310/554f6b1ab4c9058a148b4f3e/html5/thumbnails/35.jpg)
https://github.com/chiquitinxx/grooscript-gradle-plugin
v 0.2
![Page 36: Grooscript greach](https://reader033.fdocuments.in/reader033/viewer/2022052310/554f6b1ab4c9058a148b4f3e/html5/thumbnails/36.jpg)
Gradle plugin
Add in your build.gradle
http://grooscript.wordpress.com/2014/02/22/starting-with-grooscript/
![Page 37: Grooscript greach](https://reader033.fdocuments.in/reader033/viewer/2022052310/554f6b1ab4c9058a148b4f3e/html5/thumbnails/37.jpg)
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
![Page 38: Grooscript greach](https://reader033.fdocuments.in/reader033/viewer/2022052310/554f6b1ab4c9058a148b4f3e/html5/thumbnails/38.jpg)
Demo springboot
http://projects.spring.io/spring-boot/
REST - Require.js - Grooscript Gradle Plugin - H2
https://github.com/chiquitinxx/springboot-rest-demo
![Page 39: Grooscript greach](https://reader033.fdocuments.in/reader033/viewer/2022052310/554f6b1ab4c9058a148b4f3e/html5/thumbnails/39.jpg)
https://github.com/chiquitinxx/grooscript/tree/master/npm
![Page 40: Grooscript greach](https://reader033.fdocuments.in/reader033/viewer/2022052310/554f6b1ab4c9058a148b4f3e/html5/thumbnails/40.jpg)
Last demo :)
Node.js is very fast!http://grooscript.wordpress.com/2014/01/10/impressive-node-js-v8-speed/
https://github.com/chiquitinxx/colors
![Page 41: Grooscript greach](https://reader033.fdocuments.in/reader033/viewer/2022052310/554f6b1ab4c9058a148b4f3e/html5/thumbnails/41.jpg)
Final topics
![Page 42: Grooscript greach](https://reader033.fdocuments.in/reader033/viewer/2022052310/554f6b1ab4c9058a148b4f3e/html5/thumbnails/42.jpg)
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
![Page 43: Grooscript greach](https://reader033.fdocuments.in/reader033/viewer/2022052310/554f6b1ab4c9058a148b4f3e/html5/thumbnails/43.jpg)
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
![Page 44: Grooscript greach](https://reader033.fdocuments.in/reader033/viewer/2022052310/554f6b1ab4c9058a148b4f3e/html5/thumbnails/44.jpg)
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?
![Page 45: Grooscript greach](https://reader033.fdocuments.in/reader033/viewer/2022052310/554f6b1ab4c9058a148b4f3e/html5/thumbnails/45.jpg)
Beer time!