In the end I decided to create a static helper:
public class PropertyUtils {
public static Properties getProperties(Context context) {
AssetManager assetManager = context.getResources().getAssets();
Properties properties = new Properties();
try {
loadProperties(assetManager, "project.properties", properties);
if (Arrays.asList(assetManager.list("")).contains("local.properties")){
loadProperties(assetManager, "local.properties", properties);
}
} catch (IOException e) {
throw new RuntimeException(e);
}
return properties;
}
private static void loadProperties(AssetManager assetManager, String fileName, Properties properties) throws IOException {
InputStream inputStream = assetManager.open(fileName);
properties.load(inputStream);
inputStream.close();
}
}
Where project.properties in assets directory has the following property:
baseUrl=${baseUrl}
and local.properties in assets:
baseUrl=http://192.168.0.1:8080/
local.properties is excluded from version control, and overwrites any project.properties. Thus when building in the CI tool, baseUrl is overridden with relevant value, and when running locally (in IntelliJ), the local.properties value will be used.