ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Joshua Wunder" <Jos...@cerylion.net>
Subject RE: Calling a String
Date Mon, 30 Jul 2007 10:31:46 GMT
Two things:
1.
Just to add for others reading, to make all URIs available you need to
add the following taskdef:

     <taskdef resource="com/idaremedia/antx/install/antlib.xml"
     >
          <classpath>
               <pathelement location="D:\Data\...\lib\AntX_tasks.jar"
               />
          </classpath>
     </taskdef>

2.  In the end the strings task didn't do what I thought it would.  I'm
gonna try to explain again and hope someone may have an idea ...

I have created a ANT to automate various copying, deleting and other
stuff we do in Production.  I would like to log the Actions in a table
that would work like Excel.  To this end, I decided against using the
regular record task because it just produces text and would not be
useful for analysis.  Instead I created a series of "echos to file" that
echo various details including the file name, the action that was
performed, the timestamp of the action and the timestamp of the
datemodified (and other stuff) comma-delimited to a filename.csv file
that can be opened in excel and read as a table.  [A csv file is a
comma-delimited text file that can be opened in Excel and read as a
tabular document where each comma means a new column.]

My ANT runs a FOR loop that processes various directories file by file
while recording the details mentioned above.  Currently, each echo has a
list of properties [I call it a log stream] similar to below:
${filename.@{file}},${date.modified.@{file}},${action.tstamp.@{file}}

And while processing each file, it produces the log to a file.  It works
perfectly, just one very important thing.  If I decide to change the log
stream I need to change it in each file and in each instance of the log
stream in the file.  This is obviously not impossible, but nevertheless
very error-prone and a big pain.

I figured that I should be able to create a central location to store
the list of properties that can be referenced each time I want to log.
This way, when a change needs to be made, I can just change it in one
place.

I started by creating a property with the log stream above.  This was a
problem because @{file} has no value until it is in the loop and then
the property is set with @{file} instead of its value.

Then I found the strings task, I thought it would do the trick.  But it
works similar to a property in that if the @{file} is not defined before
the strings task, the @{file} is left as is and the @{file} is not
replaced.

To clarify, I need the @{file} because I need a new value for each file
and that is only possible (as far as I know) by attaching the @{file} to
the property value.

I hope this is clear.  If anyone has any questions or suggestions I'd
very much appreciate it.

TIA for ur help!
Josh

-----Original Message-----
From: Wascally Wabbit [mailto:wascallywabbit@earthling.net] 
Sent: Monday, July 30, 2007 04:35
To: Ant Users List
Cc: Joshua Wunder
Subject: Re: Calling a String

Not sure what you need to do but if you're trying to print the
contents of a <strings> object w/o the # information, no luck
because both print tasks are 'diagnostic' tasks so currently
there's no way to nuke the verbose header junk.

But you can try using the Ant echo task with the AntX $ref
value URI like:

<echo message="${$ref:josh.test}" file="whatever.log"/>

if 'josh.test' is a reference to a <strings> object is will
only print the comma-delimited list of values.

Example:
   <target name="echostrings">
     <strings id="josh.test">
       <string value="a"/>
       <string value="b"/>
       <string value="c"/>
     </strings>
     <echo message="${$ref:josh.test}"/>
   </target>

-OUTPUT-
echostrings:
      [echo] a,b,c

HTH,
-The Wabbit

Joshua Wunder wrote:
> Hi
> 
> I was wondering if this message was posted - I never got a response
> 
> TIA,
> Josh
> 
> -----Original Message-----
> From: Joshua Wunder 
> Sent: Wednesday, July 25, 2007 13:12
> To: 'Ant Users List'
> Subject: RE: Calling a String
> 
> Sorry it took so long to respond
> 
> Found something that looks good in antxtras - <strings>
> 
> I'm just having a problem
> 
> I'd like to print the <reference> to a file.  I see that I can do that
> with <printenv>, but for some reason it also attaches the two # lines
> and josh.test=.  All I want is the a,b,c,d.
> 
> stringtest:
>  [printenv] #
>  [printenv] #Wed Jul 25 13:08:49 IDT 2007
>  [printenv] josh.test=a,b,c,d
> 
> I see that there is a way to manipulate printers with the <printer>
> task, but I don't follow at all what to do.  [Do I need to know java
to
> use this task?]
> 
> Also, <printenv> does not support printing using a specific printer.
> Only <print> does that, but print doesn't have the option to write to
a
> file, as far as I can tell.
> 
> I'd very much appreciate any help.
> 
> TIA,
> Josh
> 
> -----Original Message-----
> From: Ditrick, Gregory [mailto:gregory.ditrick@fmr.com] 
> Sent: Thursday, July 19, 2007 18:02
> To: Ant Users List
> Cc: Shalom Deitch
> Subject: RE: Calling a String
> 
> It looks like you need to look into antcontrib.
> 
> http://ant-contrib.sourceforge.net/
> 
> The tasks propertycopy, propertyregex and propertyselector.
> 
> I may be wrong about what you are trying to do, but I have found that
> ant with antcontrib and antXtra is the way to go.  It makes ant more
of
> a shell language with more logical controls.
> 
> http://antxtras.sourceforge.net/index.html
> 
> 
> Hope this helps, if you are not using them already. 
> 
> 
> GregD
> 6-8309
> 
> -----Original Message-----
> From: Joshua Wunder [mailto:Joshua@cerylion.net] 
> Sent: Thursday, July 19, 2007 9:46 AM
> To: Ant Users List
> Cc: Shalom Deitch
> Subject: Calling a String
> 
> Hello All!!
> 
>  
> 
> First time writing to the list.  I'm working for a Software Design
> company that works primarily in JAVA.  I work in the Production
> department, and started using ANT a month or two ago to automate our
> processes.
> 
>  
> 
> So - I am stuck on something
> 
>  
> 
> I would like to create a documentation of my processes thru a CSV
file.
> 
>  
> 
> The way my ANT works, I use a loop to process each file individually,
> and the various details about the file [name, path, datemodified,
action
> performed with the file, etc] are echoed to a file with comma
delimiters
> to allow for filtering and sorting in Excel.
> 
>  
> 
> Here's my problem, I currently echo a full string of variables for
each
> file in each area I process files in different ways.  The problem with
> this is that if I want to make a change, I need to change the string
of
> variables in every location I create this log.  I'd like to be able to
> have some form of reference to a string that I can call in various
> places, but only need to change in one.
> 
>  
> 
> Making a property with other properties doesn't work because
properties
> sets the value with the ${} and doesn't allow for them to be replaced.
> 
>  
> 
> I'd appreciate if anyone has any ideas.
> 
>  
> 
> I hope that my description is clear.  If not, please ask away ...
> 
>  
> 
> TIA,
> 
> Josh
> 
>  
> 
>  
> 
>  
> 
> Joshua Wunder
> Production Engineer
> Cerylion Israel
> 39 HaShaked Street
> Moshav Aminadav
> Israel
> 
> Tel: 972-2-643-3399 @ 107
> Work Home: 972-2-997-1004
> Cell: 972-54-759-8887
> Fax: 972-2-643-6066
> 
>  
> 
>  
> 
> 
> 
> ---------------------------------------------------------------------
> 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