first create a file called external.properties in the project root directory.
then check if this file exists
def externalPropertyFile = file("${rootProject.projectDir.path}${File.separator}external.properties") if (!propertyFile.exist()) { throw new GradleException("external.property file doesn't exist") }
check if properties exist in the current context if you do not load the properties file
if (!rootProject.ext.has("externalProperties")) { rootProject.ext { externalProperties = new Properties() externalProperties.load(propertyFile.newReader()) } }
You can do the same check in signConfigs and omit the release build if properties are not available:
signingConfigs { if (rootProject.ext.has("externalProperties")) { release { keyAlias rootProject.externalProperties.KEY_ALIAS storeFile file(rootProject.externalProperties.KEYSTORE_PATH) storePassword rootProject.externalProperties.KEYSTORE_PASSWORD keyPassword rootProject.externalProperties.MOBILE_KEY_PASSWORD } } }
source share