that takes a "property path" or list of properties files. It loads in all properties from the properties files, in reverse order.
This achieves the effect of "overriding" b/c you can have default settings in a "defaults" file first in the path,
followed by other properties files in which you may or may not override values as appropriate.
This is a pretty trivial task to write, and serves our purposes fine--until Ant2 comes along.
<sidebar>
Incidentally, what we eventually realized is that this is simply an implementation of a special case of what we
are calling "context oriented programming;" where the attributes and even behavior of an
object can change depending on its context. You have defined several contexts (UAT, staging, production). If you had several different customers, they could also be different contexts. Different legacy systems/environments
often define the "same" object or task slightly differently, so they can also be considered as different contexts,
etc. etc. We actually found an environment that implements context oriented programming: Zope
(www.zope.org). They call it acquisition, and it is implemented in python. I have often thought about implementing this
facility in Java....
</sidebar>
--Craeg
Diane Holt wrote:
Can't you just put the loading of you specialized config files in a target that's only run if "buildconfig" is defined, since it's not defined for the default case?
Diane
--- jeff drost <[EMAIL PROTECTED]> wrote:
No, that's not what I'm saying. I'll try to explain better.
In the general case, where no additional parameters are supplied at the
command
line, the buildconfig task uses the default.buildconfig to obtain it's
properties. This is the way builds are typically being done in the
development
environment. Builds that are destined for other environments (such as
uat,
staging and production) frequently need some things to be different. For
instance, if I am building a Weblogic domain that is going to a staging
environment, I need the config.xml to refer to the staging database. In
this
case, I want to provide a way to override properties from the
default.buildconfig. I do this with an additional parameter, which
causes a
subset of the default properties to be loaded on those default
properties.
In most the general case, only one property file needs to be loaded. In the special case of a move to staging, I need two - the default as well as the special staging one.
<property file="${buildconfig}.buildconfig"/> <property file="default.buildconfig"/>
This does not allow me load only one. The hack is setting ${buildconfig} to "default" in the general case. This would have the desired effect but would needlessly load the same properties file twice.
Sorry if I wasn't clear before.
Thanks, Jeff
--- Erik Hatcher <[EMAIL PROTECTED]> wrote:
Its not really hackish to define a property even knowing that its
likely to
be overridden from the command-line - thats just the "Ant-way".
Erik
----- Original Message ----- From: "jeff drost" <[EMAIL PROTECTED]> To: "Ant Developers List" <[EMAIL PROTECTED]> Sent: Friday, November 16, 2001 12:58 PM Subject: Re: custom properties loading task
What if no command line argument is supplied? I don't plan on
providing
an
actual file called "${buildconfig}.buildconfig", as ant would expect
if
the
${buildconfig} property was not defined.
I imaging I could set ${buildconfig} to "default" on a previous
line, but
that
is fairly hackish.. it would load the file "default.buildconfig"
twice
(the
second time having no effect).
Jeff
--- Erik Hatcher <[EMAIL PROTECTED]> wrote:
This would do about the same thing:
<property file="${buildconfig}.buildconfig"/> <property file="default.buildconfig"/>
No guarantee about one being a subset of the other though, nor
would
exceptions be thrown.
Erik
----- Original Message ----- From: "jeff drost" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Friday, November 16, 2001 9:16 AM Subject: custom properties loading task
I have written a custom task, and have a hunch that the same
functionality
could be achieved with several built-in tasks. I'm hoping to
find
out, so
I
can either use the built-in approach, or contribute my task.
Rather than trying to explain it, I will give an example of how
I use
this
task. In the directory I run builds from, I have four property
files,
they
are:
default.buildconfig qa.buildconfig stage.buildconfig prod.buildconfig
If I simply run "ant", the task (which is currently called
buildconfig)
loads
the default.buildconfig property file and copies the loaded
properties
into the
Project. These properties are then used by the build process.
If I run "ant -Dbuildconfig=qa" then the default.buildconfig
property
file
is
loaded, then the qa.buildconfig file is loaded. The properties
loaded
from qa
overwrite those in the default properties file. The resulting
properties
are
then copied into the Project. Not that if a property is defined
in qa
that is
not defined in default, an exception is thrown.
I know that without this task, I could load the smaller subset
of
properties
first, and then load the larger superset next, but this doesn't
really
guarantee that the first one is a subset. Also, I am not
familiar
with
how I
would go about loading the first property file based on a
command line
argument. Any thoughts?
Thanks, Jeff Drost
__________________________________________________ Do You Yahoo!? Find the one for you at Yahoo! Personals http://personals.yahoo.com
-- To unsubscribe, e-mail:
<mailto:[EMAIL PROTECTED]>
For additional commands, e-mail:
<mailto:[EMAIL PROTECTED]>
-- To unsubscribe, e-mail:
<mailto:[EMAIL PROTECTED]>
For additional commands, e-mail:
<mailto:[EMAIL PROTECTED]>
__________________________________________________ Do You Yahoo!? Find the one for you at Yahoo! Personals http://personals.yahoo.com
--
To unsubscribe, e-mail:
<mailto:[EMAIL PROTECTED]>
For additional commands, e-mail:
<mailto:[EMAIL PROTECTED]>
--
To unsubscribe, e-mail:
<mailto:[EMAIL PROTECTED]>
For additional commands, e-mail:
<mailto:[EMAIL PROTECTED]>
__________________________________________________ Do You Yahoo!? Find the one for you at Yahoo! Personals http://personals.yahoo.com
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail:
<mailto:[EMAIL PROTECTED]>
===== ([EMAIL PROTECTED])
__________________________________________________ Do You Yahoo!? Find the one for you at Yahoo! Personals http://personals.yahoo.com
-- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>
-- Craeg K Strong, General Partner Ariel Partners LLC voice 781-647-2425 fax 781-647-9690
-- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>
