0
SBT <<= (Build) { FTW }        @indrajitr
SBT• Build tool on Scala for building Scala-Java projects• Compliant with Mavens convention (mostly)• Basics done right• E...
Build Definitions• Simple: Quick DSL• Diabolical: Scala code (with embedded DSL)• And the shell rocks                      ...
Build Definitions<base>/*.sbt<base>/project/*.scala<base>/project/plugins.sbt<base>/project/plugins/*.(scala|sbt)~/.sbt/plu...
build.sbtorganization := "net.liftweb"name       := "lift-demo"version    := "1.0"scalaVersion := "2.9.1"libraryDependenci...
project/build.scalaimport sbt._object LiftBuild extends Build {    lazy val projects: Seq[ProjectReference] = Seq(common, ...
The ExpressionReminder:Statement ≠ Expression  Statement:    val foo = bar + baz  Expression:    bar + baz                ...
The ExpressionThe expression:organization <<= organization or normalizedName.identityIs a: Project.Setting[S]And <<= is th...
The Emojis                The ONE    <<=Bay Area Scala Enthusiasts Meeting #42 (10-10-11)
The Emojis  And the rest  := += ++= <+= <++= ~=• Initialize ( := )• Append ( += ++= <+= <++= )• Update ( ~= )             ...
Scoped Keyssealed trait Key[T] extends Scopedfinal class SettingKey[T] extends Key[T] with ScopedSetting[T]final class TaskK...
Examplesname := "lift-demo"name ~= formalizeresolvers in GlobalScope += JavaNet2RepositoryscalacOptions ++= Seq("-encoding...
ExampleslibraryDependencies <<= (libraryDependencies, scalaVersion) apply { (ld, sv) =>ld :+ scalap(sv) })libraryDependenc...
Settings are Scoped!def in(s: Scope): Result // ScopedSetting, ScopedTask, ScopedInputdef in(p: Reference): Resultdef in(t...
MiscellaneousMOAR Emojis (in shell)!~ + ++ ; ! < -Plugin, State, Life, Universe and everything else                       ...
Lost? Befriend ‘em• Defaults.scala• Keys.scala• IDE                   Bay Area Scala Enthusiasts Meeting #42 (10-10-11)
Exercise
Questions?
Upcoming SlideShare
Loading in...5
×

Simple Build Tool Introduction

650

Published on

SBT Talk at Bay Area Scala Enthusiasts' Meetup (10/10/2011 @ Foursquare SF)

Published in: Technology, Business
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
650
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
14
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide
  • The title is actually valid SBT expression\nSkipping lots of things to make room for more important ones in 45 min\nBasic things and then SBT code\nNo FP details (unless something slips out)\n\n
  • It&amp;#x2019;s SIMPLE once you get past the initial hoop\nAs crazy and as awesome as scala\nTricky to get going, no looking back when there\n
  • Roughly equivalent to pom.xml\n\nGreat DSL in SBT: Buy DSL in Action or learn SBT for free\n\n
  • \n
  • \n
  • Contents of settings are expressions\n
  • Expressions compose, statements don&amp;#x2019;t\nExpression has a value\n
  • \n
  • \n
  • \n
  • \n
  • \n
  • lazy val scalap: String =&gt; ModuleID = &quot;org.scala-lang&quot; % &quot;scalap&quot; % _\n
  • \n
  • \n
  • \n
  • \n
  • \n
  • Transcript of "Simple Build Tool Introduction"

    1. 1. SBT <<= (Build) { FTW } @indrajitr
    2. 2. SBT• Build tool on Scala for building Scala-Java projects• Compliant with Mavens convention (mostly)• Basics done right• Easy to set up for simple projects (intrusive)• Shares a *lot* with Scala Bay Area Scala Enthusiasts Meeting #42 (10-10-11)
    3. 3. Build Definitions• Simple: Quick DSL• Diabolical: Scala code (with embedded DSL)• And the shell rocks Bay Area Scala Enthusiasts Meeting #42 (10-10-11)
    4. 4. Build Definitions<base>/*.sbt<base>/project/*.scala<base>/project/plugins.sbt<base>/project/plugins/*.(scala|sbt)~/.sbt/plugins/*.(scala|sbt) Bay Area Scala Enthusiasts Meeting #42 (10-10-11)
    5. 5. build.sbtorganization := "net.liftweb"name := "lift-demo"version := "1.0"scalaVersion := "2.9.1"libraryDependencies ++= Seq("net.liftweb" %% "lift-webkit" % "2.4-M4", "org.eclipse.jetty" % "jetty-webapp" % "7.3.0.v20110203" % "jetty") Bay Area Scala Enthusiasts Meeting #42 (10-10-11)
    6. 6. project/build.scalaimport sbt._object LiftBuild extends Build { lazy val projects: Seq[ProjectReference] = Seq(common, actor, json) lazy val framework = Project("lift-framework", file(".")).aggregate(projects) lazy val common = Project(“lift-common”, file(“core/common”)).settings(/*...*/) lazy val actor = Project(“lift-actor”, file(“core/actor”)).dependsOn(common).settings(/*...*/) lazy val json = Project("lift-json", file("core/json")) dependsOn(common % "test") //lazy val foo = Project("lift-foo", file("core/foo"), delegates = common :: Nil)} Bay Area Scala Enthusiasts Meeting #42 (10-10-11)
    7. 7. The ExpressionReminder:Statement ≠ Expression Statement: val foo = bar + baz Expression: bar + baz Bay Area Scala Enthusiasts Meeting #42 (10-10-11)
    8. 8. The ExpressionThe expression:organization <<= organization or normalizedName.identityIs a: Project.Setting[S]And <<= is thus:final def <<= (app: Initialize[S]): Setting[S]for: InputKey, SettingsKey Bay Area Scala Enthusiasts Meeting #42 (10-10-11)
    9. 9. The Emojis The ONE <<=Bay Area Scala Enthusiasts Meeting #42 (10-10-11)
    10. 10. The Emojis And the rest := += ++= <+= <++= ~=• Initialize ( := )• Append ( += ++= <+= <++= )• Update ( ~= ) Bay Area Scala Enthusiasts Meeting #42 (10-10-11)
    11. 11. Scoped Keyssealed trait Key[T] extends Scopedfinal class SettingKey[T] extends Key[T] with ScopedSetting[T]final class TaskKey[T] extends Key[T] with ScopedTask[T]final class InputKey[T] extends Key[InputTask[T]] with ScopedInput[T] Bay Area Scala Enthusiasts Meeting #42 (10-10-11)
    12. 12. Examplesname := "lift-demo"name ~= formalizeresolvers in GlobalScope += JavaNet2RepositoryscalacOptions ++= Seq("-encoding", "UTF-8")resolvers <++= isSnapshot { s => if (s) Seq(ScalaToolsSnapshots) else Nil }inceptionYear <<= inceptionYear ?? Some(2011)organization <<= organization or normalizedName.identity Bay Area Scala Enthusiasts Meeting #42 (10-10-11)
    13. 13. ExampleslibraryDependencies <<= (libraryDependencies, scalaVersion) apply { (ld, sv) =>ld :+ scalap(sv) })libraryDependencies <+= (scalaVersion)(scalap)libraryDependencies <+= scalaVersion apply scalapscalacOptions /*in GlobalScope*/ in doc <++= (name in doc, version in doc) map(Seq("-doc-title", _, "-doc-version", _)) Bay Area Scala Enthusiasts Meeting #42 (10-10-11)
    14. 14. Settings are Scoped!def in(s: Scope): Result // ScopedSetting, ScopedTask, ScopedInputdef in(p: Reference): Resultdef in(t: Scoped): Resultdef in(c: ConfigKey): Resultdef in(c: ConfigKey, t: Scoped): Resultdef in(p: Reference, c: ConfigKey): Resultdef in(p: Reference, t: Scoped): Resultdef in(p: Reference, c: ConfigKey, t: Scoped): Resultdef in(p: ScopeAxis[Reference], c: ScopeAxis[ConfigKey], t: ScopeAxis[AttributeKey[_]]): Result Bay Area Scala Enthusiasts Meeting #42 (10-10-11)
    15. 15. MiscellaneousMOAR Emojis (in shell)!~ + ++ ; ! < -Plugin, State, Life, Universe and everything else Bay Area Scala Enthusiasts Meeting #42 (10-10-11)
    16. 16. Lost? Befriend ‘em• Defaults.scala• Keys.scala• IDE Bay Area Scala Enthusiasts Meeting #42 (10-10-11)
    17. 17. Exercise
    18. 18. Questions?
    1. A particular slide catching your eye?

      Clipping is a handy way to collect important slides you want to go back to later.

    ×