jberkel/android-plugin — pull request #175 by fxthomas (2013-05-17 12:33:24+00:00)
Title: Spring cleaning

A lot of things to (hopefully) make the plugin a little easier to use. This will break your builds, but I tried to make both the plugin source _and_ your build files easier to read and understand. Tell me what you think of it.

### Questions?

* Do you think we need to release a 0.6.4 version along with it?

* Making a wrapper around the changes so that old build files still work is probably going to be rather straightforward. Is there a need for it though?

### Notable changes

* I took the liberty of **bumping the version to `0.7-SNAPSHOT`**, given the scope of the changes.

* `AndroidProject` **has been renamed** to `AndroidPlugin`: It extended `Plugin`, not `Project`, so it makes more sense now.

* Before, we had to import multiple objects (`AndroidProject`, `AndroidKeys`, `AndroidNdkKeys`,...) to be able to use the plugin. Now all you have to do is **import one object**, `AndroidPlugin`, and you're done.

* Proguard now writes its configuration by default to `target/proguard.conf`.

* Added a few flags (such as the ever-annoying `SeqLike`) to the default Proguard configuration.

* The two improvements above also let you use `.sbt` build files **a lot more easily for simple projects**. Typical use of the plugin about 5 lines in `build.sbt` to specify names and versions.

* **Development modes (Preview)**: Added preliminary support for different development modes. Instead of having to say `android:install-{debug,development,...}` on the command-line, I actually find it better to use multiple projects and just run `android:install` or `android:package`. You can find the default `androidDevelopment`, `androidDebug` and `androidRelease` settings in `AndroidPlugin` -- Debug and Release both do a standard build (include the Scala library, use Proguard, do not preload), but Development actually works, which is kinda nice ;)

* Improved how we automatically manage `AndroidManifest.xml`. Added the new `manifestRewriteRules` key.

* In development mode (i.e. if `usePreloadedScala` is set to `true`), automatically add the `uses-library` tag in `AndroidManifest.xml`.

### Example build files

#### `build.sbt`

```sbt
androidDevelopment

name := "AppName"

version := "0.1"

versionCode := 0

scalaVersion := "2.10.1"

platformName in Android := "android-16"
```

#### `project/build.scala`

```scala
import sbt._
import Keys._
import Defaults._

import org.scalasbt.androidplugin.AndroidPlugin._

object AndroidBuild extends Build {
// Global settings for all projects
val globalSettings = Seq(
version := "0.1",
versionCode := 0,
scalaVersion := "2.10.1",
platformName in Android := "android-16",
)

// Custom settings for the main project
val mainSettings = globalSettings ++ Seq(
name := "AppName"
)

// Custom settings for the test project
val testSettings = globalSettings ++ Seq(
name := "AppNameTests"
)

// Main project
lazy val main = Project("main", file("."))
.settings(androidDevelopment: _*) // Include Android development settings
.settings(mainSettings: _*) // Include custom settings

// Release project
lazy val release = Project("release", file("."))
.settings(androidRelease: _*) // Include Android release settings
.settings(mainSettings: _*) // Include custom settings

// Unit tests
lazy val tests = Project("tests", file("tests"))
.settings(androidDevelopment: _*) // Include Android development settings
.settings(androidTest: _*) // Include Android test settings
.settings(testSettings: _*) // Include custom test settings
.dependsOn(main)
}
```