Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to execute a command in windows cmd using Gradle?

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 ?

like image 911
Abhik Avatar asked Aug 31 '15 15:08

Abhik


People also ask

How do I run a gradle command in Windows?

Press ⌃⌃ (macOS), or Ctrl+Ctrl (Windows/Linux), type "gradle" followed by the gradle task name or names. We can, of course, run Gradle commands from the terminal window inside IntelliJ IDEA. Open this with ⌥F12 (macOS), or Alt+F12 (Windows/Linux).

How do I run a gradle test in CMD?

Use the command ./gradlew test to run all tests.

How do I pass a gradle argument in command line?

We first read the arguments from a project property. Since this contains all the arguments as one string, we then use the split method to obtain an array of arguments. Next, we pass this array to the args property of our JavaExec task.

How do I run a program in gradle?

You can run the application by executing the run task (type: JavaExec). This will compile the main source set, and launch a new JVM with its classes (along with all runtime dependencies) as the classpath and using the specified main class.


1 Answers

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"'
}
like image 151
Abhik Avatar answered Oct 11 '22 16:10

Abhik