Reputation: 5857
I'm pretty new to Gradle and have to invoke a shell command and parse it's console-output.
After doing some research how to achieve this i ended up with two ways:
type: Exec
(org.gradle.api.tasks.Exec
) with commandLine
.java.lang.String
with execute
and java.lang.Process
.The question is, why should i use the Gradle-way over the Java-way or vice versa? I couldn't find any resource pointing out the difference, yet.
Upvotes: 0
Views: 294
Reputation: 84864
If what You need to do is a pretty standard task it's better to use Gradle's Exec
. It's just a wrapper that also starts a command under the hood.
If what You're looking for is a better control or untypical command or maybe a dedicated handling of result it better to use execute()
on String
(but it's better to pass command as a List
to avoid parser issues). It's more low level and needs more coding.
Upvotes: 2