Override property in build.gradle from the command line

前端 未结 1 562
天涯浪人
天涯浪人 2021-02-02 06:35

In build.gradle we can define variables like:

def libVersion=\'someVersion\'

We can override properties in command line with

相关标签:
1条回答
  • 2021-02-02 07:13

    Here's an example:

    ext.greeting = project.hasProperty('greeting') ? project.getProperty('greeting') : 'hello'
    
    task greet << {
        println greeting
    }
    

    If you run gradle greet, it will print hello.

    If you run gradle -Pgreeting=welcome greet, it will print welcome.

    0 讨论(0)
提交回复
热议问题