40
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 CBT

fun, fast, intuitive, composable, statically checked CBT A ... · x.ai 25 Engineers, lots of Scala projects (CBT is my personal, free-time side-project)

  • Upload
    others

  • View
    1

  • Download
    0

Embed Size (px)

Citation preview

Page 1: fun, fast, intuitive, composable, statically checked CBT A ... · x.ai 25 Engineers, lots of Scala projects (CBT is my personal, free-time side-project)

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

CBT

Page 2: fun, fast, intuitive, composable, statically checked CBT A ... · x.ai 25 Engineers, lots of Scala projects (CBT is my personal, free-time side-project)

Jan Christopher Vogt

ai

Slick, Martin’s lab, Compossible Records,Scala Forklift, MavenSearch

Who am I?

magically sch

edule

meetings

Page 3: fun, fast, intuitive, composable, statically checked CBT A ... · x.ai 25 Engineers, lots of Scala projects (CBT is my personal, free-time side-project)

What’s the goal here?

Page 4: fun, fast, intuitive, composable, statically checked CBT A ... · x.ai 25 Engineers, lots of Scala projects (CBT is my personal, free-time side-project)

x.ai

25 Engineers,

lots of Scala projects

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

Page 5: fun, fast, intuitive, composable, statically checked CBT A ... · x.ai 25 Engineers, lots of Scala projects (CBT is my personal, free-time side-project)

CBT

Few, simple building blocks.Easy. Fast. Idiomatic Scala.Flexible and compositional.Easy code and contribution.

Page 6: fun, fast, intuitive, composable, statically checked CBT A ... · x.ai 25 Engineers, lots of Scala projects (CBT is my personal, free-time side-project)

- 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)

Page 7: fun, fast, intuitive, composable, statically checked CBT A ... · x.ai 25 Engineers, lots of Scala projects (CBT is my personal, free-time side-project)

- 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

Page 8: fun, fast, intuitive, composable, statically checked CBT A ... · x.ai 25 Engineers, lots of Scala projects (CBT is my personal, free-time side-project)

- focus!- tiny: < 1500 LOC- easy code! Scala beginners can understand.- bootstraps from source: install = git clone

Easy to understand and contribute

Page 9: fun, fast, intuitive, composable, statically checked CBT A ... · x.ai 25 Engineers, lots of Scala projects (CBT is my personal, free-time side-project)

Supported features right now

- compile, run, test, scaladoc- package jars- publish to sonatype- download jars from maven- file change triggers- build composition (dependent builds)

Page 10: fun, fast, intuitive, composable, statically checked CBT A ... · x.ai 25 Engineers, lots of Scala projects (CBT is my personal, free-time side-project)

Missing features (likely easy to add)

1. configurable resolvers2. cross scala version builds3. scalajs support4. repl

Page 11: fun, fast, intuitive, composable, statically checked CBT A ... · x.ai 25 Engineers, lots of Scala projects (CBT is my personal, free-time side-project)

- some aspects of- usability- logging

- only tested on OSX- only used by me :)

Rough edges

Page 12: fun, fast, intuitive, composable, statically checked CBT A ... · x.ai 25 Engineers, lots of Scala projects (CBT is my personal, free-time side-project)

Live Demo

Page 13: fun, fast, intuitive, composable, statically checked CBT A ... · x.ai 25 Engineers, lots of Scala projects (CBT is my personal, free-time side-project)

check

- README.txt

Getting started

Page 14: fun, fast, intuitive, composable, statically checked CBT A ... · x.ai 25 Engineers, lots of Scala projects (CBT is my personal, free-time side-project)

Philosophy and design

Page 15: fun, fast, intuitive, composable, statically checked CBT A ... · x.ai 25 Engineers, lots of Scala projects (CBT is my personal, free-time side-project)

Builds aren’t special.Just code.

Page 16: fun, fast, intuitive, composable, statically checked CBT A ... · x.ai 25 Engineers, lots of Scala projects (CBT is my personal, free-time side-project)

- zinc- Scala- BarbaryWatchService- ammonite-ops (still)

Dependencies

Page 17: fun, fast, intuitive, composable, statically checked CBT A ... · x.ai 25 Engineers, lots of Scala projects (CBT is my personal, free-time side-project)

Custom maven resolver

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

Page 18: fun, fast, intuitive, composable, statically checked CBT A ... · x.ai 25 Engineers, lots of Scala projects (CBT is my personal, free-time side-project)

Fast re-compilation triggers

- watches sources of project, build, CBT

Page 19: fun, fast, intuitive, composable, statically checked CBT A ... · x.ai 25 Engineers, lots of Scala projects (CBT is my personal, free-time side-project)

- totally opt-in- requires care regarding IO- per-run result cache

Parallel task execution

Page 20: fun, fast, intuitive, composable, statically checked CBT A ... · x.ai 25 Engineers, lots of Scala projects (CBT is my personal, free-time side-project)

Build composition

