简体   繁体   English

从批处理文件执行gradle命令时关闭命令窗口

[英]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. 我正在尝试编写一个非常简单的批处理文件来为我的java项目执行gradle命令。 I have written below script in a batch file and saved as build.bat 我在批处理文件中写了下面的脚本并保存为build.bat

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

Now the .bat file is placed in the correct folder. 现在.bat文件放在正确的文件夹中。 Trouble occurs as the execution reaches 3rd line of the script. 当执行到达脚本的第3行时发生故障。 The command prompt just stops on 3rd line, no errors nothing. 命令提示符在第3行停止,没有任何错误。 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. 尝试在第2行和第3行替换“gradle”和“call gradle”。 Your existing invocation calls gradle.bat and never returns. 您现有的调用调用gradle.bat并且永远不会返回。

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). 参考: http//www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/call.mspx? mfr = true (你没有说你正在使用哪个版本的Windows,但我认为这已经有一段时间了。)

This is also answered here: Executing multiple commands from a Windows cmd script 这里也回答了这个问题: 从Windows cmd脚本执行多个命令

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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