I know this because build.sbt knows this.
Unlike sbt-buildinfo
, sbt-android-buildinfo
generates xml android values file from your build definitions.
Put following in your project/plugins.sbt:
resolvers += Resolver.url("sbt-android-plugin",
url("https://raw.github.com/dant3/sbt-android-plugin/repo/"))(Resolver.ivyStylePatterns)
addSbtPlugin("com.github.dant3" % "sbt-android-buildinfo" % "0.1")
Then in your build.sbt:
android.buildinfo.Plugin.androidBuildInfoSettings
Add this to your build.sbt if you want to automatically generate build info file on packaging:
resourceGenerators in Compile <+= android.buildinfo.Plugin.androidBuildInfo
To change generated keys you can override keys setting, for example:
import android.buildinfo.Plugin._
// ...
androidBuildInfoKeys <<= name.apply{(n) => Seq(
"name" -> n,
"year" -> 2014,
"debug" -> true,
"strings" -> Array("foo", "bar", "baz"),
"ints" -> (1 to 10).toArray
)
}
To use together with android-sdk-plugin you can put following code in your build project:
import sbt._
import android.Keys._
object Tasks {
def collectGeneratedBuildInfo = (android.buildinfo.Plugin.androidBuildInfo,
projectLayout in Android).map {
(buildInfo, layout) => {
val resTarget = layout.bin / "resources" / "res" / "values"
for {
file <- buildInfo
} IO.copyFile(file, resTarget / file.getName, preserveLastModified = true)
}
}
}
And then in your build.sbt:
collectResources in Android := {
Tasks.collectGeneratedBuildInfo.value
(collectResources in Android).value
}
Apache 2.0 License