Build a mixed Scala 2.8/Java application from scratch with Maven [Eclipse Settings]

[EDIT 15.01.2011]
There have been changes since i wrote this article. Although i don’t have experiences with it until know, I would suggest using the m2eclipse-scala Plugin which solves some bugs that occur when using the regular M2Eclipse plugin.

Now i’m going to show you how to open the Maven project from Part 1 with Eclipse and what you have to care about when developing Scala/Java/Maven within Eclipse. It’s very easy to setup, but it took me a while so maybe it helps someone out there.
I’m using Eclipse version 3.5.2.

Before opening the Maven project with Eclipse, we need to download the M2Eclipse plugin and do some other adjustments to eclipse. M2Eclipse will handle all dependencies for our project and will build it automatically.

You can get the M2Eclipse-plugin from this update site:
http://m2eclipse.sonatype.org/sites/m2e
M2eclipse needs Eclipse to use the JDK as the JVM (the default setting is the JRE). So if you get an error from M2Eclipse saying that Eclipse should be run with the JDK, you have to alter the Eclipse.ini, inserting the path to your JDK.
Insert your JDK path before the vmargs. A sample Eclipse.ini for a windows system looks like this (when using Debian/Ubuntu, Eclipse seems to use the JDK automatically):

Read More »

Posted in General | Tagged , , , | 2 Comments

Build a mixed Scala 2.8/Java application from scratch with Maven

In this tutorial I will show you how to build an application by Maven that consists of Java and Scala source files. The project automatically uses the latest Scala 2.8-Snapshot until it’s released (Maven will look for the latest version of the Scala language each time you build it).
We will setup the project to use cross-compiling, so the java-classes can access Scala-classes and vice versa.

The good thing about maven projects is that you don’t need an IDE to start a project, thus remaining independent from certain IDE-features. In my next article, i will show how to configure eclipse to open the maven project. But for now i’ll show how to create the project from command line only.

If you’re impatient and just want to see the resulting pom.xml, you can also download the complete source:
Complete maven project

Read More »

Posted in General | Tagged , , | 14 Comments

Eclipse: assign keyboard shortcut to a specific run configuration

A few days ago, i tried to find a possibility to assign a keyboard shortcut to a specific run configuration in eclipse (i have 4 different confs in my current project).
As it seems to me that there is no built-in solution nor a plugin to set a keyboard shortcut to a specific run conf, and as i dont have time to learn eclipse plugin development (in the moment), i found a NICE tool to do things like this: The Sikuli IDE..

Sikuli is a visual technology to search and automate graphical user interfaces (GUI) using images (screenshots).

So i wrote a Sikuli Skript which clicks on the corresponding eclipse buttons and voilĂ  – i can assign a keyboard shortcut to a specific run conf.
My Sikuli Skript looks like this:

Sikuli Eclipse Run Config

Works fine for me. The last thing to do is to assign a keyboard shortcut on Windows which starts this script.
I’m looking forward to the next tasks i could automate with Sikuli! It’s easy and fun, like programming for children…

Posted in General | Tagged | Leave a comment

Scala – an alternative console scripting language?

[EDIT 15.01.2011]
This post doesn’t reflect my opinion about Scala as a console scripting language anymore. I’m currently using Python for everyday-tasks, which i find pretty much simpler and quicker to solve problems. As you often have to use Java libraries inside Scala, writing code is often still cumbersome and full of Java-style-boilerplate. So the script really has to get to a reasonable amount of complexity so that it’s worth using Scala.

Since 3 month i’m programming in Scala now. As a Java-programmer i was not very happy at first with Scala’s kind-of uncommon syntax. But after some time i realized the conciseness of Scala code. So i started to write my allday-tools (file operations etc.) with Scala instead of Java.
I’m really impressed when i can “compress” 5 lines of Java into one single Scala line…

Today i discovered that you can also use Scala as an replacement for console scripting languages (Batch under windows, Bash/Perl under Linux/Cygwin).
Okay, Python and Ruby are also good console languages.
But cause i program a lot of Scala at the moment, i thought it would be more convenient for me to also use Scala for console scripting.
The Scala package contains – like Ruby and Python do – its own console to test code snippets and more. So unlike in Java, you can also do real scripting in Scala.

The advantages:

  1. I can re-use my Scala-scripts in larger programs later – even in Java projects
  2. In my script i have access to the COMPLETE JDK and i can put other Java/Scala-Libraries into my Classpath to use in a script
  3. I can improve my Scala-skills
  4. I can do all file opertations on a high and object oriented level – for me that is much easier than writing Bashscripts (or the even more horrible Batch-scripts)
  5. Because i can do functional-like programming, i get small and readable scripts
  6. If the scripts gets more advanced, i can use the wonderful Swing-Wrapper to create a GUI for my script

Read More »

Posted in General | Tagged | 4 Comments

Eclipse: Color your console

I just discovered a very useful plugin for Eclipse: Grep Console.

With Grep Console, you can color lines in your Eclipse console if they match a specific regular expression. For example my beloved “BUILD SUCCESS” when working with Maven – which looks like this:

Grep Console Ergebnis
Read More »

Posted in General | 2 Comments

Repository-visualization with Gource

During the lecture “software project”, me and my team (5 members) made a web application with JBoss Seam 2.2. After 2 semesters of hard work, we had a subversion-repository with as much as 999 revisions.

Now i discovered Gource, with which you can visualize the development of a repository over the time. So Gource created the following video after some hours of rendering:


Read More »

Posted in General | Leave a comment