ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Erik Hatcher" <jakarta-...@ehatchersolutions.com>
Subject Re: Probably dumb question about accessing system properties in build listeners.
Date Wed, 06 Mar 2002 14:47:26 GMT
Are you grabbing them in buildStarted?  (Un?)fortunately the Ant properties
have not been set then. You will have to grab them during another event
(lazy initialize in the first event where you need the property other than
buildStarted, and cache whatever you need from buildStarted until then).

Although System.getProperty should work, I'd think, although I've not tried
it.  That would mean you'd have to set them on the command-line rather than
within a build file, but that seems ok for your needs at least.

    Erik

----- Original Message -----
From: "Ken Wood" <kwood@i2.com>
To: "Ant Developers List" <ant-dev@jakarta.apache.org>
Sent: Wednesday, March 06, 2002 9:36 AM
Subject: Probably dumb question about accessing system properties in build
listeners.


> I wrote a simple build listener,
> and I initially designed it to be configured
> from a file. Now, I want it to be configured
> from system properties on the command line.
>
> So, I changed the code that reads the property
> files to instead us java.lang.System.getProperty()...
> When I invoke Ant, I used the -Dproperty=value syntax.
>
> Well, when I test the listener, the properties are not
> there! I suspect Ant is grabbing them because I see that
> Project has getProperty methods. Problem is, I can't
> see a way to get a handle on the project object in
> a build listener. Everything else I looked at that
> references a project object is extended from Project
> in one way or another, so the access is easy.
>
> Am I missing something? Is there some way for a build
> listener to get the 'project' object so it can
> get the properties? Any advice on how I should do this?
> Or, should System.getProperty work???
>
> Thanks!
>
> -ken
>
> --
> To unsubscribe, e-mail:   <mailto:ant-dev-unsubscribe@jakarta.apache.org>
> For additional commands, e-mail: <mailto:ant-dev-help@jakarta.apache.org>
>
>


--
To unsubscribe, e-mail:   <mailto:ant-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:ant-dev-help@jakarta.apache.org>


Mime
View raw message