You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by Stephen Rozum <ro...@ispwest.com> on 2002/12/08 21:46:03 UTC

How does one pre-append lines

Hello all,

I have come across the following problem and I am looking for a nice solution to address it.

What I need to to is command similiar to <echo> with a option to pre-append the echo string to the beginning of the file. 

Note: I need this tool since some of our Java code is automatically generated and the tool that generates the code has no concepts of packages.  What I need to do is add a package statement to the beginning of the file.  Unfortunately, changing the routine that generates the code is not an option.

I see three possible solutions:

1) Write an external tool class that would be called by Ant to prepend the string.

2) Modify Ant with a new option for prepending the data.  Unfortunately, it would be a local modification would need to be re-implemented each time we update Ant with the latest revision. 

3) Use existing Ant command to accomplish this task.

I would like to use option 3, but being relatively new to the Ant environment, I am unsure of the best way of doing this.  Note: All of the files to be modified will be contained in thier own directory.

One possible algorithm that I thought of was to:
1) Copy all of the *.java files to another temporary directory
2) For each *.java in the original directory replace the contents with the package information.
3) For each of the files in the temporary directory, concatenate it with its original's file name in the original directory.

Thanks ahead of time for any help.


Regards,


Stephen
  



--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: How does one pre-append lines

Posted by Erik Hatcher <ja...@ehatchersolutions.com>.
How about a little <concat> with a <filelist> action?  That should do 
the trick, right?

	Erik


Stephen Rozum wrote:
> Hello all,
> 
> I have come across the following problem and I am looking for a nice solution to address it.
> 
> What I need to to is command similiar to <echo> with a option to pre-append the echo string to the beginning of the file. 
> 
> Note: I need this tool since some of our Java code is automatically generated and the tool that generates the code has no concepts of packages.  What I need to do is add a package statement to the beginning of the file.  Unfortunately, changing the routine that generates the code is not an option.
> 
> I see three possible solutions:
> 
> 1) Write an external tool class that would be called by Ant to prepend the string.
> 
> 2) Modify Ant with a new option for prepending the data.  Unfortunately, it would be a local modification would need to be re-implemented each time we update Ant with the latest revision. 
> 
> 3) Use existing Ant command to accomplish this task.
> 
> I would like to use option 3, but being relatively new to the Ant environment, I am unsure of the best way of doing this.  Note: All of the files to be modified will be contained in thier own directory.
> 
> One possible algorithm that I thought of was to:
> 1) Copy all of the *.java files to another temporary directory
> 2) For each *.java in the original directory replace the contents with the package information.
> 3) For each of the files in the temporary directory, concatenate it with its original's file name in the original directory.
> 
> Thanks ahead of time for any help.
> 
> 
> Regards,
> 
> 
> Stephen
>   
> 
> 
> 
> --
> To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
> For additional commands, e-mail: <ma...@jakarta.apache.org>
> 
> 
> 


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


RE: How does one pre-append lines

Posted by "Bruno.Konik" <br...@unigone.com>.
one suggestion is to make add by the generator tool a single line at the
begining of each file. For example :
@PACKAGE_INFORMATION@

and make this replace by the right information by the ant Replace task or
use a Filter...

Of course, this implies modifying your generator tool a bit...

Bruno

> -----Message d'origine-----
> De : Stephen Rozum [mailto:rozum@ispwest.com]
> Envoyé : dimanche 8 décembre 2002 21:46
> À : ant-user@jakarta.apache.org
> Objet : How does one pre-append lines
>
>
> Hello all,
>
> I have come across the following problem and I am looking for a
> nice solution to address it.
>
> What I need to to is command similiar to <echo> with a option to
> pre-append the echo string to the beginning of the file.
>
> Note: I need this tool since some of our Java code is
> automatically generated and the tool that generates the code has
> no concepts of packages.  What I need to do is add a package
> statement to the beginning of the file.  Unfortunately, changing
> the routine that generates the code is not an option.
>
> I see three possible solutions:
>
> 1) Write an external tool class that would be called by Ant to
> prepend the string.
>
> 2) Modify Ant with a new option for prepending the data.
> Unfortunately, it would be a local modification would need to be
> re-implemented each time we update Ant with the latest revision.
>
> 3) Use existing Ant command to accomplish this task.
>
> I would like to use option 3, but being relatively new to the Ant
> environment, I am unsure of the best way of doing this.  Note:
> All of the files to be modified will be contained in thier own directory.
>
> One possible algorithm that I thought of was to:
> 1) Copy all of the *.java files to another temporary directory
> 2) For each *.java in the original directory replace the contents
> with the package information.
> 3) For each of the files in the temporary directory, concatenate
> it with its original's file name in the original directory.
>
> Thanks ahead of time for any help.
>
>
> Regards,
>
>
> Stephen
>
>
>
>
> --
> To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
> For additional commands, e-mail: <ma...@jakarta.apache.org>
>


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>