I faced a problem when executing external program with Gradle. Hope you will help me to solve this. Thank you all
PS: I used Gradle for an embedded project (C language not a Java project)
I will describe my problem:
My development environment is Ubuntu.
I used an external program for Unit test (It is called Cantata), From Linux I will type a command â./cantppâ to invoke its GUI (eclipse based)
After finishing working on GUI I will integrate last result to Gradle so that Gradle will invoke a command line to generate Test Report.
The command line like below:
$CANTATA_INSTALL_DIR/cantpp -application com.ipl.products.eclipse.cantpp.testscript.TestSummaryGenerator -noSplash -data Cantata/UnitTest project=Cantata/UnitTest/abcdef 1 (with this command like on shell the GUI will not be invoked by option â-noSplashâ, and I get the report successfully)
Is it resolved or not, I tried the below code and it was working.
def cmd = commandLine
def process1 = cmd.execute()
process1.waitFor()
println âOutput: ${process1.text.trim()}â
Your question is not really related to the thread.
Of course you can use Javaâs ProcessBuilder as OP does,
or Groovyâs .execute() like you do
to execute some external process, you just shouldnât,
but instead as Stefan said use a task of type Exec or an exec { .... } block.
But besides of that, the question here said not, that it is not possible to execute an external process,
but that the external process shows a GUI which OP did not want, most probably because he did not supply the arguments properly as in his first try he supplied one argument with value com.ipl.products.eclipse.cantpp.testscript.TestSummaryGenerator -noSplash -data Cantata/UnitTest project=Cantata/UnitTest/gDMPxy 1 and in his second try an argument with value noSplash.
Besides that the question has exactly zero to do with Gradle, it should most probably be an argument with value -noSplash instead, but that depends on that command that is called and how it needs to be called and not at all a Gradle topic.