ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ckn...@onebox.com
Subject Re: Setting a property based on a command-line parameter
Date Mon, 24 Jul 2006 17:43:28 GMT
Here is how I decided to do it. If the command-line parameter "span" is supplied with the value
"week", "start.date" is assigned the value of "weekly.start.date". Otherwise, it is assigned
the value of "daily.start.date".


<target name="init">
  <tstamp>
    <format property="TODAY" pattern="MMMM dd, yyyy" />
    <format property="DSTAMP" pattern="yyyy-MM-dd" />
    <format property="weekly.start.date" pattern="yyyy-MM-dd" offset="-8" unit="day" />
    <format property="daily.start.date" pattern="yyyy-MM-dd" offset="-2" unit="day" />
  </tstamp>
  <condition property="start.date" value="${weekly.start.date}" else="${daily.start.date}">
    <equals arg1="${span}" arg2="week" />
  </condition>
<!--<echo>${start.date}</echo> -->
</target>
-- 
Charles Knell
cknell@onebox.com - email



-----Original Message-----
From:     Anderson, Rob (Global Trade) <Rob.Anderson@nike.com>
Sent:     Mon, 24 Jul 2006 10:31:31 -0700
To:       "Ant Users List" <user@ant.apache.org>
Subject:  RE: Re: Setting a property based on a command-line parameter

In your case, it seems that you only need to test whether or not the
property is set, and not necissarily the value. In other words, if you
want a weekly report set week=true on the command line, otherwise assume
the report should be daily by default. The easiest way to do this is...

<target name="set.date.for.weekly" if="week">
..
</target>

<target name="set.date.for.daily" unless="week">
..
</target>

-Rob A


> -----Original Message-----
> From: cknell@onebox.com [mailto:cknell@onebox.com] 
> Sent: Friday, July 21, 2006 1:11 PM
> To: user@ant.apache.org
> Subject: RE: Re: Setting a property based on a command-line parameter
> 
> <condition> is almost right, but it doesn't seem to have a 
> means of testing the value of a property. Of course, I may be 
> missing something.
> --
> Charles Knell
> cknell@onebox.com - email
> 
> 
> 
> -----Original Message-----
> From:     Joe Moore <i_bugsy@yahoo.com>
> Sent:     Fri, 21 Jul 2006 12:56:39 -0700 (PDT)
> To:       Ant Users List <user@ant.apache.org>
> Subject:  Re: Setting a property based on a command-line parameter
> 
> Charles,
> 
> Look at the Conditions task, Supported conditions in the Ant 
> manual. This has a test to see if a property is set or not.
> 
> The Tstamp task has an offset attribute that you can use to 
> change the date either forward or backward. 
> 
> Hopefully that points you in the right direction.
>  
> Joe Moore 
> i_bugsy@yahoo.com
> 
> ----- Original Message ----
> From: cknell@onebox.com
> To: user@ant.apache.org
> Sent: Friday, July 21, 2006 3:41:05 PM
> Subject: Setting a property based on a command-line parameter
> 
> I'm using Ant to orchestrate a processing pipeline that 
> begins with a query to an Oracle database and ends with a 
> file containing a report in HTML format.
> 
> One of the reports I have to produce comes in two flavors; 
> daily and weekly. These are distinguished by the lower end of 
> the date range the SQL query will include in selecting 
> records. That is to say, the low end of the date range in the 
> daily report is two days before the current date, while the 
> low end of the date range in the weekly report is eight days 
> before the current date.
> 
> I have been looking for a means of setting the value for the 
> low end of the date range in Ant, triggered by passing the 
> command line parameter -Dweek=true. Based on this (either the 
> parameter is set or it is not), I'd like to set a property to 
> one or another value.
> 
> If week=true then I'd like to set the value of start.date to 
> the current date minus eight days.
> If the value is not set or it is not "true", I'd like to set 
> the value of start.date to the current date minus two days.
> 
> The start.date property will be passed by ora:sqlplus as a 
> parameter to a SQL script. I've been poking around the Ant 
> docs for two afternoons, but while it seems like I'm almost 
> finding what I need, I'm coming up short.
> 
> So as I see it, there are two parts to my hoped-for solution.
> 1) Setting a property to one or another value based on the 
> value of command-line parameter.
> 2) Performing date arithmetic in Ant.
> 
> Has anyone done either of these before?
> 
> Thanks.
> -- 
> Charles Knell
> cknell@onebox.com - email
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
> For additional commands, e-mail: user-help@ant.apache.org
> 
> 
> 
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
> For additional commands, e-mail: user-help@ant.apache.org
> 
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
> For additional commands, e-mail: user-help@ant.apache.org
> 
> 
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org




---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org


Mime
View raw message