Igor Mukhin
04/04/2025, 7:27 PMChris Lee
04/04/2025, 8:59 PMVampire
04/04/2025, 9:31 PMlogging.captureStandardOutput(<http://LogLevel.INFO|LogLevel.INFO>)
on the taskIgor Mukhin
04/04/2025, 9:58 PMcaptureStandardOutput
does not look like a relevant solution:Vampire
04/04/2025, 9:59 PMChris Lee
04/04/2025, 9:59 PMVampire
04/04/2025, 10:00 PMIgor Mukhin
04/04/2025, 10:01 PMlogging
Vampire
04/04/2025, 10:01 PMVampire
04/04/2025, 10:02 PMgetLogging
Vampire
04/04/2025, 10:02 PMlogging
Chris Lee
04/04/2025, 10:02 PM@Override
public org.gradle.api.logging.LoggingManager getLogging() {
return super.getLogging();
}
on DefaultTask.Igor Mukhin
04/04/2025, 10:02 PM@TaskAction
public void execute() {
var bufferOut = new ByteArrayOutputStream();
var result = execOperations.javaexec(spec -> {
spec.setClasspath(runtimeConfiguration);
spec.getMainClass().set("jooqgenie.tool.JooqGenieTool");
//...
spec.setIgnoreExitValue(true);
spec.setStandardOutput(bufferOut);
});
if (getLogger().isInfoEnabled()) {
getLogger().info(bufferOut.toString());
}
if (result.getExitValue() != 0) {
throw new GradleException("JooqGenieTool execution failed with exit code: " + result.getExitValue());
}
}
Vampire
04/04/2025, 10:03 PMVampire
04/04/2025, 10:03 PMIgor Mukhin
04/04/2025, 10:03 PMVampire
04/04/2025, 10:04 PMIgor Mukhin
04/04/2025, 10:05 PMIgor Mukhin
04/04/2025, 10:10 PM@TaskAction
public void execute() {
getLogging().captureStandardOutput(LogLevel.INFO);
execOperations.javaexec(spec -> {
spec.setClasspath(runtimeConfiguration);
spec.getMainClass().set("jooqgenie.tool.JooqGenieTool");
});
}
and if i run:
./gradlew clean build
and it outputs everything from the external process.Igor Mukhin
04/04/2025, 10:12 PMVampire
04/04/2025, 10:13 PMjavaexec
already captures stdout and sends it to the logging making the option not work.Vampire
04/04/2025, 10:13 PMVampire
04/04/2025, 10:13 PMIgor Mukhin
04/04/2025, 10:14 PMIgor Mukhin
04/04/2025, 10:21 PMgetLogging().captureStandardOutput(LogLevel.QUIET);
System.out.println("!?!?!?!?!?!?!?!?!?!?!?!?!?!?!?!?!?!?!?!?");
and it shown the output.
For:
getLogging().captureStandardOutput(<http://LogLevel.INFO|LogLevel.INFO>);
System.out.println("!?!?!?!?!?!?!?!?!?!?!?!?!?!?!?!?!?!?!?!?");
it hides the output.
So it indeed works in-process.
Still, I am thankful for your help.Vampire
04/04/2025, 10:29 PMVampire
04/04/2025, 10:30 PMIgor Mukhin
04/05/2025, 12:27 AMgetLogging().captureStandardOutput(<http://LogLevel.INFO|LogLevel.INFO>);
System.out.println("####"); // !!!!!!!!!!
execOperations.javaexec(spec -> {
spec.setClasspath(runtimeConfiguration);
spec.getMainClass().set("jooqgenie.tool.JooqGenieTool");
spec.setStandardOutput(System.out); // !!!!!!!!!!!!
});
It swallows only "####" but the child process output is still visible.