android - Why does gradle not run my shell script? -


i'm overlooking something.

i have android gradle project build.gradle file. inside here, specify task:

task dosomething(type: exec) {     println("okay have got getting in here")     commandline 'sh /users/dzt/desktop/create_a_file_on_desktop.sh' } 

and doesn't run @ all. shell file literally does:

#!/bin/sh echo "hi" > /users/dzt/desktop/i_am_a_byproduct.txt 

and ran chmod u+x on executable (i double checked on regular bash shell).

i tried use groovy command:

"cd ../ && sh /users/dzt/desktop/create_a_file_on_desktop.sh".execute() 

which not work either. i'm little stumped. not see output file. however, see print statement in gradle console.

what going on here?

** edit **

okay, drilled down more ->

cd ../ not work @ all. why this? need use relative path, @ least relative directory

the call must be

commandline 'sh', '/users/dzt/desktop/create_a_file_on_desktop.sh' 

or else considered one command. want start sh script param. on other hand, since have set execute-bit, can call shell script directly.

see http://gradle.org/docs/current/dsl/org.gradle.api.tasks.exec.html

running cd want cd ../ && sh script not work this, since && shell script command. if want run this, have run shell , make run command. e.g.

commandline 'sh', '-c', 'cd ~/scripts && sh myscript.sh' 

Comments

Popular posts from this blog

c++ - Difference between pre and post decrement in recursive function argument -

php - Nothing but 'run(); ' when browsing to my local project, how do I fix this? -

php - How can I echo out this array? -