gradle

How do I turn off in console gradle build message like 'BUILD SUCCESSFUL'?


I want to export project version to environment

by tag='gradle printVersion'`

printVersion is gradle task

task exportVersion {
    println project.version
}

it print 0.0.1-SNAPSHOT to console, and my $tag env is set to 0.0.1-SNAPSHOT:exportVersionUP-TO-DATEBUILD SUCCESSFUL

How do I make the gradle to include :exportVersion, BUILD SUCCESSFUL to console?


Solution

  • First of all you have your task misconfigured. This way version will be printed every time gradle is run. To avoid it you should add an action: << or doLast. To suppress gradle output, use -q switch:

    >cat build.gradle 
    task exportVersion << {
        println project.version
    }
    
    >gradle -q exportVersion
    unspecified
    

    P.S. @DaveyDaveDave is right, it shouldn't be handled that way.