Emit "browsable" sample code
The new emitBrowsable build task emits a directory structure meant
to be consumed by the sample browser.
Change-Id: Ie1488a13d33a7e57a6d3ed5bc994f85c71d33dc6
diff --git a/build.gradle b/build.gradle
index 61eb6a7..70a538b 100644
--- a/build.gradle
+++ b/build.gradle
@@ -47,8 +47,26 @@
}
task emitBrowsable(type:Copy) {
- def output = "build/browsable"
- mkdir output
- into output
+ def outputPath = "build/browsable"
+ def inputPath = "${project.projectDir}/${samplegen.targetSampleModule()}"
+ mkdir outputPath
+ into outputPath
+ ["main", "common", "template"].each { input ->
+ def srcPath = "${inputPath}/src/${input}"
+ into("src") {
+ from("${srcPath}/java")
+ eachFile { FileCopyDetails fcd ->
+ def file = fcd.name
+ def parent = fcd.relativePath.parent
+ def newPath = parent.pathString.replaceAll ('(?<=/)([^/]+)/(?!java)', {a,b -> "$b."})
+ newPath = "${newPath}/${file}"
+ fcd.path = newPath
+ println fcd.path
+ }
+ }
+ into("res") {
+ from("${srcPath}/res")
+ }
+ }
}