简体   繁体   中英

Access build.xml properties from Java

I have an Android application that is by default built with Ant.

There is build.xml file which loads local.proerties file. I would like to add my custom property (for example Google Maps apiKey) and access it in Java classes - for example in some MainActivity.

How can I achieve it ?

Ant provides a target called "sysproperty". Its like a property tag, but it sets the java System.property. So, you can do something like:

<sysproperty name="foo" value="$THE_EXTRA_PROPERTY">

where "THE_EXTRA_PROPERTY" is the extra property that you added to the properties file that gets loaded.

使用带有过滤器集的替换任务或复制任务,使您的蚂蚁脚本修改包含API密钥的Java源文件或与应用程序捆绑在一起的属性文件。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM