Gradle JavaExec StandardOutput to enable Java command

Is it possible to add java command to standardOutput stream in JavaExec command in Gradle?

Those

task importSitesDef(dependsOn: init, type: JavaExec) {
    main = 'com.x'
    classpath = configurations.runE
    standardOutput = new FileOutputStream(standardLog, true)
}

      

Will write the output, but I want to see java com.x -cp ... in the file also before entering.

This involves using the same output stream / file for multiple tasks, and it is very difficult to determine where the output from one task ends before starting another.

+3


source to share


1 answer


I know this is an old question, but all I did in order to use the Java command I used was to get the result of the method JavaExec

commandLine

and attach elements to it, e.g .: -

commandLine.collect().join(' ')



Then take it out.

0


source







All Articles