• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Conditionally copying parts of a file using Ant

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello,

I have a build script that creates a new file (using the concat task) consisting of todays results, followed by the history results file. This new file is now considered to be the history results file. However if the history file already contains todays data (i.e. this process has already been run today), then I don't want to append all of the history file. I only want from line 12 onwards in the history file (everything before today).

Does anyone have any idea as to how I can achieve this using Ant and what tasks I should be investigating?

Manually, I can determine whether the history file has todays data in it, since the date I am interested in will be at line 2 of the history file, but I have no idea how to do this sort of thing using ant.

Thanks in advance,
Francis
 
Ranch Hand
Posts: 167
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Try using regular expressions.
You could also try using temporary file.

If you elaborate a little more, I would have a solution for you.
 
Ranch Hand
Posts: 88
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In fact I have a similar problem. I need my build script to read a list of files from wherever(maybe notepad or another xml) and get those and only those files from the VSS with the latest checked in version of those files. Any solutions?
 
Ranch Hand
Posts: 1953
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The simplest way to do such very-speicific-to-your-project task is to write a customized ant task which extens Task. It is easy and flexible to your own specifications.

Just remember, ant is Java based. Anything that Java can do, ant can do it!!!

If you want to avoid compilation, you also can use JavaScript to do the job, but you need to add libraries, such as bsf.jar...
reply
    Bookmark Topic Watch Topic
  • New Topic