Is it possible to declare a variable in Gradle usable in Java?

后端 未结 9 1247
春和景丽
春和景丽 2020-11-22 09:11

Is it possible to declare a variable in Gradle usable in Java ? Basically I would like to declare some vars in the build.gradle and then getting it (obviously) at build time

9条回答
  •  旧时难觅i
    2020-11-22 09:23

    I'm using

    buildTypes.each {
        it.buildConfigField 'String', 'GoogleMapsApiKey', "\"$System.env.GoogleMapsApiKey\""
    }
    

    Its based on Dennis's answer but grabs its from an environment variable.

提交回复
热议问题