apply plugin: 'io.fabric' ext.getFabricApiKey = { return System.getenv('FABRIC_APIKEY') ?: "xxxe76c4xxxx97e8cxxxx0135e9d46f5a2xxx" } ext.getFabricApiSecret = { return System.getenv('FABRIC_APISECRET') ?: "xx68f6074dxxxxxc11dxxx97c172e8ebf0" } def buildFabricProperties() { def propertiesFile = file("fabric.properties") def apiSecret = getFabricApiSecret() def apiKey = getFabricApiKey() if (propertiesFile.exists()) { propertiesFile.delete() } def commentMessage = "suppress inspection \"UnusedProperty\" for whole file" ant.propertyfile(file: "fabric.properties", comment: commentMessage) { entry(key: "apiSecret", value: apiSecret) entry(key: "apiKey", value: apiKey) } } afterEvaluate { buildFabricProperties() }