ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jan.Mate...@rzf.fin-nrw.de
Subject AW: AW: AW: Prepend licence information to every source file
Date Fri, 17 Sep 2004 13:47:11 GMT
just another idea:
- use selectors (contains,...) to get a fileset with files without the
header (like
  Peter wrote)
- use regexps for inline editing (<replaceregexp> task)
  match:   (.*)
  replace: ${header}\1
  flags:   s

Jan

> -----Urspr√ľngliche Nachricht-----
> Von: Peter Reilly [mailto:peterreilly@apache.org]
> Gesendet am: Freitag, 17. September 2004 15:42
> An: Ant Users List
> Betreff: Re: AW: AW: Prepend licence information to every source file
> 
> There is no in-place prepend task (I think), but one can do this
> by
>   1) getting a fileset that contain the files the need the license to
>      be added
>   2) iterate over the the files added the license by
>          a) adding the licence to a file making a new file
>          b) move that new file to overwrite the original file
> 
> one can use the ant-contrib <for> task to do the iteration:
> 
> <project default="addlicense" xmlns:ac="antlib:net.sf.antcontrib">
>   <target name="addlicense">
>     <ac:for param="file">
>       <fileset id="missing" dir="src" includes="**/*.java">
>         <not>
>           <contains text="you may not use this file except in 
> compliance 
> with the License"/>
>         </not>
>       </fileset>
>       <sequential>
>         <copy file="@{file}" tofile="@{file}.withlicense">
>           <filterchain>
>             <concatfilter prepend="license-java.txt"/>
>           </filterchain>
>         </copy>
>         <move file="@{file}.withlicense" tofile="@{file}"/>
>       </sequential>
>     </ac:for>
>   </target>
> </project>
> 
> Peter
> Kannan V wrote:
> 
> >Hi Jan,
> >
> >  Thanks for the help. So that means that if my source files 
> doesn't have header info, then 
> >I have to copy them to a temp location for adding the 
> licence text. I was trying to avoid that 
> >copying to temp location part so that I can run the task on 
> my src folder directly.
> >
> >thannks and regards,
> >
> >-- Kannan.
> >  
> >
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
> For additional commands, e-mail: user-help@ant.apache.org
> 

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message