I'm trying to check if a file is empty before processing it, all of that from my ANT task.
Basically I have the following target that is called by another main target, i have other targets called after this one that I want to run whatever happens to this one:
<target name="mytarget">
<!-- Copy a file -->
<get verbose="true" ignoreerrors="no"
src="..."
dest="bla.txt" />
<property name="file.bla" value="bla.txt" />
<!-- Check if the file is empty -->
<script language="javascript"> <![CDATA[
importClass(java.io.File);
file = project.getProperty("file.bla");
var filedesc = new File(file);
var size = filedesc.size;
if (size==0){
//? Exit the target cleanly
}
]]> </script>
<!-- If the file is not empty, process it with ANT. -->
<!-- ... ->
</target>
- What is the easiest way to check a file size without ANT Contrib?
- How do I quit the current target without breaking the rest of the execution?