Upload
wei-chen
View
74
Download
5
Tags:
Embed Size (px)
Citation preview
Scala and Play with GradleWei Chen
Sr. Software Engineer, Development Tools
Gradle Summit 2015
Build Happiness
What this talk is about?
● Scala support in Gradle● Play support in Gradle● Continuous mode (watch mode)● Demos
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
● Object oriented● Strong typed● Full support for functional programming● JVM based● 1.5% of LI code base (Java 25.1%)
(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
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
Scala Support in Gradle
● Scala plugin● From the very beginning of Gradle● 0.8 (September 2009)● Zinc support (1.3 November 2012)
Demo
● Compiles Scala● Compiles Java● Joint compilation
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
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
Why to build Play on Gradle
● Pains with Ivy● Simplify our processes● Unify our build technologies● DRY
Dependency Management
● Product catalog● Dependency validation● Repository management● Conflict resolution● Consistent versioning● Manifest generation/upload● Dependency resolution performance
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
Milestones
1. Using Gradle to build a Play application
2. Continuous Mode and Hot-Reload
3. Making it real!
Demo
● Build a play app● Start the server in development mode
Basic Sample Demo
● Apply play plugin● Declare dependencies● Configure repositories
Advanced Sample Demo
● Apply CoffeeScript plugin● Configure target Scala and Play version
Multiproject Sample Demo
● Standard Gradle multiproject build● “root” project: main Play application● 3 submodules:
○ admin: Play application○ user: Play application○ util: Java library
Continuous Mode
● Gradle does not exit● Re-execute tasks when task file inputs
change● > Java 7 (file system WatchService)
Demo
● gradle build● gradle test
Play Hot Reload
● Stateless● Lightweight● Classloader magic● Used to be tightly coupled with build system
(sbt)● BuildLink
Play Hot Reload
Demo
Hot reload● Routes● Templates● Controller class
Q & A
Thank you!Wei ChenSr. Software Engineer, Development Tools
[email protected]://www.linkedin.com/in/weichenlinkedin
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