3

I have gone through the following:

I have tried the solutions mentioned at:

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.

VIAGC
  • 639
  • 6
  • 14

1 Answers1

0

try to redirect stderr to stdout using cmd:

String [] command = [
    "cmd", "/c", 
    "mvn -e --no-transfer-progress clean compile -Psome-profile 2>&1"
]
ProcessBuilder processBuilder = new ProcessBuilder(command)
Process proc = processBuilder.start()
proc.waitForProcessOutput(System.out, System.err)
daggett
  • 26,404
  • 3
  • 40
  • 56