Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ant: how to compare contents of two files

Tags:

ant

I want to compare the contents of two files (say file1.txt,file2.txt) using ANT.

if files content are same then it should set some 'property' to true, if contents are not same then it should set the 'property' as false.

Can anyone suggest me any ANT task that can do this.

Thanks in advance.

like image 981
nitinJi Avatar asked Jun 08 '11 17:06

nitinJi


People also ask

How can I compare two files in Android?

Go to file name in project then press control then select Compare File and select another file you wish to compare. Seperate window will open up showing differences by colour contrast. Welcome to SO !


1 Answers

You can use something like:

<condition property="property" value="true">
  <filesmatch file1="file1"
              file2="file2"/>
</condition>

This will set the property only if the files are the same. You can then check for the property, using

<target name="foo" if="property">
...
</target>

This is available in ant, with no added dependency, see here for other conditions.

like image 74
tonio Avatar answered Sep 21 '22 12:09

tonio