As already mentioned, you cannot do this with the library, because sampledata simply cannot be part of the Android library.
However, you can place the names file somewhere, and then extract it using the gradle task, you can simply add build.gradle to the application
clean.doFirst { println "cleanSamples" def samplesDir = new File(projectDir.absolutePath, "sampledata") if (samplesDir.exists()) { samplesDir.deleteDir() } } task fetchSamples { println "fetchSamples" def samplesDir = new File(projectDir.absolutePath, "sampledata") if (samplesDir.exists()) { println "samples dir already exists" return } samplesDir.mkdir() def names = new File(samplesDir, "names") new URL('http://path/to/names').withInputStream { i -> names.withOutputStream { it << i } } }
Here you can see 2 functions, the first of which is performed before the clean task, and it will simply delete your sampledata folder. The second is the task performed on each assembly, it will not download the file every time, but only if the directory does not exist.
I understand that you can also copy the paste names file, but with this method you need to copy the paste only once, and you can change the names in any project by simply uploading a new file and doing a clean build.
lelloman
source share