How to execute a command in windows cmd using Gradle?

我的梦境 提交于 2019-12-01 02:23:36

问题


I am trying to execute this command using Gradle .

.\build\build.exe parse /p 246 /o ".\strings.xml.bcg" /novalidate /l 1033 /sr "@LbaRoot@\settings\default\lss\default.config" "..\app\src\main\res\values\strings.xml"

This works fine when I execute in command Line. I am trying to replicate the behaviour using Gradle

    task runLSBuild(type:Exec) {
    workingDir '../outer_build'

    //on windows:
    commandLine '.\\build\\build.exe','parse /p 246 /o ".\\strings.xml.bcg" /novalidate /l 1033 /sr "@LbaRoot@\\settings\\default\\lss\\default.config" "..\\app\\src\\main\\res\\values\\strings.xml"'
}

But this fails with error ".\build\build.exe", The system cannot find the file specified. I need to run the program with working directory as outer_build.

Any suggestions on where am I going wrong ?


回答1:


Ok I got the issue . Looks like for windows, we have to write like this

     task runLSBuild(type:Exec) {
    workingDir '../outer_build'

    //on windows:
    commandLine "cmd","/c",'.\\build\\build.exe parse /p 246 /o ".\\strings.xml.bcg" /novalidate /l 1033 /sr "@LbaRoot@\\settings\\default\\lss\\default.config" "..\\app\\src\\main\\res\\values\\strings.xml"'
}


来源:https://stackoverflow.com/questions/32315287/how-to-execute-a-command-in-windows-cmd-using-gradle

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!