Skip to content

Instantly share code, notes, and snippets.

@gfx
Created February 20, 2014 08:27
Show Gist options
  • Save gfx/9109139 to your computer and use it in GitHub Desktop.
Save gfx/9109139 to your computer and use it in GitHub Desktop.
AndroidAnnotationsにコントリしたい。
preBuild.dependsOn(task("generateUsageReportActivities") << {
def manifestFile = file("src/main/AndroidManifest.xml")
def manifest = new XmlParser().parse(manifestFile);
def pkg = manifest.@package
def androidNamespace = new Namespace("http://schemas.android.com/apk/res/android", "android")
manifest.find { Node node ->
node.name() == "application"
}.findAll { Node node ->
node.name() == "activity"
}.each { Node node ->
def activityClass = node.attribute(androidNamespace.get("name"))
if (activityClass[0] == ".") {
activityClass = "$pkg$activityClass"
}
Map attrs = new HashMap();
attrs.putAll(node.attributes())
attrs.put("android:name", activityClass + "_modified")
def newNode = new Node(null, node.name(), attrs);
node.replaceNode(newNode)
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment