joycollector
joycollector

Reputation: 2056

How can I specify gradle project properties in gradle.properties file?

Is it possible to specify project properties such as name in gradle.properties file so will be possible to access them from build.gradle by using project.name?

I've tried with no luck:

name=some
project.name=some
org.gradle.project.name=some

Upvotes: 2

Views: 1613

Answers (2)

Gabriele Mariotti
Gabriele Mariotti

Reputation: 364808

You can do it.

For example in your root gradle.properties file you can have:

VERSION_NAME=2.0.2

Then in your build.gradle file (in the root folder) you can have for example:

allprojects {
    version = VERSION_NAME
}

If you would like to use it in your module build.gradle file you can have:

android {

    defaultConfig {
        versionName project.VERSION_NAME  
    }
}

Upvotes: 1

Opal
Opal

Reputation: 84854

These properties won't be set automatically - see the docs. It can be done with settings.gradle.

Upvotes: 0

Related Questions