Wie unterstützen Sie eine Gradle Exec-Aufgabe für Mac und PC?

Gibt es eine Möglichkeit, eine Aufgabe unter Windows und Mac auszuführen, wenn die Befehle eine andere Form haben? Beispielsweise

task stopTomcat(type:Exec) {

    // use this command line if on Windows
    commandLine 'cmd', '/c', 'stop.cmd'

    // use the command line if on Mac
    commandLine './stop.sh'
}

Wie würdest du das in Gradle machen?