Tuesday 8 July 2014

Gradle: escaping spaces in arguments for the task “type:Exec”

Gradle have problems when try to pass many arguments to its task with the type of "Exec".
The more accurate the problem is decribed here: http://stackoverflow.com/questions/20613244/gradle-execute-task-typeexec-with-many-arguments-with-spaces

The solution is simple: path the parameters as arguments list, like this:

 task callProfileDelete(type: Exec) {
      description = 'Delete profile with wsadmin.'
      executable = manageProfilesFile
      args = ["-delete", "-profileName", "My profile name"]
 }

In this case you will path always the correct number of arguments and the "space" will escaped nicely.

No comments:

Post a Comment