How to pass parameters or arguments into a gradle task

前端 未结 6 2018
独厮守ぢ
独厮守ぢ 2020-12-29 00:41

I have a gradle build script into which I am trying to include Eric Wendelin\'s css plugin - http://eriwen.github.io/gradle-css-plugin/

Its easy enough to implement,

6条回答
  •  鱼传尺愫
    2020-12-29 01:20

    You should consider passing the -P argument in invoking Gradle.

    From Gradle Documentation :

    --project-prop Sets a project property of the root project, for example -Pmyprop=myvalue. See Section 14.2, “Gradle properties and system properties”.

    Considering this build.gradle

    task printProp << {
        println customProp
    }
    

    Invoking Gradle -PcustomProp=myProp will give this output :

    $ gradle -PcustomProp=myProp printProp
    :printProp
    myProp
    
    BUILD SUCCESSFUL
    
    Total time: 3.722 secs
    

    This is the way I found to pass parameters.

提交回复
热议问题