A lot of things to (hopefully) make the plugin a little easier to use. This will break your current build files and require you to change a few things, 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.
AndroidProjecthas 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. A nice side-effect is that .sbt build files now automatically import everything you would ever need.
Proguard now writes its configuration by default in the directory referenced by source-managed (usually something like target/scala-2.10/src_managed/main/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: Added support for different development configurations. Instead of having to say android:package-{debug,development,...} on the command-line, I actually find it better to use multiple configurations and just run install or package. This is why I ditched the android scope..
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.
IntelliJ integration: Use with my fork of SBTidea for now (on the android-support branch), should work out of the box! ApkLibs don't work yet, but I'm planning on fixing this.
Do not extract ApkLib dependencies in the provided scope anymore.
Example build files
The default (compile) configuration builds a development app (no Scala Library, use the preloaded one and skip Proguard).
The debug configuration builds a debug app with the Scala Library bundled in, and with Proguard.
The release configuration builds a release app package.
To run a command in a specific configuration, prefix it with the configuration name. apk will use the default development mode, while debug:apk and release:apk will each use Debug and Release settings.
To change a setting or a task for one specific configuration only, just use in, like in mySettingKey in Release := "Hello, world".
build.sbt
androidDefaults
name := "AppName"
version := "0.1"
versionCode := 0
scalaVersion := "2.10.1"
platformName := "android-16"
project/build.scala
import sbt._
import Keys._
import Defaults._
// Import the Android plugin
import org.scalasbt.androidplugin.AndroidPlugin._
object AndroidBuild extends Build {
// Global settings for all projects
val globalSettings = Seq(
name := "App",
version := "0.1",
versionCode := 0,
scalaVersion := "2.10.1",
platformName := "android-16",
)
// Main project
lazy val main = AndroidProject("main", file("."), settings=globalSettings)
// Android instrumentation tests
lazy val tests = AndroidTestProject("tests", file("tests"), settings=globalSettings)
.dependsOn(main % "provided")
.settings(name := "AppTests")
}
A lot of things to (hopefully) make the plugin a little easier to use. This will break your current build files and require you to change a few things, 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?
Notable changes
0.7-SNAPSHOT
, given the scope of the changes.AndroidProject
has been renamed toAndroidPlugin
: It extendedPlugin
, notProject
, so it makes more sense now.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. A nice side-effect is that.sbt
build files now automatically import everything you would ever need.source-managed
(usually something liketarget/scala-2.10/src_managed/main/proguard.conf
.SeqLike
) to the default Proguard configuration..sbt
build files a lot more easily for simple projects. Typical use of the plugin about 5 lines inbuild.sbt
to specify names and versions.android:package-{debug,development,...}
on the command-line, I actually find it better to use multiple configurations and just runinstall
orpackage
. This is why I ditched theandroid
scope..AndroidManifest.xml
. Added the newmanifestRewriteRules
key.usePreloadedScala
is set totrue
), automatically add theuses-library
tag inAndroidManifest.xml
.android-support
branch), should work out of the box! ApkLibs don't work yet, but I'm planning on fixing this.provided
scope anymore.Example build files
The default (
compile
) configuration builds a development app (no Scala Library, use the preloaded one and skip Proguard).The
debug
configuration builds a debug app with the Scala Library bundled in, and with Proguard.The
release
configuration builds a release app package.To run a command in a specific configuration, prefix it with the configuration name.
apk
will use the default development mode, whiledebug:apk
andrelease:apk
will each use Debug and Release settings.To change a setting or a task for one specific configuration only, just use
in
, like inmySettingKey in Release := "Hello, world"
.build.sbt
project/build.scala