Scala & Maven – POM Example

Today, there is no waffle about what Scala or Maven is. This is just the plain configuration to build Scala projects with Maven. If you want more detailed information check Maven for Beginners at scala-lang.org or browse through the documentation of the Scala-Maven-Plugin.

By the way,the configuration works as well if you want to mix Java and Scala within a single project. Just place your scala files in src/main/scala and your Java files in src/main/java (or the src/test equivalents). Maven will do the rest for you.

Enjoy!

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <groupId>my.company</groupId>
  <artifactId>my-artifact</artifactId>
  <packaging>jar</packaging>
  <version>1.0-SNAPSHOT</version>

  <repositories>
    <repository>
      <id>scala-tools.org</id>
      <name>Scala-tools Repository</name>
      <url>http://scala-tools.org/repo-releases</url>
    </repository>
  </repositories>
  <pluginRepositories>
    <pluginRepository>
      <id>scala-tools.org</id>
      <name>Scala-tools Repository</name>
      <url>http://scala-tools.org/repo-releases</url>
    </pluginRepository>
  </pluginRepositories>

  <dependencies>
    <dependency>
      <groupId>org.scala-lang</groupId>
      <artifactId>scala-library</artifactId>
      <version>2.9.1</version>
    </dependency>
    <dependency>
      <groupId>org.scalatest</groupId>
      <artifactId>scalatest_2.9.1</artifactId>
      <version>1.6.1</version>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>4.10</version>
      <scope>test</scope>
    </dependency>
  </dependencies>

  <build>
    <plugins>
      <plugin>
        <groupId>org.scala-tools</groupId>
        <artifactId>maven-scala-plugin</artifactId>
        <executions>
          <execution>
            <goals>
              <goal>compile</goal>
              <goal>testCompile</goal>
            </goals>
          </execution>
        </executions>
        <configuration>
          <jvmArgs>
            <jvmArg>-Xms64m</jvmArg>
            <jvmArg>-Xmx1024m</jvmArg>
          </jvmArgs>
        </configuration>
      </plugin>
    </plugins>
  </build>
</project>

Getting started with Scala

Update: Scala Documentation (an excellent site for getting started with Scala) has just been launched. Make sure to check it out as well.

If you want to get started with Scala, here is a short list with (in my opinion) some of the most important resources to get you on the fast track.

  1. Get a book! I highly recommend this one, but there are plenty out there already.
  2. Install SBT and learn how to use it. (You might as well use Maven with Scala if you really want to.)
  3. Install Scala IDE for Eclipse and use sbteclipse to import your SBT projects.
  4. Get some friends out there, and learn.
  5. And not to forget my personal favourite for quick hacks: Simply Scala
  6. Enjoy!

First Dobule Challenge – Less meat, more clouds

I am quite a fan of Lars Vogels’s Challenge of the Month. That is why I decided to introduce a similar category on my blog. But, as I don’t want to be a typical European copy-cat, I will do it slightly different. Every month I will set up a double challenge for myself. Including one IT concerned challenge and one non-IT concerned challenge. By doing this, I hope it will a) improve my writing, b) improve my IT-skills and c) improve some other areas in my live.

So my first double challenge will be:

ISO-3166-1 Country List as SQL Script

How often do you need a drop-down in your application that displays all countries? And in most cases you need it in more than one language, right. I’ve been there a couple of times and finally decided to publish an sql script that could be used to create a countries table and fill it with all countries according to ISO-3166-1.

It took me some time to scan different sources and create my own countries.sql. And that was the main reason for setting up this post, I couldn’t find a page or blog post that had a ready-to-apply SQL script. When I was looking for the spanish translations, I finally stumbled upon Mega Database and its wonderful lists of everything. So you can either go to their page and get your own export of the data, or simply download the script I have attached to this post.

Thanks to http://www.mega-db.com.ar for the lists and enjoy displaying those country drop-downs.