Buildr – Keeping up with the latest and greatest
In a previous post I ran into some problems with Buildr’s support for Specs in combination with JUnit. I googled a bit and came up with nothing so I did what all newbies do. Ask the pros on the mailinglist :) (I stayed away from “plz help” and “could you plz send me a patch”). I was (of course) suggested to try the latest from head and I felt an unpleasant resistance towards downloading archives, figuring out how to point gems to the latest version etc. All of those things are probably simple but I just want to develop some Scala code and did not look forward to it.
Well, boy was I worrying in vain!
Side-note: After years of pre-switch anxiety I recently just got over myself and converted to Linux from Windows. I am a very happy Ubuntu user and I think that this post will illuminate some of the advantages I experience when it comes to software development.
The scala-support is relatively new in Buildr so it seems like a good idea to make it easy to use the latest development version of Buildr. Buildr makes it’s source available via GitHub. With my recent experiences with Mercurial I had the feeling that I would much prefer Git over Svn. Ok, let’s get started…
Keep in mind that most of the console-text you see below is output. It is actually 3 very simple steps followed by a 4th to actually test it. For your convenience I have marked everything you actually need to type in red.
Step 1 – install git
jocke@euroblok:~/dev/3rd/buildr-head$ sudo apt-get install git-core
3 seconds later:
... (Reading database ... 222430 files and directories currently installed.) Unpacking git-core (from .../git-core_1%3a1.5.4.3-1ubuntu2_i386.deb) ... Setting up git-core (1:1.5.4.3-1ubuntu2) ...
That’s how hard it is to install git :)
Step 2 – cloning the buildr repository
Now lets clone Buildr’s repository:
jocke@euroblok:~/dev/3rd/buildr-head$ git clone git://github.com/vic/buildr.git
And git starts getting the Buildr code:
Initialized empty Git repository in /home/jocke/dev/3rd/buildr-head/buildr/.git/ remote: Counting objects: 4075, done. remote: Compressing objects: 100% (945/945), done. remote: Total 4075 (delta 3061), reused 4075 (delta 3061) Receiving objects: 100% (4075/4075), 2.04 MiB | 554 KiB/s, done. Resolving deltas: 100% (3061/3061), done.
That only took a few seconds.
Step 3 – adding your repository to the path
I look in the fetched repository and in the root there is a script named _buildr that according to it’s comments should be used if you want to run buildr from source without having to do a rake install.
Not having to do stuff is exactly what I’m after, let’s make the final touch so I can use alternate between using buildr from my repository and running the latest stable version. I create a launch-script on my source-path, in my case have ~/bin on my path so I create it there like this:
jocke@euroblok:~/bin$ cat > _buildr #!/bin/sh /home/jocke/dev/3rd/buildr-head/buildr/_buildr jocke@euroblok:~/bin$ chmod +x _buildr
Just end the cat > _buildr command with ctrl+c when done typing or just use vim or whatever you prefer instead. I used cat from stdin here just to be able to show all relevant information in the post.
Step 4 – test it!
Now I can use buildr from source whenever I want by using _buildr instead of buildr when I build:
jocke@euroblok:~/dev/publisher/scala-core$ _buildr test
(in /home/jocke/dev/publisher, development)
Building publisher:scala-core
Compiling publisher:scala-core into /home/jocke/dev/publisher/scala-core/target/classes
Compiling publisher:scala-core:test into /home/jocke/dev/publisher/scala-core/target/test/classes
Running tests in publisher:scala-core
Running java com.agical.publisher.content.site.PublishSiteGraphSpec
Specification "PublishSiteGraphSpec"
specifies
o directories are nodes
Won't work until MemoryResourceRepository adds resources for directories. (PublishSiteGraphSpec.scala:19)
Total for specification "PublishSiteGraphSpec":
Finished in 0 second, 58 ms
1 example (1 skipped), 0 assertion, 0 failure, 0 error
[Completed] Your build has completed: /home/jocke/dev/publisher
buildr default
Completed in 7.667s
That was not so hard and from now on I can pull the latest code from the repository whenever I like by running…
jocke@euroblok:~/dev/3rd/buildr-head/buildr$ git pull
Already up-to-date.
…from my repository. Sweet!

Stumble It!
[...] Also, I have learned how easy it is to be on the bleeding edge with buildr and share it here [...]
Phasing over from java to scala pt. 3 - What about the tests? « The point is missed
February 28, 2009 at 9:42 am