ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Peter Reilly <peterrei...@apache.org>
Subject Re: AW: AW: Prepend licence information to every source file
Date Fri, 17 Sep 2004 13:42:15 GMT
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
View raw message