Bleah. It's not worth it then. Specifying the default locations inside the build.xml, as opposed to the build.properties file, is not ideal. I guess there's no clean way to get both.
> -----Original Message----- > From: Dominique Devienne [mailto:DDevienne@;lgc.com] > Sent: Thursday, October 24, 2002 1:13 PM > To: 'Ant Users List' > Subject: RE: Best way to get paths either from env vars or properties > file ? > > > No, really, what I told you if the only way I can think of. > Your approach > doesn't work (it's similar, but not the same), because even > when the env. > var is not set, your assigning the thingX.home anyway (literally to > '${env.XYZ}'), and then it cannot be changed. That's why you need to > override the env.XYZ property name which will not be set if > the env. var is > not set. --DD > > -----Original Message----- > From: Karr, David [mailto:david.karr@;attws.com] > Sent: Thursday, October 24, 2002 3:02 PM > To: 'Ant Users List' > Subject: RE: Best way to get paths either from env vars or > properties file ? > > I set up something similar, but it didn't appear to work. > > My build.xml has the following at the top of the "project" element: > > <property environment="env"/> > <property file="env.properties"/> > <property file="build.properties"/> > > My "env.properties" file looks something like this: > > thing1.home = ${env.THING1_HOME} > thing2.home = ${env.THING2_HOME} > > My "build.properties" file looks something like this: > > thing1.home = c:/thing1path > thing2.home = c:/thing2path > > In my "init" target in my "build.xml", I have something like > the following: > > <available file="${thing1.home}" property="thing1.present" > type="dir"/> > <fail message="Missing thing1 home" unless="thing1.present"/> > <available file="${thing2.home}" property="thing2.present" > type="dir"/> > <fail message="Missing thing2 home" unless="thing2.present"/> > > I then made sure my environment had "THING1_HOME" set to a > valid path, and > "THING2_HOME" unset. > > When I ran "ant" (version 1.5), I got this (some abbreviated): > > Buildfile: build.xml > init: > BUILD FAILED > file:C:/.../build.xml:28: Missing thing2 home > Total time: 2 seconds > > So, "thing1" didn't have any problems, because the envvar was > set. The > "THING2_HOME" variable was not set, however, and apparently > the line in > "build.properties" setting "thing2.home" had no effect, > seemingly because it > was "already set", even though the value was null. > > In order for this scheme to work, when "ant" finds a property > setting, it > needs to ignore it if the value is already set, but use it if > the current > value is null. Is there anyway to get it to work that way? -- To unsubscribe, e-mail: <mailto:ant-user-unsubscribe@;jakarta.apache.org> For additional commands, e-mail: <mailto:ant-user-help@;jakarta.apache.org>