I have gone through the following:
I have tried the solutions mentioned at:
- https://wiki.sei.cmu.edu/confluence/display/java/FIO07-J.+Do+not+let+external+processes+block+on+IO+buffers
- https://leo3418.github.io/2021/06/20/java-processbuilder-stdout.html
The groovy script does not print output in the correct order. Here is the implementation:
final String command = "cmd /c mvn -e --no-transfer-progress clean compile -Psome-profile"
ProcessBuilder processBuilder = new ProcessBuilder(command.split())
processBuilder = processBuilder.redirectErrorStream(true)
final Process proc = processBuilder.start()
proc.waitForProcessOutput(System.out, System.err)
The order of the output is incorrect:
[WARNING] D:\checkstyle\src\main\java\com\puppycrawl\tools\checkstyle\checks\imports\ImportControlLoader.java:[185,78] [argument] incompatible argument for parameter parent of FileImportControl.
found : @Initialized @Nullable PkgImportControl
[WARNING]
required: @Initialized @NonNull PkgImportControl
Whereas it should be:
[WARNING] D:\checkstyle\src\main\java\com\puppycrawl\tools\checkstyle\checks\imports\ImportControlLoader.java:[185,78] [argument] incompatible argument for parameter parent of FileImportControl.
found : @Initialized @Nullable PkgImportControl
required: @Initialized @NonNull PkgImportControl
[WARNING]................
Groovy version:
Groovy Version: 2.5.18 JVM: 11.0.16.1 Vendor: Azul Systems, Inc. OS: Windows 11
Note: This particular maven command takes a long to execute and dumps out the logs at the end (not continuously) which is a contributing factor to the above issue, any help will be really appreciated.
Update:
Upgraded groovy version to:
Groovy Version: 4.0.5 JVM: 11.0.16.1 Vendor: Azul Systems, Inc. OS: Windows 11
Still isn't working correctly.