Resolution of bidirectional properties of two files

Suppose I have an ant build system that loads various property files. Sometimes properties declared in one file are used in the value of properties declared in another.

For instance:

File 1: java.version=1.6 File 2: jdk.path=/blah/foo/java/${java.version} 

This works fine if I upload file 1 before file 2. In some cases, the replacement should be done in the reverse order - the things declared in file 2 will be used by file 1.

It is not possible to merge these files due to external limitations and system design.

Is there a way to implement bidirectional expansion? Maybe some way for the subsequent processing of properties and the application of additional stages of expansion? You can assume that there are no circular dependencies in extension chains.

+4
source share
1 answer

Interestingly, the following works:

File test1:

 a1=a1 a2=${b1} a3=${b3} 

Test2 file:

 b1=b1 b2=${a1} b3=${a2} 

Ant:

 <!-- Repeat until result is fully resolved. --> <var file="test1"/> <var file="test2"/> <!-- a3 = ${b3} --> <var file="test1"/> <var file="test2"/> <!-- a3 = ${b1} --> <var file="test1"/> <var file="test2"/> <!-- a3 = b1 --> <echo>${a3}</echo> 
+2
source

All Articles