Monday, 13 September 2010

Converting Meditation Helper to Scala: Creating the Scala Project

Now that I have managed to install both the Scala IDE and Android plugins into the same instance of Eclipse, the next stage is to create a new Android project for the Scala version. To do that, I'm going to use the Android plugin for sbt, described at http://zegoggl.es/2009/12/building-android-apps-in-scala-with-sbt.html.
  • First things first - I need a version of Scala installed outside Eclipse. I will use the IzPack installer from http://www.scala-lang.org/downloads.
  • That was easy. Once it was installed all I had to do was add the ~/scala/bin directory to my PATH.
  • Now to follow the instructions at zegoggles to install sbt.
  • All seems good so far. Now to generate the project using the android-plugin listed on that page, and the instructions.
  • ../android-plugin/script/create_project MeditationHelperScala com.nwalex.meditation.scala --api-level 7
  • I've used a different package name so that I can install this version side by side with the current version on my phone. I will need to change this before I deploy the new version to the market.
  • Ah, that worked well but doesn't have Eclipse integration. 
Let's try another approach.
  • Using the instructions at https://www.assembla.com/wiki/show/scala-ide/Developing_for_Android I...
  • Created a new Android project in Eclipse using the wizard.
  • Created the Ant files using: android update project --target 1 --path .
  • Followed the directions to customize the ant file and the rest of the instructions and...
  • IT WORKS!!!
To stop Eclipse and Ant getting in the way of each other, I changed the build.properties so that the Ant generated classes go into gen-ant, and builds into bin-ant.

With the external build tool configuration I can now edit the files in Eclipse using the Scala perspective, and run ant to do the build and install to the emulator.

Now I can get cracking with the conversion.

No comments:

Post a Comment