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: AW: Prepend licence information to every source file
Date Fri, 17 Sep 2004 14:41:23 GMT
Should be possible to get the first line of the file via regexp.
Something like
  (.*)${line.separator}.*  --> $1
or so ...

Jan

> -----Urspr√ľngliche Nachricht-----
> Von: Peter Reilly [mailto:peterreilly@apache.org]
> Gesendet am: Freitag, 17. September 2004 16:24
> An: Ant Users List
> Betreff: Re: AW: AW: AW: Prepend licence information to every source
> file
> 
> yes that works too (slaps head!).
> 
>   <target name="addlicense">
>     <loadfile srcfile="license-java.txt" property="license"/>
>     <replaceregexp flags="s" match="(.*)" replace="${license}\1">
>       <fileset dir="src" includes="**/*.java">
>         <not>
>           <contains text="you may not use this file except in 
> compliance 
> with the License"/>
>         </not>
>       </fileset>
>     </replaceregexp>
>   </target>
> 
> 
> Note that the <contains> file selector only works
> on one line at a time, so it cannot use <contains text="${license}"/>
> 
> Also, be careful with the contents of the license file,
> special characters like \ will cause problems (like \0) with
> the regexp replace string.
> 
> Peter
> 
> Jan.Materne@rzf.fin-nrw.de wrote:
> 
> >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
> >>
> >>    
> >>
> >
> >  
> >
> 
> 
> ---------------------------------------------------------------------
> 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