C C B B T T Jan Christopher Vogt / @cvogt - - PowerPoint PPT Presentation

c c b b t t
SMART_READER_LITE
LIVE PREVIEW

C C B B T T Jan Christopher Vogt / @cvogt - - PowerPoint PPT Presentation

A Vision for Scala Builds fun, fast, intuitive, composable, statically checked I am releasing 1.0-beta today C C B B T T Jan Christopher Vogt / @cvogt https://github.com/cvogt/talk-2016-03-04 NESCALA MARCH 4TH 2016


slide-1
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
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
SLIDE 3

What’s the goal here?

slide-4
SLIDE 4

x.ai

25 Engineers, lots of Scala projects

(CBT is my personal, free-time side-project)

slide-5
SLIDE 5

CBT Few, simple building blocks.

  • Easy. Fast. Idiomatic Scala.

Flexible and compositional. Easy code and contribution.

slide-6
SLIDE 6
  • build composition!
  • Scala library of functionality
  • builds scripts written in vanilla Scala

(builds = classes, “tasks” = methods)

  • configuration via inheritance

(shallow layer)

  • cli interop

Building blocks

Similar to SBT 0.7. (back in 2011)

slide-7
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
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
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
SLIDE 10

Missing features (likely easy to add)

  • 1. configurable resolvers
  • 2. cross scala version builds
  • 3. scalajs support
  • 4. repl
slide-11
SLIDE 11
  • some aspects of
  • usability
  • logging
  • only tested on OSX
  • only used by me :)

Rough edges

slide-12
SLIDE 12

Live Demo

slide-13
SLIDE 13

check

  • README.txt

Getting started

slide-14
SLIDE 14

Philosophy and design

slide-15
SLIDE 15

Builds aren’t special. Just code.

slide-16
SLIDE 16
  • zinc
  • Scala
  • BarbaryWatchService
  • ammonite-ops (still)

Dependencies

slide-17
SLIDE 17

Custom maven resolver

  • new implementation
  • proper caching
  • (some feature limitation still)
  • Coursier as a drop-in
slide-18
SLIDE 18

Fast re-compilation triggers

  • watches sources of project, build, CBT
slide-19
SLIDE 19
  • totally opt-in
  • requires care regarding IO
  • per-run result cache

Parallel task execution

slide-20
SLIDE 20

Build composition

slide-21
SLIDE 21

Build composition

assembly-project project1 project2 shared project3 Can be separate git repos each one compiles

slide-22
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
SLIDE 23

Current limitations

slide-24
SLIDE 24

Concurrent builds

  • not supported yet
  • should be fine via dependency graph
  • requires internal care regarding caches
slide-25
SLIDE 25

Re-configuration

Inheritance is static Re-configuration through static code

slide-26
SLIDE 26

e.g. provide version from command line But how? Members are already hard-wired.

Dynamic re-configuration

slide-27
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
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
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
SLIDE 30

How to contribute

slide-31
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
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
SLIDE 33

Diving into the source

If time permits. Otherwise unconference session.

slide-34
SLIDE 34
  • allow different CBT and Scala versions
  • concurrent builds
  • Coursier integration
  • more tests
  • Scala Days 2016 surprise feature

Near future work

slide-35
SLIDE 35
  • git(hub) dependencies
  • sbt interop

Future work

slide-36
SLIDE 36

CBT?!?

Compositional Build Tool Complex Build Tool ;)? Cool Build Tool CBT Build Tool Compossible Build Tool

COmposition Possible

slide-37
SLIDE 37

CBT!

For now: “Chris’ Build Tool”

if( year == 2017 && cbt.hasCommunity ) cbt.setName( “Community Build Tool” )

slide-38
SLIDE 38

NEScala special offer: I’ll make your CBT builds work. Talk to me.

slide-39
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
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