Android Gradle:保存属性文件
我在我的项目中使用NewRelic。它需要带有应用程序令牌的newrelic.properties文件。我需要用不同的令牌创建几个构建。在gradle for genereting属性中,我使用下一个代码段:Android Gradle:保存属性文件,android,gradle,properties-file,Android,Gradle,Properties File,我在我的项目中使用NewRelic。它需要带有应用程序令牌的newrelic.properties文件。我需要用不同的令牌创建几个构建。在gradle for genereting属性中,我使用下一个代码段: Properties props = new Properties() props.setProperty("com.newrelic.application_token","MYTOKEN") 如何将其保存到我的应用程序文件夹?我需要根文件夹中文本为“com.newrelic.appl
Properties props = new Properties()
props.setProperty("com.newrelic.application_token","MYTOKEN")
如何将其保存到我的应用程序文件夹?我需要根文件夹中文本为“com.newrelic.application\u token=MYTOKEN”的“newrelic.properties”文件。您可以使用-p标志指示生成配置文件:
gradle clean build -Pprofile=dev
然后在构建脚本中使用它:
File propsFile = new File('/libs/newrelic.properties')
if (project.getProperty('profile') == "dev") {
println "Target environment: $profile"
Properties props = new Properties()
props.setProperty("com.newrelic.application_token","DEV_TOKEN")
props.store(propsFile.newWriter(), null)
}
您可以使用-p标志指示生成配置文件:
gradle clean build -Pprofile=dev
然后在构建脚本中使用它:
File propsFile = new File('/libs/newrelic.properties')
if (project.getProperty('profile') == "dev") {
println "Target environment: $profile"
Properties props = new Properties()
props.setProperty("com.newrelic.application_token","DEV_TOKEN")
props.store(propsFile.newWriter(), null)
}
您可以使用-p标志指示生成配置文件:
gradle clean build -Pprofile=dev
然后在构建脚本中使用它:
File propsFile = new File('/libs/newrelic.properties')
if (project.getProperty('profile') == "dev") {
println "Target environment: $profile"
Properties props = new Properties()
props.setProperty("com.newrelic.application_token","DEV_TOKEN")
props.store(propsFile.newWriter(), null)
}
您可以使用-p标志指示生成配置文件:
gradle clean build -Pprofile=dev
然后在构建脚本中使用它:
File propsFile = new File('/libs/newrelic.properties')
if (project.getProperty('profile') == "dev") {
println "Target environment: $profile"
Properties props = new Properties()
props.setProperty("com.newrelic.application_token","DEV_TOKEN")
props.store(propsFile.newWriter(), null)
}
我使用更简单的方法:
ant.propertyfile(file: "newrelic.properties") {
entry( key: "com.newrelic.application_token", value: "AA165ad2e3e518***********************sd2")
}
由此:
我使用更简单的方法:
ant.propertyfile(file: "newrelic.properties") {
entry( key: "com.newrelic.application_token", value: "AA165ad2e3e518***********************sd2")
}
由此:
我使用更简单的方法:
ant.propertyfile(file: "newrelic.properties") {
entry( key: "com.newrelic.application_token", value: "AA165ad2e3e518***********************sd2")
}
由此:
我使用更简单的方法:
ant.propertyfile(file: "newrelic.properties") {
entry( key: "com.newrelic.application_token", value: "AA165ad2e3e518***********************sd2")
}
由此: