For developers ^
> history | awk '{print $2}' | sort | uniq -c
ant
mvn
sbt
import javax.xml.*
I've seen it.
<but>
<it does="not">
<look/>
<like>
${env.this}
</like>
</it>
</but>
(not only java)
echo "Makefile" | sed 's/Make/Rake/'
rake -T # ruby developer happiness ensues
Programmers often feel joy when they can concentrate on the creative side of programming, so Ruby is designed to make programmers happy.
— Yukihiro “Matz” Matsumoto
apache buildr caught on
leiningen gets it
(defproject leiningen "0.5.0-SNAPSHOT"
:description "A build tool designed to not set your hair on fire."
:url "http://github.com/technomancy/leiningen"
:dependencies [[org.clojure/clojure "1.1.0"]
[org.clojure/clojure-contrib "1.1.0"]]
:dev-dependencies [[swank-clojure "1.2.1"]])
clojure on clojure action ^
of the scala, by the scala, for the scala
Guy in the back exclaims...
Wait!!! What about my IDE???
use what you like
Relax
It's ★ Editor Independence Day! ★
sbt is built with sbt. How cool is that?
> mkdir -p fooz/src/{main,test}/{scala,resources}
> mkdir -p fooz/{project,src/{main,test}/\
{scala,resources}}
> tree # or
> ls -R | grep ":$" | sed -e 's/:$//' \
-e 's/[^-][^\/]*\//--/g' -e 's/^/ /' -e 's/-/|/'
|-project # <-- your sbt project config lives here
|-src
|---main
|-----resources
|-----scala
|---test
|-----resources
|-----scala
> cat `which sbt`
java -Xmx512M -jar `dirname $0`/sbt-launch-0.7.4.jar "$@"
> sbt
Project does not exist, create new project? (y/N/s) y
Name: fooz
Organization: nyscala
Version [1.0]: 0.0.1
scala version [2.7.7]: 2.8.0
sbt version [0.7.4]:
... getting stuff
[info] Building project fooz 0.0.1 against Scala 2.8.0
[info] using sbt.DefaultProject with sbt 0.7.4
and Scala 2.7.7
> exec find src/main/scala -iname *.scala -exec wc -l {} ;
> tree | head -14
|-lib
|-project
|---boot
|-----scala-2.7.7
|-------lib
|-------org.scala-tools.sbt # sbt power
|---------sbt
|-----------0.7.4
|-------------compiler-interface-bin_2.7.7.final
|-------------compiler-interface-bin_2.8.0.RC2
|-------------compiler-interface-src
|-------------xsbti
|-----scala-2.8.0
|-------lib
> {editor} project/build/Project.scala
import sbt._
/** Sbt will evaluate this as the project's configuration */
class Fooz(info: ProjectInfo) extends DefaultProject(info) {
// override defaults
// declare dependencies
// conjure spells!
}
> cat project/build.properties
#Project properties
#Sat Jan 29 20:16:24 EST 2011
project.organization=nyscala
project.name=fooz
sbt.version=0.7.4
project.version=0.0.1
build.scala.versions=2.8.0
project.initialize=false
lazy val projectOrganization = propertyOptional[String](name, true)
lazy val projectName = propertyLocalF[String](NonEmptyStringFormat)
lazy val sbtVersion = property[String]
lazy val projectVersion = property[Version]
lazy val defScalaVersion = property[String]
lazy val buildScalaVersions = propertyOptional[String](
defScalaVersion.value, true)
> ls lib_managed | wc -l
0
> sbt update
> ls lib_managed | wc -l
{n}
(but mostly ivy)
// fixed scala version
val a = "org.a" % "a_2.7.7" % "1.0"
// cross built (a good citizen)
val b = "org.b" %% "a" % "1.0"
// java/maven
val jc = "org.jc" % "jc" % "1.0"
// jar from where evs
val d = "d" % "d" % "2.1" from "http://somehost.com/2.1/d.jar"
val x = "repo name" at "path"
val scalaToolsSnapshots =
"Scala-Tools Maven2 Snapshots Repository" at
"http://scala-tools.org/repo-snapshots"
val m2 = "Local M2" at
"file://%s/.m2/repository" format Path.userHome
> cat /project/build/Project.scala
import sbt._
class Project(info: ProjectInfo)
extends DefaultProject(info) {
override def managedStyle = ManagedStyle.Maven
val publishTo =
"Repoz" at "http://you.com/repos/releases/"
Credentials(Path.userHome / ".ivy2" / ".credentials", log)
}
> sbt +publish
thank you for being a friend
> cat project/build.properties | grep versions
build.scala.versions 2.8.1 2.8.0 2.7.7
> sbt +update
> sbt +compile
> sbt +publish
publish local
> sbt +publish-local # publish your project locally
> mvn -o # maven's offline mode
speak louder than words
list actions
> sbt actions
> rake -T # rake's task:description listing
continuous execution
> sbt ~test
teach sbt to speak
lazy val say = task { args =>
args match {
case Array() => task { Some("say what?") }
case _ => task {
new java.lang.ProcessBuilder(
("say" :: args.toList).toArray:_*).start
None
}
}
} describedAs("chatty")
speak sbt, speak!
sbt 'say i am in your codez'
sharing is caring
make
> cat project/build/ChattyProject.scala
import sbt._
class ChattyProject(info: ProjectInfo) extends PluginProject(info)
> cat src/main/scala/Chatty.scala
package nyscala
import sbt._
trait Chatty extends Project {
lazy val say = task { ... }
}
take
> cat project/plugins/Plugins.scala
import sbt._
class Plugins(info: ProjectInfo) extends PluginDefinition(info) {
val repo = "repoz" at "http://host.com/repos"
val chatty = "nyscala" % "chatty" % "1.0.0"
}
> cat project/build/Project.scala
import sbt._
class Fooz(info: ProjectInfo)
extends DefaultProject(info)
with nyscala.Chatty {
// you can now make sbt speak
}
> sbt update run