android studio - Issue with Gradle task to write file -


i developing android application have directory of json files , want create gradle task combine these files single json file.

this gradle task have far not create file:

// task combines json files in ../libraries src/main/res/raw/libraries.json task combinejsonfiles {     string content = ""     filetree tree = filetree(dir: '../libraries', include: '**/*.json')     tree.each {file file ->         content += file.gettext()     }      println "[" + content.substring(0, content.length()-1) + "]" // prints out correct contents     file libraries = file("../app/src/main/res/raw/libraries.json")     println libraries.getproperties() } 

i print out properties , not sure why these property values:

{directory=false, canonicalfile=/users/michaelcarrano/androidstudioprojects/detective_droid/app/src/main/res/raw/libraries.json, file=false, freespace=0, canonicalpath=/users/michaelcarrano/androidstudioprojects/detective_droid/app/src/main/res/raw/libraries.json, usablespace=0, hidden=false, totalspace=0, path=/users/michaelcarrano/androidstudioprojects/detective_droid/app/src/main/res/raw/libraries.json, name=libraries.json, prefixlength=1, absolute=true, class=class java.io.file, parentfile=/users/michaelcarrano/androidstudioprojects/detective_droid/app/src/main/res/raw, absolutepath=/users/michaelcarrano/androidstudioprojects/detective_droid/app/src/main/res/raw/libraries.json, absolutefile=/users/michaelcarrano/androidstudioprojects/detective_droid/app/src/main/res/raw/libraries.json, parent=/users/michaelcarrano/androidstudioprojects/detective_droid/app/src/main/res/raw} 

any appreciated have not seemed figure out after reading documentation. http://www.gradle.org/docs/current/userguide/working_with_files.html

creating instance of java.io.file in groovy/java not create file on disk. need write it. check out tutorial working files in groovy.

also have put task implementation in task configuration block, rather task action. means code not running when expecting - run every time run gradle rather when run task. need put code in dolast block


Comments

Popular posts from this blog

java - How to specify maven bin in eclipse maven plugin? -

single sign on - Logging into Plone site with credentials passed through HTTP -

php - Why does AJAX not process login form? -