ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Yanrong Deng <>
Subject help!
Date Wed, 12 May 2004 02:08:39 GMT

We want to use ant file to indicate the change of a file. That is, when the 
file is same as before, ant build file will give us a verification message; if 
the file is different from last time, ant build file will return an error 

What we did is like this:
source code is ct.xml:
 <target name="GenerateCheckSum">
  <checksum file="x" forceoverwrite="yes" /> 
 <target name="SeeIfXChanged">
  <checksum file="x" verifyProperty="XChangedOrNot" /> 
  <echo>Verification 2</echo> 
 <target name="ErrorMessageIfXChanged" depends="SeeIfXChanged" 
  <echo>Verification Succeeded</echo> 

First, we prepared a text file x. This is the file on which we wish to monitor 

Second, use command to create the MD5 file---x.MD5 for x as below:
	ant -buildfile ct.xml GenerateCheckSum

Third, use command as below to check if the file x has changed by comparing 
this CheckSum with the CheckSum we got in previous step. 
(this time we didn't change file x)
	ant -buildfile ct.xml ErrorMessageIfXChanged
This returned "Verification Succeeded" as we anticipated.
(The debugging revealed that "the project propety XChangedOrNot -> true")

Fourth, we change file x with a text editor.

Fifth, we use command "ant -buildfile ct.xml ErrorMessageIfXChanged >&
DebugOutput" again. The debugging revealed that "the project propety
XChangedOrNot -> false" as expected. Thus, We should not get "Verification
succeeded", since this CheckSum is different from last one because file
x was changed. But the output is "Verification Succeeded". This means
our ant build file didn't work as we inticipated; the problem looks like
the last target of ct.xml, but not doing the "CheckSum". But, we don't
know what's wrong.

Here is the DebugOutput:

Apache Ant version 1.6.0 compiled on December 18 2003
Buildfile: ct.xml
Adding reference: ant.PropertyHelper
Detected Java version: 1.4 in: /usr/java/j2sdk1.4.1_01/jre
Detected OS: Linux
Adding reference: ant.ComponentHelper
Setting ro project property: ant.version -> Apache Ant version 1.6.0 compiled 
on December 18 2003
Setting ro project property: ant.file -> /home/leffstudent/Project/ct.xml
Adding reference: ant.projectHelper
Adding reference: ant.parsing.context
Adding reference: ant.targets
parsing buildfile /home/leffstudent/Project/ct.xml with URI = 
Setting ro project property: ant.file.null -> /home/leffstudent/Project/ct.xml
Project base dir set to: /home/leffstudent/Project
 +Target: GenerateCheckSum
 +Target: SeeIfXChanged
 +Target: ErrorMessageIfXChanged
Build sequence for target `ErrorMessageIfXChanged' is [SeeIfXChanged, 
Complete build sequence is [SeeIfXChanged, ErrorMessageIfXChanged, 
GenerateCheckSum, ]

Setting project property: XChangedOrNot -> false
     [echo] Verification 2

     [echo] Verification Succeeded

Total time: 1 second

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message