跨两个文件双向解析属性
想象一下我有一个 ant 构建系统,它加载各种属性文件。有时,在一个文件中声明的属性会用于在另一个文件中声明的属性的值。
例如:
File 1:
java.version=1.6
File 2:
jdk.path=/blah/foo/java/${java.version}
如果我在文件 2 之前加载文件 1,则效果很好。但是,在某些情况下,替换需要以相反的顺序进行 - 文件 2 中声明的内容将由文件 1 使用。
无法组合这些文件由于外部约束和系统设计。
有什么办法可以实现双向扩展吗?也许有某种方法可以对属性进行后处理并应用额外的扩展步骤?您可以假设扩展链中不存在循环依赖关系。
Imagine I have an ant build system which loads various property files. Sometimes properties declared in one file are used in the value of properties declared in another.
For example:
File 1:
java.version=1.6
File 2:
jdk.path=/blah/foo/java/${java.version}
This works fine if I load file 1 before file 2. In some cases, however, the substitution needs to happen in the reverse order - things declared in file 2 will be used by file 1.
It's not possible to combine these files due to external constraints and the design of the system.
Is there some way to implement the bi-directional expansion? Maybe some way to post-process the properties and apply additional expansion steps? You may assume that there are no circular dependencies in the expansion chains.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
有趣的是,以下内容似乎有效:
文件 test1:
文件 test2:
Ant:
Interestingly the following seems to work:
File test1:
File test2:
Ant: