Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Suppress Gradle's JavaExec output

Tags:

gradle

I have gradle code below and I don't know how to avoid huge output generated by JavaExec task. I haven't found any option of JavaExec for it. If anyone knows better way of ignoring it, please share it.

def getStubOutput() {
    return new FileOutputStream(new File("${buildDir}/temp"))
}

configure(project(':jradius:dictionary-min')) {
    evaluationDependsOn(':jradius')
    sourceSets {
        main {
            java {
                srcDir "${projectDir}/target/dictionary-src"
            }
        }
    }
    dependencies {
        compile project(':jradius:core')
    }
    task genSources(type: JavaExec) {
        main = 'net.jradius.freeradius.RadiusDictionary'
        classpath configurations.all
        args = ["net.jradius.dictionary", "${projectDir}/../freeradius/dict-min", "${projectDir}/target/dictionary-src"]
        maxHeapSize = "800m"
        standardOutput = getStubOutput()
    }
    jar {
        archiveName = "jradius-dictionary-min-1.1.5-SNAPSHOT.jar"
    }
    genSources.dependsOn ':jradius:cloneJradius' 
    compileJava.dependsOn genSources
}
like image 529
Egor Avatar asked Nov 16 '25 03:11

Egor


1 Answers

I simply use a dummy OutputStream that does nothing in its write method:

def dummyOutputStream = new OutputStream() {
    @Override
    public void write(int b) {}
}

exec {
    executable = name
    standardOutput = dummyOutputStream
    errorOutput = dummyOutputStream
    ignoreExitValue = true
}
like image 82
sschuberth Avatar answered Nov 17 '25 19:11

sschuberth



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!