ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Dominique Devienne <DDevie...@lgc.com>
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 <ddevienne@lgc.com>      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 java.io.File(filename);
      self.getProject().setNewProperty("file.size", file.length());
    ]]></script>
    <echo message="current build file size is '${file.size}'" />
  </target>

</project>

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

test:
     [echo] current build file size is '680'

BUILD SUCCESSFUL
Total time: 1 second
P:\org_apache\antx>

-----Original Message-----
From: Veld in 't, GJ (Geert Jan) [mailto:G.J.Veld@rf.rabobank.nl] 
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 [mailto:DDevienne@lgc.com]
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) [mailto:G.J.Veld@rf.rabobank.nl] 
Sent: Thursday, October 31, 2002 4:39 AM
To: 'ant-user@jakarta.apache.org'
Subject: fill a property with filesize

Hi,

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:   <mailto:ant-user-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:ant-user-help@jakarta.apache.org>




================================================
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:   <mailto:ant-user-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:ant-user-help@jakarta.apache.org>

--
To unsubscribe, e-mail:   <mailto:ant-user-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:ant-user-help@jakarta.apache.org>


Mime
View raw message