Gradle not showing stdout/err from jni wrapped native code


#1

I have some c++ code that prints to stdout/err. When I run it from a java only wrapper I get output. When I call into the jni wrapper from a gradle task, I get nothing. I know there’s a

testLogging.showStandardStreams = true

but this is not during testing.

Here’s the gradle task:

task transformPdfs(dependsOn:parse, description: "Transform PDFs to raster images") {
 inputs.dir parseDir
 outputs.dir generatedDir
    doLast {
  generatedDir.deleteDir()
  generatedDir.mkdirs()
  inputs.files.each {
   if(it.getName().endsWith(".pdf")){
    println "Converting " + it.getAbsolutePath()
     PdfConverter pdf = new PdfConverter(it.getAbsolutePath(), "replica", cbCfg);
    pdf.processPdf(project.ext.dataset);
....

The pdf.processPdf prints to stdout/err, but this is not visible when run from gradle.

What do I need to do to enable/capture this output?


#2

Adding the following to the task:

task transformPdfs(dependsOn:parse, description: "Transform PDFs to raster images") {
 logging.captureStandardOutput LogLevel.ERROR
 logging.captureStandardError LogLevel.ERROR

has no effect.

I get java log messages back from the above pdf.processPdf, but none of the stdio prints from the jni lib it calls into.

Currently I have to run separate test cases outside of gradle just so that the output is not suppressed.