In my last post, I explained how I have setup my LibGDX game project to use Scala. No doubt it’s working but if you follow my procedure, you will face the same wall as me: it is unusable in an IDE, or at least in IDEA Intellij: no error displayed when typing, no error displayed when opening a file… The only way to see compilation errors is to ask for a full rebuild of the project each time you modify something…

So who is the culprit?

  • Scala-plugin? Scala support in IDEA Intellij 14.1 is quite good for a new project. It is not as advanced as Java is but time will make the plugin for Scala better i have no doubt on this.
  • Gradle? When launching a build with Gradle, everything compile smooth.  I have tested both desktop and android version and nothing is wrong.
  • Gradle with Scala in IDEA? Gradle is working well in IDEA for java projects but Gradle with the Scala plugin in IDEA seems not really supported. It is working but its working badly. [EDIT] Hopefully, someone from twitter help me to fix the issue: just clean your .idea config folder, upgarde Intellij/Scala plugin/Gradle to their last version and re-import projects: all issues are gone.[/EDIT]

So I decide to have a look to SBT as this is the preferred build tool for Scala projects. Scala plugin in IDEA is supporting SBT and it can’t be worse that Gradle + Scala.

I use a gitter template found on github and get a really simple project with a structure similar to the one i have with Gradle: core, desktop, android, ios. After compiling and checking that the sample project is working properly, i moved my game code in core/src/main/scala and modify two things in the Scala build task all-platforms/build.scala :

  • add the local maven repository:
  • add a new dependency for my personal game framework:
    • add a new parameter in versions.sbt :
    • Modify all-platforms/build.scala  to add this new dependency:

SBT compilation from command line is working well. If you import the project in IDEA, all is running smoothly. Changing library versions in versions.sbt  and refresh the SBT project in IDEA works perfectly like a Maven or a Gradle project.

So my advice for a Scala project is: forget Gradle and Maven and focus on SBT.