aboutsummaryrefslogtreecommitdiff
path: root/artifacts.gradle
diff options
context:
space:
mode:
authorAllan Wang <me@allanwang.ca>2017-07-22 16:08:08 -0700
committerGitHub <noreply@github.com>2017-07-22 16:08:08 -0700
commit61d87976e8b29ed25061ae98743a6cf4f4274542 (patch)
treefa4d9bca5fe1b9478ba2f1cc1e6c7d8d18bf15ce /artifacts.gradle
parent8f2b5ac043f47cc44f43c3788d1377083fb339a2 (diff)
downloadkau-61d87976e8b29ed25061ae98743a6cf4f4274542.tar.gz
kau-61d87976e8b29ed25061ae98743a6cf4f4274542.tar.bz2
kau-61d87976e8b29ed25061ae98743a6cf4f4274542.zip
Support sdk 19 where possible and add image picker (#10)3.0
* Fix plural * Switch to long * Test plural again * Comment * Major update to image picker and view utils * Make image activity full screen * Update min sdk and prefix * Lower sdk requirement and make string private * Bring kpref activity to sdk 19
Diffstat (limited to 'artifacts.gradle')
-rw-r--r--artifacts.gradle74
1 files changed, 74 insertions, 0 deletions
diff --git a/artifacts.gradle b/artifacts.gradle
index 6db3cfb..12dd3fa 100644
--- a/artifacts.gradle
+++ b/artifacts.gradle
@@ -1,3 +1,5 @@
+import groovy.xml.MarkupBuilder
+
apply plugin: 'com.github.dcendents.android-maven'
// build a jar with source files
@@ -22,4 +24,76 @@ task javadocJar(type: Jar, dependsOn: javadoc) {
artifacts {
archives sourcesJar
archives javadocJar
+}
+
+// Task to generate our public.xml file
+// See https://developer.android.com/studio/projects/android-library.html#PrivateResources
+// We assume resources within res-public are public
+task generatepublicxml {
+
+ def resDir = project.projectDir.absolutePath + "/src/main/res-public"
+
+ def publicFolder = file(resDir + "/values")
+ if (!publicFolder.exists()) publicFolder.mkdirs()
+
+ // Include the desired res types
+ // Note: we don't need the qualified resource directories,
+ // since those resources will already be defined in the unqualified directories
+ // however, there are special cases like transition-v21 that is only available on lollipop and up
+ def tree = fileTree(dir: resDir,
+ includes: ['**/anim/*.xml',
+ '**/color/*.xml',
+ '**/drawable/*.xml',
+ '**/layout/*.xml',
+ '**/transition-v21/*.xml',
+ '**/values/*.xml'
+ ],
+ exclude: '**/public.xml'
+ );
+
+ // Create new public.xml with writer
+ new File(resDir + "/values/public.xml").withWriter { writer ->
+ // Create MarkupBuilder with 4 space indent
+ def destXml = new MarkupBuilder(new IndentPrinter(writer, " ", true));
+ def destXmlMkp = destXml.getMkp();
+
+ // GIST NOTE: our project needed the ResourceName suppression, but its not needed in general
+ destXml.resources(
+ 'xmlns:tools': 'http://schemas.android.com/tools',
+ 'tools:ignore': 'ResourceName'
+ ) {
+ // Leave file comment
+ destXmlMkp.yield "\r\n"
+ destXmlMkp.comment("AUTO-GENERATED FILE. DO NOT MODIFY. public.xml is generated by the generatepublicxml gradle task")
+
+ if (tree.isEmpty())
+ "public"("name": "dummy", "type": "id")
+ else
+ tree.each { resFile ->
+
+ // use the directory name to get the type
+ def type = resFile.getParentFile().getName()
+
+ if (type == "values") {
+ // Resource files under values. Parse the file, and pull out the resource definitions
+ def parsePublicResources = new XmlParser().parse(resFile)
+ parsePublicResources.children().each {
+
+ // Type is usually the element, but sometimes a type attribute is present
+ // example: <item name="line_spacing_multiplier" format="float" type="dimen">1.4</item>
+ type = it.name()
+ if (it.@type) {
+ type = it.@type
+ }
+
+ // it.@name is value in name=
+ "public"("name": it.@name, "type": type)
+ }
+ } else {
+ // Drawable, layout, etc files
+ "public"("name": resFile.getName().tokenize('.')[0], "type": type.tokenize('-')[0])
+ }
+ }
+ }
+ }
} \ No newline at end of file