ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Dominique Devienne <>
Subject RE: fill a property with filesize
Date Thu, 31 Oct 2002 16:07:05 GMT
Maybe so, but overloading tasks with different meaning/function is not good
either. Personally, I believe scripting to be much more appropriate in this
case, and is equivalent to task scripting, which exists in the Ant2
proposals, and missing in Ant1. Remember that it's pure Java scripting, this
portable, only provides access to normal JDK functionality. Anyways... --DD

With bsf.jar and js.jar in ant/lib, I get it in 3 lines of javascript:

P:\org_apache\antx>type filesize-script.xml
<?xml version="1.0"?>

<!-- ANT build file to test a specific feature or bug of ANT.
     Dominique Devienne <>      October 2002
<project name="filesize" default="test" basedir=".">

  <target name="test">
    <!-- Sets the file.size property with the length of the
         file as named in the ant.file property -->
    <script language="javascript"><![CDATA[
      filename = self.getProject().getProperty("ant.file");
      file = new;
      self.getProject().setNewProperty("file.size", file.length());
    <echo message="current build file size is '${file.size}'" />


P:\org_apache\antx>%ANT_HOME%\bin\ant -f filesize-script.xml
Buildfile: filesize-script.xml

     [echo] current build file size is '680'

Total time: 1 second

-----Original Message-----
From: Veld in 't, GJ (Geert Jan) [] 
Sent: Thursday, October 31, 2002 9:53 AM
To: 'Ant Users List'
Subject: RE: fill a property with filesize

I already made an enhancement to the LoadFile task:
	copy/paste (because its a final class)
	add a new property (fileSizeOnly...)

Does it sound like a welcome change?

Personally I dont like scripting... I find it less clean... but maybe
somebody can convince me.. ;-)

-----Oorspronkelijk bericht-----
Van: Dominique Devienne []
Verzonden: donderdag 31 oktober 2002 16:19
Aan: 'Ant Users List'
Onderwerp: RE: fill a property with filesize

Sounds like a task for this is overkill. How about trying out <script>? One
or two lines of JavaScript (or BeanShell, or whatever else BSF scripting
language) should do the trick. Just read carefully the dependencies section
of the manual to get the appropriate JARs you need to get it running (At
minimum bsf.jar, plus the JAR of the scripting engine). --DD

-----Original Message-----
From: Veld in 't, GJ (Geert Jan) [] 
Sent: Thursday, October 31, 2002 4:39 AM
To: ''
Subject: fill a property with filesize


I want to fill a property with the size of a given file. I cant find any
existing functionality for that.

Is there a task wich can do this for me?
Should i create a new task for that?
Or should i extend an existing one? (which?)

Kind regards,
Geert Jan in 't Veld

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

De informatie opgenomen in dit bericht kan vertrouwelijk zijn en 
is uitsluitend bestemd voor de geadresseerde. Indien u dit bericht 
onterecht ontvangt, wordt u verzocht de inhoud niet te gebruiken en 
de afzender direct te informeren door het bericht te retourneren. 
The information contained in this message may be confidential 
and is intended to be exclusively for the addressee. Should you 
receive this message unintentionally, please do not use the contents 
herein and notify the sender immediately by return e-mail.

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

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

View raw message