Page 21: fun, fast, intuitive, composable, statically checked CBT A ... · x.ai 25 Engineers, lots of Scala projects (CBT is my personal, free-time side-project)

Build composition

assembly-project

project1project2 shared

project3

Can be separate git repos

each one compiles

Page 22: fun, fast, intuitive, composable, statically checked CBT A ... · x.ai 25 Engineers, lots of Scala projects (CBT is my personal, free-time side-project)

Build composition

Simple building block, many uses:

1. Dependent builds2. Multi-project builds3. Tests4. Builds of builds5. Whenever A needs to compile before B

Same rules

everywhere

Page 23: fun, fast, intuitive, composable, statically checked CBT A ... · x.ai 25 Engineers, lots of Scala projects (CBT is my personal, free-time side-project)

Current limitations

Page 24: fun, fast, intuitive, composable, statically checked CBT A ... · x.ai 25 Engineers, lots of Scala projects (CBT is my personal, free-time side-project)

Concurrent builds

- not supported yet- should be fine via dependency graph- requires internal care regarding caches

Page 25: fun, fast, intuitive, composable, statically checked CBT A ... · x.ai 25 Engineers, lots of Scala projects (CBT is my personal, free-time side-project)

Re-configuration

Inheritance is static

Re-configuration through static code

Page 26: fun, fast, intuitive, composable, statically checked CBT A ... · x.ai 25 Engineers, lots of Scala projects (CBT is my personal, free-time side-project)

e.g. provide version from command line

But how?

Members are already hard-wired.

Dynamic re-configuration

Page 27: fun, fast, intuitive, composable, statically checked CBT A ... · x.ai 25 Engineers, lots of Scala projects (CBT is my personal, free-time side-project)

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

Page 28: fun, fast, intuitive, composable, statically checked CBT A ... · x.ai 25 Engineers, lots of Scala projects (CBT is my personal, free-time side-project)

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)

Page 29: fun, fast, intuitive, composable, statically checked CBT A ... · x.ai 25 Engineers, lots of Scala projects (CBT is my personal, free-time side-project)

Example: code-generationclass BasicBuild(...){ def publishSnapshot: Unit = { val reconfiguredBuild = this.mixin( new BasicBuild{ override def version = super.version+“-SNAPSHOT” } ): reconfiguredBuild b.publish }}

Page 30: fun, fast, intuitive, composable, statically checked CBT A ... · x.ai 25 Engineers, lots of Scala projects (CBT is my personal, free-time side-project)

How to contribute

Page 31: fun, fast, intuitive, composable, statically checked CBT A ... · x.ai 25 Engineers, lots of Scala projects (CBT is my personal, free-time side-project)

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

Page 32: fun, fast, intuitive, composable, statically checked CBT A ... · x.ai 25 Engineers, lots of Scala projects (CBT is my personal, free-time side-project)

● very easy● write traits to mix into builds● publish as libs on maven● depend on them in your BuildBuild

Write extensions

Page 33: fun, fast, intuitive, composable, statically checked CBT A ... · x.ai 25 Engineers, lots of Scala projects (CBT is my personal, free-time side-project)

Diving into the source

If time permits.Otherwise unconference session.

Page 34: fun, fast, intuitive, composable, statically checked CBT A ... · x.ai 25 Engineers, lots of Scala projects (CBT is my personal, free-time side-project)

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

Near future work

Page 35: fun, fast, intuitive, composable, statically checked CBT A ... · x.ai 25 Engineers, lots of Scala projects (CBT is my personal, free-time side-project)

● git(hub) dependencies● sbt interop

Future work

Page 36: fun, fast, intuitive, composable, statically checked CBT A ... · x.ai 25 Engineers, lots of Scala projects (CBT is my personal, free-time side-project)

CBT?!?Compositional Build ToolComplex Build Tool ;)?Cool Build ToolCBT Build ToolCompossible Build ToolCOmposition Possible

Page 37: fun, fast, intuitive, composable, statically checked CBT A ... · x.ai 25 Engineers, lots of Scala projects (CBT is my personal, free-time side-project)

CBT!For now: “Chris’ Build Tool”

if( year == 2017 && cbt.hasCommunity )cbt.setName(

“Community Build Tool”)

Page 38: fun, fast, intuitive, composable, statically checked CBT A ... · x.ai 25 Engineers, lots of Scala projects (CBT is my personal, free-time side-project)

NEScala special offer:

I’ll make your CBT builds work.

Talk to me.

Page 39: fun, fast, intuitive, composable, statically checked CBT A ... · x.ai 25 Engineers, lots of Scala projects (CBT is my personal, free-time side-project)

● 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

Page 40: fun, fast, intuitive, composable, statically checked CBT A ... · x.ai 25 Engineers, lots of Scala projects (CBT is my personal, free-time side-project)

chris @ human.x.aiSenior Backend Engineer

Twitter: @cvogt @xdotaiGithub: @cvogtSlides, etc

We are hiring

!https://github.com/cvogt/cbt