How to get Apache Maven to build scala projects?

How to get Apache Maven to build scala projects?

Download the file gol3.zip from [5] (at the very end of the page) and unpack the contained pom.xml. Make it to your pom.xml by adapting it to your project. The go to [1] and copy+paste the part for surefire plugin into your pom.xml and the import and @RunWith in your scalatests.

The full story

If you google for that, you’ll most probably find [1] and [2]. But both ([2] is an refrence to [1]) failed. Of cource i copied the needed import and @RunWith in my scalatests and compiled them. The error was:

Without surefire plugin: Not tests are found

With surefire plugin:


[INFO] ————————————————————————
[ERROR] FATAL ERROR
[INFO] ————————————————————————
[INFO] scala/ScalaObject
scala.ScalaObject
[INFO] ————————————————————————
[INFO] Trace
java.lang.NoClassDefFoundError: scala/ScalaObject

This affected also others (Thanks to Kenneth McDonald for asking in [3], [4] and [5]).  The key to the solution was found by Nayan Hajratwala in the Apache Maven forum [5]: He gave us in his last answer on this thread a file named gol3.zip. It containes a pom.xml which – as it is – no tests found. But i realised that the surefire plugin was missing! So i added the tag for the surefire plugin from [2] – AND IT WORKS!!! Thanks so much!

Examples_for_working_pom_xmls

Testcases wich works with this pom.xmls:
http://decisiontable.sourceforge.net -> DecisiontableLib
http://myflipflops.sourceforge.net -> Toolbox

[1] JPZ’LOG ScalaTest in Maven

[2] Is there a Scala unit test tool that integrates well with Maven?

[3] Closer, but still problems with maven an scalatest

[4] Still problems with IDEA/maven/scala test phase

[5] Problems with Scala unit testing

PS: At the very end i decided to use Gradle for my scala builds. Although i got Maven to run and read 50% of  „Maven by example“ and „Maven complete reference“ provided by sonatype, the company behind Maven, i found Gradle easier to handle.

Veröffentlicht in Apache Maven, Scala, Scalatest, Tools. Kommentare deaktiviert für How to get Apache Maven to build scala projects?
%d Bloggern gefällt das: