I recently started learning Android development and I decided to follow the following development processes:
- Preinstall Scala in emulator
- Edit source files in IntelliJ IDEA 11
- Compile the project with sbt in command line
- Dex generated classes without Scala libraries
- Build APK and test in emulator
In the above steps, except step 3, I think other steps can be easily handled by command line/makefile. So here I am, I want a sample build.sbt to allow me easily specify the following information:
- Source directories
- Reference libraries
- Output directory
I am aware of sbt android plugin and sbt idea plugin but I want to avoid them for the following reason: projects generated by android plugin dex Scala libraries for each build but I want to have control on that part: I want to skip Scala libraries for development but include them for release build, which seams requires a lot of digging if I do it with the plugin but can be easily handled if it is done from command line/makefile.
If overall what I plan to do makes sense, could someone familiar with sbt provide such a sample build.sbt? I have already spent hours following sbt tutorials but felt it’s so hard to make each seemed simple change to the default behavior of sbt.
A side question, it seems that source directories added by unmanagedSourceDirectories get compiled every time regardless of the time stamp. If that’s the case, what’s the point of using sbt? I can just feed all sources files into scalac.
This is the build.sbt based on Daniel C. Sobral's answer. When I type in sbt compile, it only prints some info like "Set current project to HelloAndroid...". No compilation happens.
name := "HelloAndroid" scalaVersion := "2.8.2" unmanagedSourceDirectories := List( file("src"), file("gen")) libraryDependencies := List() // remove Scala's library from dependencies unmanagedJars := List(Attributed.blank(file("C:/bin/android/platforms/android-10/android.jar"))) target := file("target")
I didn't expect it compiles because I still need to work out the jar files but at least I should get some compiler error. Any hint?
UPDATE: the sbt compile outputs the following:
[info] Set current project to HelloAndroid (in build file:/C:/Users... [success] Total time: 0 s, completed May 14, 2012 10:36:23 AM
I have two source files in src directory:
No class file is found under target folder.