SlideShare a Scribd company logo
sbt 0.10 for beginners ? 2011-07-06 20:00:00 JST #rpscala 41 Kazuo KASHIMA
Who am I? Software engineer / technical consultant 10 months with Scala and #rpscala A big fan of Lift Spend half of my time with PHP  
Goal Migrate my sbt 0.7.x project to sbt 0.10. Composed of sub projects Lift app
What’s new in sbt 0.10.x? Dunno…should be better than 0.7.x Two ways of configuration Basic Configuration (DSL) Full Configuration (Scala) and more…
Basic Configuration (example) //  https://github.com/harrah/xsbt/wiki/Basic-Configuration name := &quot;My Project&quot; version := &quot;1.0&quot; libraryDependencies += &quot;junit&quot; % &quot;junit&quot; % &quot;4.8&quot; % &quot;test&quot; libraryDependencies ++= Seq( &quot;net.databinder&quot; %% &quot;dispatch-google&quot; % &quot;0.7.8&quot;, &quot;net.databinder&quot; %% &quot;dispatch-meetup&quot; % &quot;0.7.8&quot; ) defaultExcludes ~= (filter => filter || &quot;*~&quot;) publishTo <<= version { (v: String) => if(v endsWith &quot;-SNAPSHOT&quot;) Some(ScalaToolsSnapshots) else Some(ScalaToolsReleases) }
Basic Configuration Less features Easier? Similar to Scala IMHO, almost as complex as Scala I wouldn’t recommend…
Full Configuration Write in Scala -> more comfortable More control https://github.com/harrah/xsbt/wiki/Full-Configuration-Example Much less information… “ Use the source, Luke”
Let’s get started https://github.com/harrah/xsbt/wiki/Migrating-from-SBT-0.7.x-to-0.10.x This is for “Basic Configuration” Steps Install sbt 0.10.0 Back up the old “project” directory Write Build.scala not build.sbt Run (and cross your fingers)
Dependency management Uses Ivy Examples &quot; commons-io &quot; % &quot; commons-io &quot; % &quot; 2.0.1 &quot; &quot; org.specs2 &quot; %% &quot; specs2 &quot; % &quot; 1.3 &quot; % &quot; test &quot; Corresponding maven settings http://mvnrepository.com/artifact/commons-io/commons-io/2.0.1 http://mavenhub.com/mvn/scala-tools-releases/org.specs2/specs2_2.9.0/1.3 % and %%
Resolvers Pair of Name and URL Example val   jGitRepo  = &quot; JGit &quot; at ” http://download.eclipse.org/jgit/maven &quot;
Sub projects (0.7.x) class LifthubProject(info: ProjectInfo) extends ParentProject(info) { lazy val core = project(&quot;core&quot;, &quot;Lifthub core&quot;, new CoreProject(_)) lazy val web = project(&quot;web&quot;, &quot;Lifthub web&quot;, new LiftProject(_),  core ) lazy val bgtasks = project(&quot;bgtasks&quot;, &quot;Lifthub bg tasks&quot;, new BgProject(_),  core ) } protected class CoreProject(info: ProjectInfo) extends DefaultProject(info) with AkkaProject  { // plugins are traits in sbt 0.7.x. // snip } protected class LiftProject(info: ProjectInfo) extends  DefaultWebProject (info) { // web support is part of sbt 0.7.x. // snip }
Sub projects (0.10.x) //  not working properly yet… object MyLifthubBuild extends Build { import Dependencies._ import com.github.siasia.WebPlugin._   lazy val root = Project(&quot;root&quot;, file (&quot;.&quot;), settings = buildSettings)  aggregate (core, web, bgtasks) lazy val core = Project(&quot;core&quot;, file (&quot;core&quot;),  settings = buildSettings ++ Seq (libraryDependencies := allDeps) ++ webSettings ) lazy val web = Project(&quot;web&quot;, file (&quot;web&quot;), settings = buildSettings ++  Seq (libraryDependencies := allDeps))  dependsOn  (core)  lazy val bgtasks = Project(&quot;bgtasks&quot;, file (&quot;bgtasks&quot;),  settings = buildSettings ++ Seq (libraryDependencies := allDeps))  dependsOn  (core) }
Plugins https://github.com/harrah/xsbt/wiki/Plugins Plugins are “object”s in sbt 0.10.x while they are traits in sbt 0.7.x. xsbt-web-plugin https://github.com/siasia/xsbt-web-plugin Akka ??
Lift with sbt 0.10.0 (not finished) http://moreindirection.blogspot.com/2011/06/migrating-to-sbt-010-lift.html ↑  Basic Configuration! Steps Create project/plugins/build .sbt import com.github.siasia.WebPlugin._ Add  webSettings  to project’s  settings Add jetty to  libraryDependencies
Conclusion 0.10 is very different from 0.7.x. Looks powerful “ Basic Configuration” sucks. Need to understand Scala and read the source, anyway.
Resources https://github.com/harrah/xsbt/wiki/Settings https://github.com/harrah/xsbt/wiki/Full-Configuration-Example http://eed3si9n.com/ja/sbt-010-guide

More Related Content

sbt 0.10 for beginners?

  • 1. sbt 0.10 for beginners ? 2011-07-06 20:00:00 JST #rpscala 41 Kazuo KASHIMA
  • 2. Who am I? Software engineer / technical consultant 10 months with Scala and #rpscala A big fan of Lift Spend half of my time with PHP 
  • 3. Goal Migrate my sbt 0.7.x project to sbt 0.10. Composed of sub projects Lift app
  • 4. What’s new in sbt 0.10.x? Dunno…should be better than 0.7.x Two ways of configuration Basic Configuration (DSL) Full Configuration (Scala) and more…
  • 5. Basic Configuration (example) // https://github.com/harrah/xsbt/wiki/Basic-Configuration name := &quot;My Project&quot; version := &quot;1.0&quot; libraryDependencies += &quot;junit&quot; % &quot;junit&quot; % &quot;4.8&quot; % &quot;test&quot; libraryDependencies ++= Seq( &quot;net.databinder&quot; %% &quot;dispatch-google&quot; % &quot;0.7.8&quot;, &quot;net.databinder&quot; %% &quot;dispatch-meetup&quot; % &quot;0.7.8&quot; ) defaultExcludes ~= (filter => filter || &quot;*~&quot;) publishTo <<= version { (v: String) => if(v endsWith &quot;-SNAPSHOT&quot;) Some(ScalaToolsSnapshots) else Some(ScalaToolsReleases) }
  • 6. Basic Configuration Less features Easier? Similar to Scala IMHO, almost as complex as Scala I wouldn’t recommend…
  • 7. Full Configuration Write in Scala -> more comfortable More control https://github.com/harrah/xsbt/wiki/Full-Configuration-Example Much less information… “ Use the source, Luke”
  • 8. Let’s get started https://github.com/harrah/xsbt/wiki/Migrating-from-SBT-0.7.x-to-0.10.x This is for “Basic Configuration” Steps Install sbt 0.10.0 Back up the old “project” directory Write Build.scala not build.sbt Run (and cross your fingers)
  • 9. Dependency management Uses Ivy Examples &quot; commons-io &quot; % &quot; commons-io &quot; % &quot; 2.0.1 &quot; &quot; org.specs2 &quot; %% &quot; specs2 &quot; % &quot; 1.3 &quot; % &quot; test &quot; Corresponding maven settings http://mvnrepository.com/artifact/commons-io/commons-io/2.0.1 http://mavenhub.com/mvn/scala-tools-releases/org.specs2/specs2_2.9.0/1.3 % and %%
  • 10. Resolvers Pair of Name and URL Example val jGitRepo = &quot; JGit &quot; at ” http://download.eclipse.org/jgit/maven &quot;
  • 11. Sub projects (0.7.x) class LifthubProject(info: ProjectInfo) extends ParentProject(info) { lazy val core = project(&quot;core&quot;, &quot;Lifthub core&quot;, new CoreProject(_)) lazy val web = project(&quot;web&quot;, &quot;Lifthub web&quot;, new LiftProject(_), core ) lazy val bgtasks = project(&quot;bgtasks&quot;, &quot;Lifthub bg tasks&quot;, new BgProject(_), core ) } protected class CoreProject(info: ProjectInfo) extends DefaultProject(info) with AkkaProject { // plugins are traits in sbt 0.7.x. // snip } protected class LiftProject(info: ProjectInfo) extends DefaultWebProject (info) { // web support is part of sbt 0.7.x. // snip }
  • 12. Sub projects (0.10.x) // not working properly yet… object MyLifthubBuild extends Build { import Dependencies._ import com.github.siasia.WebPlugin._ lazy val root = Project(&quot;root&quot;, file (&quot;.&quot;), settings = buildSettings) aggregate (core, web, bgtasks) lazy val core = Project(&quot;core&quot;, file (&quot;core&quot;), settings = buildSettings ++ Seq (libraryDependencies := allDeps) ++ webSettings ) lazy val web = Project(&quot;web&quot;, file (&quot;web&quot;), settings = buildSettings ++ Seq (libraryDependencies := allDeps)) dependsOn (core) lazy val bgtasks = Project(&quot;bgtasks&quot;, file (&quot;bgtasks&quot;), settings = buildSettings ++ Seq (libraryDependencies := allDeps)) dependsOn (core) }
  • 13. Plugins https://github.com/harrah/xsbt/wiki/Plugins Plugins are “object”s in sbt 0.10.x while they are traits in sbt 0.7.x. xsbt-web-plugin https://github.com/siasia/xsbt-web-plugin Akka ??
  • 14. Lift with sbt 0.10.0 (not finished) http://moreindirection.blogspot.com/2011/06/migrating-to-sbt-010-lift.html ↑ Basic Configuration! Steps Create project/plugins/build .sbt import com.github.siasia.WebPlugin._ Add webSettings to project’s settings Add jetty to libraryDependencies
  • 15. Conclusion 0.10 is very different from 0.7.x. Looks powerful “ Basic Configuration” sucks. Need to understand Scala and read the source, anyway.