Pages

Monday, June 10, 2013

First attempt with scala

I decided to try scala once again (all previous attempts did not last long). I have not read any book about scala so far, and this is just dummy attempt, so I tried to use everything that I already know from Java. To my luck I have stumbled on the project by Graham Lea that uses maven for building, spring-mvc as the web-framework and hibernate as a database access layer. This project actually works, so it is possible to try it moving from one working state of the project to the other.
What I have done in my fork so far:

  • maven-eclipse-plugin is a deprecated way of generating Eclipse project files for the maven project, since Eclipse itself has a pretty good support for maven-basd projects. However inside the stable version of Scala-ide a rather old version of Eclipse is used internally, so maven support is not so great, but still it is good enough to not use maven-eclipse-plugin. So I removed its configuration from the project.
  • Selenium tests was the part that didn't work for me in this project (probably because I'm on Linux), so I removed them and started tests using spring-test library.
  • The latter required spring framework upgrade. Also I have upgraded Hibernate and scala and scala-maven-plugin to the latest versions. This required a bit of editing the scala sources and changing the scala-ide installation since different versions are required for scala 2.9.x and 2.10.x.
  • I migrated the project from using Hibernate SessionFactory to EntityManager and spring-data-jpa (scala traits can be used as spring-data repository interfaces). It seems that this way of using Hibernate is a bit more up-to-date and is free from issues like this one, that I trapped into some time ago.
Glitches that I have stumbled over are about Scala-ide and both can be seen in this file:

  • Organizing imports action removes imports in use making compilation to fail (in the file mentioned SpringJUnit4ClassRunner import is removed, but I have seen this in other situations too)
  • Formatting the source remove comments (in the file mentioned the "//TODO..." comment is removed)
So now is the time to read something about scala and all the surrounding magic. Any thoughts on what book or resource should I read?

No comments:

Post a Comment