SLIDE 1 NESCALA MARCH 4TH 2016 PHILADELPHIA https://github.com/cvogt/talk-2016-03-04
A Vision for Scala Builds
Jan Christopher Vogt / @cvogt
fun, fast, intuitive, composable, statically checked
I am releasing 1.0-beta today
C C B B T T
SLIDE 2
Jan Christopher Vogt ai Slick, Martin’s lab, Compossible Records, Scala Forklift, MavenSearch
Who am I? m m a a g g i i c c a a l l l l y y s s c c h h e e d d u u l l e e m m e e e e t t i i n n g g s s
SLIDE 3
What’s the goal here?
SLIDE 4 x.ai
25 Engineers, lots of Scala projects
(CBT is my personal, free-time side-project)
SLIDE 5 CBT Few, simple building blocks.
- Easy. Fast. Idiomatic Scala.
Flexible and compositional. Easy code and contribution.
SLIDE 6
- build composition!
- Scala library of functionality
- builds scripts written in vanilla Scala
(builds = classes, “tasks” = methods)
- configuration via inheritance
(shallow layer)
Building blocks
Similar to SBT 0.7. (back in 2011)
SLIDE 7
- resident JVM via Nailgun
- caching of dependencies
- artifacts/pom on disk
- classloader in memory
- run zinc only when changed
- concurrency (opt-in)
- native OSX file change triggers
Fast
SLIDE 8
- focus!
- tiny: < 1500 LOC
- easy code! Scala beginners can understand.
- bootstraps from source: install = git clone
Easy to understand and contribute
SLIDE 9 Supported features right now
- compile, run, test, scaladoc
- package jars
- publish to sonatype
- download jars from maven
- file change triggers
- build composition (dependent builds)
SLIDE 10 Missing features (likely easy to add)
- 1. configurable resolvers
- 2. cross scala version builds
- 3. scalajs support
- 4. repl
SLIDE 11
- some aspects of
- usability
- logging
- only tested on OSX
- only used by me :)
Rough edges
SLIDE 12
Live Demo
SLIDE 13 check
Getting started
SLIDE 14
Philosophy and design
SLIDE 15
Builds aren’t special. Just code.
SLIDE 16
- zinc
- Scala
- BarbaryWatchService
- ammonite-ops (still)
Dependencies
SLIDE 17 Custom maven resolver
- new implementation
- proper caching
- (some feature limitation still)
- Coursier as a drop-in
SLIDE 18 Fast re-compilation triggers
- watches sources of project, build, CBT
SLIDE 19
- totally opt-in
- requires care regarding IO
- per-run result cache
Parallel task execution
SLIDE 20
Build composition
SLIDE 21
Build composition
assembly-project project1 project2 shared project3 Can be separate git repos each one compiles
SLIDE 22 Build composition
Simple building block, many uses:
- 1. Dependent builds
- 2. Multi-project builds
- 3. Tests
- 4. Builds of builds
- 5. Whenever A needs to compile before B
Same rules everywhere
SLIDE 23
Current limitations
SLIDE 24 Concurrent builds
- not supported yet
- should be fine via dependency graph
- requires internal care regarding caches
SLIDE 25
Re-configuration
Inheritance is static Re-configuration through static code
SLIDE 26
e.g. provide version from command line But how? Members are already hard-wired.
Dynamic re-configuration
SLIDE 27
e.g. automatically append “-SNAPSHOT” to the version number for snapshot builds But how? Code does not know the eventual class.
Ad-hoc re-configuration
SLIDE 28 Candidate solutions
- messy, easy, powerful: mutable members
- clean, easy, limited: hard-coded use cases
- clean, hard, powerful: code-generation
(it’s a build tool after all)
SLIDE 29 Example: code-generation
class BasicBuild(...){ def publishSnapshot: Unit = { val reconfiguredBuild = this.mixin( new BasicBuild{
- verride def version = super.version+“-SNAPSHOT”
} ): reconfiguredBuild b.publish } }
SLIDE 30
How to contribute
SLIDE 31 The code is simple
- CBT is distributed as source. You clone it.
- check DEVELOPER_GUIDE.txt
- read the code: clean and easy.
- change it, CBT re-builds itself on use
- submit a PR
SLIDE 32
- very easy
- write traits to mix into builds
- publish as libs on maven
- depend on them in your BuildBuild
Write extensions
SLIDE 33
Diving into the source
If time permits. Otherwise unconference session.
SLIDE 34
- allow different CBT and Scala versions
- concurrent builds
- Coursier integration
- more tests
- Scala Days 2016 surprise feature
Near future work
SLIDE 35
- git(hub) dependencies
- sbt interop
Future work
SLIDE 36
CBT?!?
Compositional Build Tool Complex Build Tool ;)? Cool Build Tool CBT Build Tool Compossible Build Tool
COmposition Possible
SLIDE 37
CBT!
For now: “Chris’ Build Tool”
if( year == 2017 && cbt.hasCommunity ) cbt.setName( “Community Build Tool” )
SLIDE 38
NEScala special offer: I’ll make your CBT builds work. Talk to me.
SLIDE 39
- This is BETA - let the bug hunting begin
- report issues or submit PRs (easy ;)).
- let’s get it solid until Scala Days
git push What’s next
SLIDE 40 chris @ human.x.ai
Senior Backend Engineer
Twitter: @cvogt @xdotai Github: @cvogt Slides, etc W W e e a a r r e e h h i i r r i i n n g g ! !
https://github.com/cvogt/cbt