简体   繁体   中英

Command window closing while executing gradle command from batch file

I am trying to write a very simple batch file to execute gradle commands for my java projects. I have written below script in a batch file and saved as build.bat

cd data-connector
gradle clean build -x test
gradle dist
cd..

Now the .bat file is placed in the correct folder. Trouble occurs as the execution reaches 3rd line of the script. The command prompt just stops on 3rd line, no errors nothing. All the environment variables are correctly set and permissions in place. Please point my mistake here, what I am missing. Why is this script not going beyond the 2nd line of the script.

Try replacing "gradle" with "call gradle" on 2nd and 3rd lines. Your existing invocation calls gradle.bat and never returns.

Reference: http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/call.mspx?mfr=true (you don't say which version of Windows you're using, but I think this has been the same for quite some time).

This is also answered here: Executing multiple commands from a Windows cmd script

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM