Hidden property in Gradle

It is possible to have hidden configuration properties in Gradle. I am not saying you should use them, but there may be reasons for them.

Normal gradle property is defined in gradle.property file like this:


You many override this via command line:

gradle war -Prelease=true

But what if you do not trust people changing gradle.property file enough? What if you want to have an undocumented property? This code snippet would help you in such a case:

def isRelease() {
  def releaseO = rootProject.hasProperty('release') && rootProject.release
    return releaseO?:false

With this code you have a "release" property that is just like a regular property: it can be defined in properties file and overridden in command line. But it could also be omitted from both properties file and command line.

What are the situations you may want to use it? I do not know. It is a hack, after all.