0

I am using this script to calculate the md5 of files

<?xml version="1.0"?>
<project name="Hello World Project" basedir="." default="checkChecksum">
    <property name="cms.dir" value="D:\CMS\webclient\WebContent" />
    <taskdef resource="net/sf/antcontrib/antlib.xml"/>

    <target name="createChecksum">
        <checksum todir="./checksum">
            <fileset dir="${cms.dir}"/>
        </checksum>

        <echo>Hello World - Welcome to Apache Ant!</echo>
        <fileset id="src.files" dir="${cms.dir}" casesensitive="yes">
            <include name="**/*.uim"/>
            <include name="**/*.properties"/>
        </fileset>
        <pathconvert pathsep="${line.separator}" property="sounds" refid="src.files">
        </pathconvert>
        <echo file="sounds.txt">${sounds}</echo>
        <loadfile property="files" srcFile="./sounds.txt"/>
        <for list="${files}" delimiter="${line.separator}" param="file1">
            <sequential>
                <echo>@{file1}</echo>
            </sequential>
        </for>
    </target>
</project>

Is there any way to get the name of the file which got modified I mean whose md5 dont match ??

thekbb
  • 7,668
  • 1
  • 36
  • 61
Deepak_Sharma
  • 61
  • 2
  • 10

1 Answers1

1

Can be done using an ANT selector.

<project name="name" default="print-modified">

  <target name="print-modified">
    <apply executable="echo">
      <srcfile/>
      <fileset dir="src">
        <modified/>
      </fileset>
    </apply>
  </target>

</project>

Note:

  • Using the apply task is a way to iterate without including the ant-contrib foreach task.
Mark O'Connor
  • 76,015
  • 10
  • 139
  • 185
  • fill the filename will be printed in the console ??? Can i put the modified file in a kind of data structure like a list and past it to ant task ????? – Deepak_Sharma Nov 29 '13 at 02:37
  • @Deepak_Sharma What are you trying to do with the files? Many ANT are designed to operate on a fileset (for example the "apply" task above). The ANT contrib looping tasks on the other hand are not part of standard ANT, so, maybe you're not approaching the problem in the optimal way – Mark O'Connor Nov 29 '13 at 15:04
  • I wanted to have a list of fils which got modified and then using the ant task to know which folder they are in – Deepak_Sharma Nov 29 '13 at 18:39
  • @Deepak_Sharma So something like this? http://stackoverflow.com/questions/15688346/get-directories-with-modified-files-with-ant/15703384#15703384 – Mark O'Connor Nov 29 '13 at 18:51
  • Can i do something like this – Deepak_Sharma Nov 29 '13 at 19:40
  • @Deepak_Sharma That will copy the modified files, not the the directories. – Mark O'Connor Nov 29 '13 at 20:04