Goal: execute a program via a command line from groovy code
Option 1: executing a string
Gotchas: Take care if you wish to pass a quoted argument that contains white space – it will be split into multiple arguments, e.g.:
will invoke executable with the following arguments:
- arg1 = "first
- arg2 = with
- arg3 = space"
- arg4 = second
In such a case, you may prefer to use one of the array or list of String variations, e.g.:
Option 2: using ant builder's exec task
Ant has an exec task and it be accessed from the AntBuilder object
The good thing is that you now have all the ant features at your disposal and Ant will not break up quoted args containing whitespace.
See also: Process Management