Hi,

couldn't you make use of immutable properties and specify several

  <available property="" value="" file="" />

starting with the most specific one and ending with the most generic
one.

Just an idea.


Greetings
Chris


> -----Original Message-----
> From: Chris Gibble [mailto:[EMAIL PROTECTED] 
> Sent: Tuesday, November 07, 2006 7:14 PM
> To: user@ant.apache.org
> Subject: Re: Selectively copying versions of files
> 
> 
> I've read up on selectors, and you're right -- they do the 
> job, at least on a file-by-file basis.  But this doesn't 
> really do what I want.  Consider:
> 
>   For personnel:
>       -- if there is a day-specific file (day1_personnel.xml), use it.
>       -- else if there is a default file (personnel.xml), use it
> 
>   For locations:
>       -- if there is a coast-specific file 
> (EastCoast_locations.xml), use it.
>       -- else if there is a default file (locations.xml), use it
> 
> ... and so on.  Note that selectors are specific for each 
> file.  So if I add a FOURTH data file (say, forklifts.xml), 
> I'd basically have to copy and paste existing selectors (if 
> they vary on the same parameter, like "days") or write new 
> selectors (if they vary on a new parameter, like "diesel vs. 
> electric") to account for the possible configurations.
> 
> Ideally the selectors would NOT be file-specific, but then 
> the number of possible configurations seem to grow tremendously:
> 
>   For ANY input file:
>       -- if there is a file that is configuration-specific, 
> (NewYearsDay2006_vehicles.xml), use it.
>       -- else if there is a file that is day-specific, 
> location-specific, and vehicle-specific 
> (day1_EastCoast_25_vehicles.xml), use it.
>       -- else if there is a file that is day-specific and 
> vehicle-specific (day1_25vehicle_locations.xml), use it.
>       -- else if there is a file that is location-specific 
> and vehicle-specific (EastCoast_25vehicle_personnel.xml), use it.
>       -- else if...... [repeat for all combinations of day, 
> location, and vehicle number]
> 
> 
> Now, if my new forklift.xml varies based on a new parameter 
> "diesel vs. electric", then the number of combinations (and 
> selectors) just doubled.  Not sure how this does 
> performance-wise, but I'm sure it doesn't help....
> 
> Again, this may be unavoidable.  And my approach of encoding 
> each file with metadata (e.g. "day1_" or "EastCoast_") might 
> not be the best -- subfolders under the top "source" folder 
> might be better, though that has issues of its own. 
> 
> What I REALLY want to do is something like
>     For any input file:
>         -- for the requested configuration (eg. day1, East 
> Coast), use the version of the file whose metadata indicates 
> it is the best match (e.g. day1_personnel.xml, 
> EastCoast_locations.xml, vehicles.xml). 
> 
> Does this help to clarify my question?  I should mention that 
> my real application (not the one I made up for this e-mail) 
> actually has something like 9 input files that vary on 4 
> different parameters, not including specific configuration requests. 
> 
> Chris
> 
> 
>  --- On Tue 11/07, Matt Benson < [EMAIL PROTECTED] > wrote:
> From: Matt Benson [mailto: [EMAIL PROTECTED]
> To: user@ant.apache.org, [EMAIL PROTECTED]
> Date: Tue, 7 Nov 2006 09:05:03 -0800 (PST)
> Subject: Re: Selectively copying versions of files
> 
> You can copy decreasing levels from most-specific 
> toleast-specific to your target directory, using a<present> 
> selector.  Check the manual for "Selectors".HTH,Matt
> 
> --- Chris Gibble <[EMAIL PROTECTED]> wrote:>
> My apologies if this has been asked before, but I couldn't 
> find anything related -- and it seems like a fairly common scenario.
> 
> Let's say I have a warehouse program that initializes itself 
> by reading three configuration files:
>       vehicles.xml
>       personnel.xml
>       locations.xml
> 
> This program runs a simulation and generates output showing 
> the efficiency of the warehouse with the given inputs.
> 
> Now let's say I want to package this program with a variety 
> of pre-generated configurations:
>       The number of available vehicles (in vehicles.xml) is 
> constant for each configuration -- say, 30
>       The number of personnel (in personnel.xml) varies by 
> day, with Sunday = day0 and Saturday = day6
>       The delivery locations (specified by locations.xml) 
> vary between two specified configurations: "East Coast" and 
> "West Coast"
> 
> For example, here are the pre-generated configurations:
>       day0 personnel, East Coast locations
>       day1 personnel, East Coast locations
>       ...
>       day6 personnel, East Coast locations
>       day0 personnel, West Coast locations
>       ...
>       day6 personnel, West Coast locations
> 
> To clarify, each "configuration" folder contains a version of 
> the files vehicles.xml, personnel.xml and locations.xml 
> populated with the desired values.  Note that the number of 
> vehicles was not specified by the above configurations, since 
> the default value of 30 is always used.
> 
> Rather than maintain multiple copies of the same file in each 
> configuration folder (e.g. 14 copies of the same 
> vehicles.xml), I was trying to use an Ant build script to 
> copy the appropriate files from one "source" location to the 
> appropriate "destination" configuration folder.  So, there is 
> one "day0-personnel.xml" file, one "EastCoast-locations.xml", 
> and one "vehicles.xml" file (the default, containing 30 
> vehicles) that would be copied (and renamed when needed) into 
> the "Day 0 personnel, East Coast locations, 30 vehicles" 
> configuration folder.
> 
> But here's an added wrinkle: in addition to the 
> configurations mentioned above, there is one more "special" 
> configuration we want to include that uses a different number 
> of vehicles:
>       day0 personnel, East Coast locations, 25 vehicles
> 
> In this case, the build script would need to copy (and 
> rename) "day0-personnel.xml", "EastCoast-locations.xml", and 
> "25-vehicles.xml".
> 
> Furthermore, there may be future requests for other specific 
> configurations, whether it's different vehicles, personnel 
> (e.g. "New Year's Day personnel"), locations ("International 
> locations"), etc.
> 
> So in short: given a desired configuration, I want an Ant 
> script that copies the MOST SPECIFIC file that exists (e.g. 
> 25-vehicles.xml).  If there is no specific file, then a more 
> generic version should be used (e.g. vehicles.xml).
> 
> Of course, I COULD hard-code configurations to copy specific 
> input files, but I'm trying hard to avoid that....
> 
> Any ideas would be greatly appreciated.
> 
> 
> 
> _______________________________________________
> Join Excite! - http://www.excite.com
> The most personalized portal on the Web!
> 
> 
> 
> ---------------------------------------------------------------------
> 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]

Reply via email to