Scala and Play with Gradle
-
Upload
wei-chen -
Category
Technology
-
view
57 -
download
5
Transcript of Scala and Play with Gradle
![Page 1: Scala and Play with Gradle](https://reader030.fdocuments.in/reader030/viewer/2022020208/55c573dfbb61eb5d358b4635/html5/thumbnails/1.jpg)
Scala and Play with GradleWei Chen
Sr. Software Engineer, Development Tools
Gradle Summit 2015
![Page 2: Scala and Play with Gradle](https://reader030.fdocuments.in/reader030/viewer/2022020208/55c573dfbb61eb5d358b4635/html5/thumbnails/2.jpg)
Build Happiness
![Page 3: Scala and Play with Gradle](https://reader030.fdocuments.in/reader030/viewer/2022020208/55c573dfbb61eb5d358b4635/html5/thumbnails/3.jpg)
What this talk is about?
● Scala support in Gradle● Play support in Gradle● Continuous mode (watch mode)● Demos
![Page 4: Scala and Play with Gradle](https://reader030.fdocuments.in/reader030/viewer/2022020208/55c573dfbb61eb5d358b4635/html5/thumbnails/4.jpg)
Who am I?
● A Software Engineer at Linkedin● Development Tools● Not a Scala expert● Not a Play expert● Maybe a build expert: make, ant, maven, sbt,
and gradle
![Page 5: Scala and Play with Gradle](https://reader030.fdocuments.in/reader030/viewer/2022020208/55c573dfbb61eb5d358b4635/html5/thumbnails/5.jpg)
● Object oriented● Strong typed● Full support for functional programming● JVM based● 1.5% of LI code base (Java 25.1%)
![Page 6: Scala and Play with Gradle](https://reader030.fdocuments.in/reader030/viewer/2022020208/55c573dfbb61eb5d358b4635/html5/thumbnails/6.jpg)
(Simple Build Tool? LOL)
● De facto build tool for scala community● Native support for compiling Scala code and
integrating with many Scala test frameworks● Build descriptions written in Scala using a DSL● Dependency management using Ivy● Continuous compilation, testing, and
deployment● Integration with the Scala interpreter for rapid
iteration and debugging● Support for mixed Java/Scala projects
![Page 7: Scala and Play with Gradle](https://reader030.fdocuments.in/reader030/viewer/2022020208/55c573dfbb61eb5d358b4635/html5/thumbnails/7.jpg)
vs.
Sbt Gradle
DSL language Scala Groovy
Supported languages Scala, Java Java, Scala, C++, ...
Incremental Scala build Yes Possible with Zinc
Interactive Shell Yes No (but has Gradle daemon)
REPL Yes No
Multi-module support Yes Yes
Dependency Management Ivy proprietary
Continuous Mode Yes YES!
Vendor and community support Mediocre Great
Existing LI Tooling Integration Minimal when we started Great
![Page 8: Scala and Play with Gradle](https://reader030.fdocuments.in/reader030/viewer/2022020208/55c573dfbb61eb5d358b4635/html5/thumbnails/8.jpg)
Scala Support in Gradle
● Scala plugin● From the very beginning of Gradle● 0.8 (September 2009)● Zinc support (1.3 November 2012)
![Page 9: Scala and Play with Gradle](https://reader030.fdocuments.in/reader030/viewer/2022020208/55c573dfbb61eb5d358b4635/html5/thumbnails/9.jpg)
Demo
● Compiles Scala● Compiles Java● Joint compilation
![Page 10: Scala and Play with Gradle](https://reader030.fdocuments.in/reader030/viewer/2022020208/55c573dfbb61eb5d358b4635/html5/thumbnails/10.jpg)
Limitations
● Scala version can only be inferred from direct dependencies
● No conflicting scala version validation● No cross-build support● No native specs2 integration● Bad IDE integration● Second class citizen in Scala world● Smaller adopter community
![Page 11: Scala and Play with Gradle](https://reader030.fdocuments.in/reader030/viewer/2022020208/55c573dfbb61eb5d358b4635/html5/thumbnails/11.jpg)
Framework
● Web App Framework● Async I/O (JBoss Netty)● Built-in hot reloading● Built on top of sbt● Supports both Java and Scala● 159+ Play Applications
![Page 12: Scala and Play with Gradle](https://reader030.fdocuments.in/reader030/viewer/2022020208/55c573dfbb61eb5d358b4635/html5/thumbnails/12.jpg)
Why to build Play on Gradle
● Pains with Ivy● Simplify our processes● Unify our build technologies● DRY
![Page 13: Scala and Play with Gradle](https://reader030.fdocuments.in/reader030/viewer/2022020208/55c573dfbb61eb5d358b4635/html5/thumbnails/13.jpg)
Dependency Management
● Product catalog● Dependency validation● Repository management● Conflict resolution● Consistent versioning● Manifest generation/upload● Dependency resolution performance
![Page 14: Scala and Play with Gradle](https://reader030.fdocuments.in/reader030/viewer/2022020208/55c573dfbb61eb5d358b4635/html5/thumbnails/14.jpg)
What’s involved?
1. Assets processing and packaging
2. Routes compilation
3. Twirl templates compilation
4. Scala/Java compilation
5. Running the server in development mode
6. Play binary packaging
7. Play distribution packaging
![Page 15: Scala and Play with Gradle](https://reader030.fdocuments.in/reader030/viewer/2022020208/55c573dfbb61eb5d358b4635/html5/thumbnails/15.jpg)
Milestones
1. Using Gradle to build a Play application
2. Continuous Mode and Hot-Reload
3. Making it real!
![Page 16: Scala and Play with Gradle](https://reader030.fdocuments.in/reader030/viewer/2022020208/55c573dfbb61eb5d358b4635/html5/thumbnails/16.jpg)
Demo
● Build a play app● Start the server in development mode
![Page 17: Scala and Play with Gradle](https://reader030.fdocuments.in/reader030/viewer/2022020208/55c573dfbb61eb5d358b4635/html5/thumbnails/17.jpg)
Basic Sample Demo
● Apply play plugin● Declare dependencies● Configure repositories
![Page 18: Scala and Play with Gradle](https://reader030.fdocuments.in/reader030/viewer/2022020208/55c573dfbb61eb5d358b4635/html5/thumbnails/18.jpg)
Advanced Sample Demo
● Apply CoffeeScript plugin● Configure target Scala and Play version
![Page 19: Scala and Play with Gradle](https://reader030.fdocuments.in/reader030/viewer/2022020208/55c573dfbb61eb5d358b4635/html5/thumbnails/19.jpg)
Multiproject Sample Demo
● Standard Gradle multiproject build● “root” project: main Play application● 3 submodules:
○ admin: Play application○ user: Play application○ util: Java library
![Page 20: Scala and Play with Gradle](https://reader030.fdocuments.in/reader030/viewer/2022020208/55c573dfbb61eb5d358b4635/html5/thumbnails/20.jpg)
Continuous Mode
● Gradle does not exit● Re-execute tasks when task file inputs
change● > Java 7 (file system WatchService)
![Page 21: Scala and Play with Gradle](https://reader030.fdocuments.in/reader030/viewer/2022020208/55c573dfbb61eb5d358b4635/html5/thumbnails/21.jpg)
Demo
● gradle build● gradle test
![Page 22: Scala and Play with Gradle](https://reader030.fdocuments.in/reader030/viewer/2022020208/55c573dfbb61eb5d358b4635/html5/thumbnails/22.jpg)
Play Hot Reload
● Stateless● Lightweight● Classloader magic● Used to be tightly coupled with build system
(sbt)● BuildLink
![Page 23: Scala and Play with Gradle](https://reader030.fdocuments.in/reader030/viewer/2022020208/55c573dfbb61eb5d358b4635/html5/thumbnails/23.jpg)
Play Hot Reload
![Page 24: Scala and Play with Gradle](https://reader030.fdocuments.in/reader030/viewer/2022020208/55c573dfbb61eb5d358b4635/html5/thumbnails/24.jpg)
Demo
Hot reload● Routes● Templates● Controller class
![Page 25: Scala and Play with Gradle](https://reader030.fdocuments.in/reader030/viewer/2022020208/55c573dfbb61eb5d358b4635/html5/thumbnails/25.jpg)
Q & A
Thank you!Wei ChenSr. Software Engineer, Development Tools
[email protected]://www.linkedin.com/in/weichenlinkedin
![Page 26: Scala and Play with Gradle](https://reader030.fdocuments.in/reader030/viewer/2022020208/55c573dfbb61eb5d358b4635/html5/thumbnails/26.jpg)
Useful Links
● https://docs.gradle.org/current/userguide/scala_plugin.html● https://github.com/gradle/gradle/blob/master/design-docs/play-support.
md● https://engineering.linkedin.com/play/developing-play-applications-
using-gradle● https://github.
com/playframework/playframework/blob/master/framework/src/build-link/src/main/java/play/core/BuildLink.java
● https://github.com/gradle/gradle● https://github.com/playframework/playframework