great juergen, thanks. I mean I knew it could be done some way or other, I meant if it was possible very easily. I find it strange that I could not find any reference to it, in the wiki or something, I guess people would find it very handy in their configuration files...
javi On 7/21/05, Juergen Hermann <[EMAIL PROTECTED]> wrote: > 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] > > --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]