Slide 1

Slide 1 text

N'ayez pas peur de faire du @CedricChampeau

Slide 2

Slide 2 text

Made in Nantes

Slide 3

Slide 3 text

Scripting

Slide 4

Slide 4 text

log.message "Releasing Groovy $version with user: $user" def desc = "Release of $version" def date = new Date().format("yyyy-MM-dd'T'HH:mm:ss.SSSZ") def remoteCall = { String url, List params, Closure onFailure -> def p = ['curl', "-m", "3600", "-u", "$user:$key", *params, url].execute() int code = p.waitFor() def resp = p.text log.message "${resp}" if (code!=0 || resp.toLowerCase().contains('error') ) { onFailure(code) System.exit(code) } }

Slide 5

Slide 5 text

DSLs

Slide 6

Slide 6 text

remoteSession { scp { from { localDir "$buildDir/application " } into { remoteDir '/usr/local/myapp' } timeout 10.minutes } }

Slide 7

Slide 7 text

Java friendly

Slide 8

Slide 8 text

@Immutable @ToString class Person { String name int age String greet(String them) { "Hello $them, my name is $name" } }

Slide 9

Slide 9 text

Dynamic

Slide 10

Slide 10 text

@ToString class Person { String name int age } def storage = [new Person(name:'Cédric', age:35), new Person(name:'Hugues', age:44)] Person.metaClass.static.methodMissing = { String name, args -> if (name.startsWith('findBy')) { String prop = (name - 'findBy').toLowerCase() storage.findAll { it."$prop" == args[0]} } } println Person.findByAge(35)

Slide 11

Slide 11 text

Static

Slide 12

Slide 12 text

@ToString class Person { String name int age } @CompileStatic void erreurDeCompil() { println Person.findByAge(35) }

Slide 13

Slide 13 text

Functional

Slide 14

Slide 14 text

new URL('http://beta.groovy-lang.org').text .split(' ') .findAll { it == 'Groovy' } .size()

Slide 15

Slide 15 text

Microservices?

Slide 16

Slide 16 text

@Grab('com.h2database:h2:1.3.179') import grails.persistence.* @Entity @Resource(uri='books') class Book { String title }

Slide 17

Slide 17 text

Builds

Slide 18

Slide 18 text

apply plugin: 'groovy' repositories { jcenter() } dependencies { compile 'org.codehaus.groovy:groovy:2.3.4-beta-3' }

Slide 19

Slide 19 text

Android

Slide 20

Slide 20 text

notify(NOTIFICATION_ID) { smallIcon = R.drawable.ic_action_alarms largeIcon = cachedBitmap contentTitle = 'Time left' contentText = "$timeLeft (Elapsed: ${rounded}%)" contentIntent = pendingActivityIntent(0, intent(WearPresentationActivity), FLAG_UPDATE_CURRENT) ongoing = true style = bigTextStyle { bigText """Time left for your presentation: $timeLeft Elapsed time: ${rounded}%) """ } }

Slide 21

Slide 21 text

Templating

Slide 22

Slide 22 text

layout 'layouts/main.groovy', true, pageTitle: 'The Groovy programming language - Mailing-lists', mainContent: contents { div(id: 'content', class: 'page-1') { div(class: 'row') { div(class: 'row-fluid') { div(class: 'col-lg-3') { include template: 'includes/community-navbar.groovy' } div(class: 'col-lg-8 col-lg-pull-0') { include template: 'includes/contribute-button.groovy' h1 { i(class: 'fa fa-envelope-o') {} yield ' Mailing-lists' } ...

Slide 23

Slide 23 text

Et tant d'autres...

Slide 24

Slide 24 text

No content

Slide 25

Slide 25 text

Merci ! @CedricChampeau