sbt and maven

A few months ago I talked about my first impressions about sbt (simple build tool) here. My conclusion at the time was that NetBeans + Maven combination would suit me better. This changed a little bit, so I’m revisiting this topic to explain why.

First, I explored sbt a little more. I certainly still have a lot to learn, but I found out one thing that is making a lot of difference: you can use a maven pom file to handle your dependencies. This is great for a few reasons:

  • you can leverage your existing knowledge of pom files;
  • I’m not comfortable (yet) with the sbt own way of handing dependencies;
  • you can use tools that doesn’t support sbt directly – actually I don’t know of any that does that.

Lets elaborate some more. First, lets say you have a project that already uses maven. The first point means you can just type ‘sbt’, create an sbt project, and the tool will be able use the pom.xml file as a source for the project dependencies configuration. You will just have to use the sbt command ‘update’ after each time you change the pom file – which is very reasonable.

Second, the way sbt handles dependencies. Code. Basically, you configure the dependencies in a scala file, that gets compiled with the rest of the project. I don’t find this bad nor good. For now, I don’t have a strong opinion about this – but its still not comfortable.

Finally, the third point means you can use, say, NetBeans, with its great maven support, while using sbt as well. For a small personal project I’m currently working on, this is being very useful. My current development setup consists of NetBeans as the IDE, with sbt running in a console window in the ‘~test’ state. Every time I hit save on a source file inside NetBeans, sbt gets it, compiles and runs the tests. Yet, because I’m using an IDE instead of simple a code editor, a have full source code completion – which is really nice.

Of course this doesn’t work perfectly all the time – NetBeans gets confused from time to time and you might have to ignore some editor warnings. Nothing too bad though.

Advertisements
This entry was posted in scala and tagged , , , , , , . Bookmark the permalink.

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