Exec task not executing input

So Im mostly new to gradle and Im trying to convert an old android ant build to gradle. I think I have most of it figured out but one of the last things Im trying to accomplish is using the Exec task to zipalign my apk. My dev machine runs windows so I have my task set like this

task(zipAlign, dependsOn: runApkSigTool, type: Exec) { taskGraph ->

workingDir ‘C:/studiobuild/myapp/app/apk’

commandLine ‘cmd’, ‘/c’, ‘C:/software_downloads/android_sdk/sdk/sdk/build-tools/19.1.0/zipalign -f -v 4 V2.5-10-debug-20140924.apk V2.5-10-debug-20140924.apk’

//executable ‘C:/software_downloads/android_sdk/sdk/sdk/build-tools/19.1.0/zipalign -c -v 4 V2.5-10-debug-20140924.apk’

println commandLine

System.out.println("---------------------zipAlign ran for debug------------------");


When the command line prints I just see all the text that I tried to run as a command. I know Im missing something but its not very apparent from reading the documentation. Do I need to make a .bat file or something or is gradle capable of running input commands like how Im trying to use it.

If it is capable of doing what Im trying how would i be able to print out the comandline output as its running the task.

I’m not toally sure what you are asking, but those println will be running when your task is configured, not when it is run. Put your first println in a ‘doFirst’ block and your second one in a ‘doLast’ block.

Thanks for the reply :slight_smile: I guess Ill just ask in simpler terms. How can I execute things I would normally run in the command line. If I entered C:/software_downloads/android_sdk/sdk/sdk/build-tools/19.1.0/zipalign -f -v 4 V2.5-10-debug-20140924.apk V2.5-10-debug-20140924.apk It would normally either work or give me an error. So how I can I run this task just like I would from the command line