Scala Simple Build Tool — Not so simple after all, at least for now…

Update:I got sbt working by building directly from the master branch from their github repo. The current version is 0.7.5. The tagged 0.9.4 version is actually an older version. Anyway, tried it and kinda loved it.

This is just another late night rambling…I was trying to get a proper scala build system setup. I was using Maven scala plugin for a while, but longing for something simpler and more scalanic (is there such a word?). I was pretty happy at Cake, the Clojure build system and expected SBT to allow me to break away from using Maven to build Scala projects…boy, was I wrong…

First off, when you google ‘simple build tool’, you get a link to the SBT Google code home page. Well, nothing wrong there, except the “latest” version on Google code was 0.7.4 and it was half a year ago…Maybe it’s not that outdated, so I downloaded it, followed this instruction and setup my ~/bin/sbt script. Running it, it asked me to setup projects, and it only supported up until Scala 2.7.7…Hrm, 2.8 was out for a while now, so obviously, SBT 0.7.4 isn’t the latest. Reading their home page more carefully, they’re moving the repository to Github. Awesome! I’d pick Github over Google Code any time too.

Heading over to their Github repo, and found the latest stable version is 0.9.2. Good! So it should support Scala 2.8 now! Downloaded the zip, unzipped it, and of course it wasn’t executable. You need to build it. There’s a README.md, so quickly I less’ed it. For step 1, it asked me to go to the setup wiki page on Google Code (!), which is the steps I did setting up 0.7.4…I guess they’re using 0.7.4 as a bootstrapping build…Anyways, I did that. Step 2 was to run `sbt update “project Launcher” proguard “project Simple Build Tool” “publish-local”`. Of course it didn’t work. It’s complained 0.7.4 version of sbt-launch can’t download Scala 2.7.7 from any of the repository…bummer! But hey, I can download Scala 2.7.7 lib from Maven! So I quickly updated pom.xml of one of my projects to use Scala 2.7.7 and did an upgrade. Now 2.7.7 is happily in my local Maven repo. Ran that command again, hooray! It started to build, and judging by the number of packages it’s building, “simple” isn’t the first adjective that comes into my mind. Anyway, it’s building at least, so even if it’s a little complicated, so be it…Except…of course it broke half way… and why?

[info] Post-analysis: 107 classes.
[info] == Precompiled 2.7.7 / compile ==
[info]
[info] Precompiled 2.8.0 / compile …
[info]
[info] == Precompiled 2.8.0 / compile ==
[info] Source analysis: 9 new/modified, 0 indirectly invalidated, 0 removed.
[info] Compiling main sources…
[warn] there were deprecation warnings; re-run with -deprecation for details
[warn] one warning found
[info] Compilation successful.
[info] Post-analysis: 108 classes.
[info] == Precompiled 2.8.0 / compile ==
java.lang.OutOfMemoryError: PermGen space
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClassCond(ClassLoader.java:632)
at java.lang.ClassLoader.defineClass(ClassLoader.java:616)

You’ve gotta be kidding me! I set -Xmx512M and it’s not enough? And why is it building every version of Scala *from source*?? Is there something called a…JAR?

Anyway, increased -Xmx from 512 to 1024M, ran again, wait, and same thing happened again! Out of PermGen space…urrgh…

I decided to give up, at least for the day… SBT is anything but simple, at least from my experience. I know it’s open source and people put efforts into it without compensation, so I shouldn’t be critical about it. I’ll give it a try again, and hopefully it’s worth the time investment.

About these ads
Leave a comment

6 Comments

  1. Jurjen Vorhauer

     /  March 19, 2011

    Actually PermGen has nothing to do with heap, which is specified by -Xmx; therefore increasing -Xmx to 1024m did not help (which is actually redundant as this was already shown by the repetition of the error message :-)).
    This is explained @ http://www.oracle.com/technetwork/java/javase/tech/vmoptions-jsp-140102.html.
    In short: use -XX:MaxPermSize=256m, which should be more than adequate… This is what I use for my sbt script:
    java -XX:+CMSClassUnloadingEnabled -XX:MaxPermSize=256m -Xmx512m -Xss2m -jar /opt/local/lib/sbt-launch-0.7.5.RC0.jar “$@”
    As can be seen, this is using the last non xsbt version, 0.7.5.RC0 and not even the newer 0.9.x version.

    Regards, Jurjen.

    Reply
    • Thanks. I actually figured it out. I compiled the latest master and it worked. nice build system. i need to update my post :)

      Reply
  2. itemState

     /  March 20, 2011

    hey dude, calm down. sbt 0.7.4 perfectly supports scala 2.8.0/2.8.1 projects. it’s only that it’s own bootstrapper is still using scala 2.7!

    $ sbt
    Project does not exist, create new project? (y/N/s) y
    Name: Test
    Organization: com.test
    Version [1.0]:
    Scala version [2.7.7]: 2.8.1
    sbt version [0.7.4]:
    Getting Scala 2.7.7 …
    :: retrieving :: org.scala-tools.sbt#boot-scala
    confs: [default]
    2 artifacts copied, 0 already retrieved (9911kB/270ms)
    Getting org.scala-tools.sbt sbt_2.7.7 0.7.4 …
    :: retrieving :: org.scala-tools.sbt#boot-app
    confs: [default]
    15 artifacts copied, 0 already retrieved (4096kB/166ms)
    [success] Successfully initialized directory structure.
    Getting Scala 2.8.1 …
    :: retrieving :: org.scala-tools.sbt#boot-scala
    confs: [default]
    2 artifacts copied, 0 already retrieved (15118kB/380ms)
    [info] Building project Test 1.0 against Scala 2.8.1
    [info] using sbt.DefaultProject with sbt 0.7.4 and Scala 2.7.7
    >

    Reply
  3. Boy, you are right! I am experiencing the same difficulties. BTW, did I mention there is simply no such thing as “domain specific language for project building and management”? I think that SBT is a brilliant example of DSL overuse. Maven, with all its “tons of XML”, is about thousand times simpler to me.

    And moreover, I have a strange feeling that something is fundamentally wrong with the direction in which Scala development moves. When I switched to Scala from Java, the rationale behind this was simple: Scala is as powerful as Java, it removes its annoyances and brings powerful functional features to make code more concise, more readable, more simple. I even started the Circumflex project: I was hoping that Scala has learnt all the bitter lessons of Java enterprise. I was hoping that Scala is there to simplify things around.

    And what do we see now? Lots of tools and libraries try to support the fast pace of Scala development, but they can’t. Scala core API is a huge mess (sorry, guys, but it is true) which gets even bigger with every release. Lack of Scala micro-kernel (only core language features) lead to the worst programming practices ever, such as cross-compilation.

    I ain’t complaining. And of course I didn’t mean to offend anyone out there. It just sucks to see on of the most brilliant ideas being spoiled.

    Reply
  4. I completely agree: there is nothing “simple” about the Simple Build Tool. (Why is it that every language has to reinvent the wheel?)

    I tried building from Google Code and it said that JNA could not be found; now I’ve got the git repo version and it can’t find org.fusesource.jansi.

    On top of this, I now have:

    * Scala 2.7.7 (Ubuntu package)
    * Scala 2.8 (Typesafe)
    * Scala 2.7.7 (original SBT)
    * Scala 2.9.1 (new SBT)

    Must everything have its OWN copy of Scala? VERY frustrating… I’d rather use GNU Make and GNU m4 – at least they work and don’t require boatloads of other apps to do it.

    Reply
  1. Scala Simple Build Tool — Not so simple after all, at least for now…

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

%d bloggers like this: