On Thu, 21 Jul 2005 22:48:38 +0200, javier muguruza wrote:

>I haven't found anything in the list about that...is it possible to
>use ant programatically to read a property file and at the same time
>performing the property substitution like ant does? I would like to
>reuse my build.properties for my own code.

Of course it is´(after all, Ant itself is just a program, too). The 
following prints "{baz=bar, foo=bar}". Since everyone can read Python, it 
should be no problem to convert this to Java (well, it will get a little 
longer ;).


from java.io import File
from org.apache.tools.ant import Project
from org.apache.tools.ant.taskdefs import Property

out = open('test.properties', 'w')
out.write("""
foo=bar
baz=${foo}
""")
out.close()

prj = Project()

p = Property()
p.setProject(prj)
p.init()
f = File('test.properties')
p.setFile(f)
p.execute()

print prj.getProperties()


Ciao, Jürgen



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to