Skip to content
This repository has been archived by the owner on Feb 22, 2019. It is now read-only.

Commit

Permalink
integrate into the compile process
Browse files Browse the repository at this point in the history
  • Loading branch information
Nathan Hamblen committed Jun 17, 2010
1 parent b5bd88b commit cfc9df6
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions project/build/Project.scala
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,13 @@ trait TypedResources extends AndroidProject {
def managedScalaPath = "src_managed" / "main" / "scala"
def typedResource = managedScalaPath / "TR.scala"
abstract override def mainSourceRoots = super.mainSourceRoots +++ managedScalaPath
lazy val generateTypedResources = task {
def xmlResources = mainResPath ** "*.xml"
override def compileAction = super.compileAction dependsOn generateTypedResources
override def watchPaths = super.watchPaths +++ xmlResources

lazy val generateTypedResources = fileTask(typedResource from xmlResources) {
val Id = """@\+id/(.*)""".r
val resources = (mainResPath ** "*.xml").get.flatMap { path =>
val resources = xmlResources.get.flatMap { path =>
val xml = XML.loadFile(path.asFile)
xml.descendant flatMap { node =>
// all nodes
Expand All @@ -39,7 +43,7 @@ trait TypedResources extends AndroidProject {
case Id(id) => try { Some(id,
// whre ids start with @+id/
ClasspathUtilities.toLoader(androidJarPath).loadClass(
// where the lable is a widget in the android jar
// where the label is a widget in the android jar
"android.widget." + node.label
).getName)
} catch { case _ => None }
Expand Down

0 comments on commit cfc9df6

Please sign in to comment.