18

I'm automating the publication of my Android app and I'm using Gradle, great utility!

Just a problem, consider this .bat file (under Windows 7):

:: assemble the project
gradle assemble -Pprofile_name=%profile_name% -p%destination_dir%

::copy apk to repository
copy "D:\compile\myapp\build\apk\*.apk" "d:\build_repository"

Well the copy command is never executed, never. It seems that the execution stops after calling gradle utility. Any idea?

The build within Gradle has ends with success and no error at all...

Seraphim's
  • 12,559
  • 20
  • 88
  • 129
  • 1
    I don't know the answer to the question (it may not be Gradle specific), but I do recommend to do the copying with Gradle. – Peter Niederwieser Sep 22 '13 at 14:12
  • Do you have a nice link that explains how to copy the output apk to a folder? – Seraphim's Oct 07 '13 at 12:57
  • Possible duplicate of [How to execute more than one maven command in bat file?](http://stackoverflow.com/questions/6573062/how-to-execute-more-than-one-maven-command-in-bat-file) – OhadR Dec 24 '15 at 10:15

2 Answers2

28

I ran into this very same problem, but for a webapp. Gradle isn't necessarily the issue, but how you are invoking it. As explained in this post,

How to execute more than one maven command in bat file?

because gradle is a batch file itself, it completes execution and doesn't return control back to your batch file. Use the same 'call' strategy and everything should work. Like so for your original post,

call gradle assemble -Pprofile_name=%profile_name% -p%destination_dir%

::copy apk to repository
copy "D:\compile\myapp\build\apk\*.apk" "d:\build_repository"
Community
  • 1
  • 1
kmek
  • 1,166
  • 1
  • 11
  • 14
-1

If you are on ionic/cordova and batch execution is stopping after ionic cordova build --release android use call before

call ionic cordova build --release android

Raj Nandan Sharma
  • 3,694
  • 3
  • 32
  • 42