Almost two weeks ago (gee, I must find more time, somewhere, somehow) Vincent Massol talked about "reusable Ant tasks".

Looking closer, he doesn't really want to reuse the Ant tasks, he wants to reuse logic from the tasks. Instead of

Expand expand = new Expand();
expand.setSrc(new File(zipfile));
expand.setDest(new File(destdir));
expand.setLogger(myLogger);
expand.execute();
you really want to write (pure fiction right now)
ZipUtils.expand(new File(zipfile), new File(destdir));

Ant has already factored out quite some pieces into helper classes, take a look at FileUtils with copyFile and renameFile for example. There certainly is more we could move around into pieces independent of Ant and I expect this to happen when we create more antlibs.

So far I don't sense any resistance against moving code into helper classes, but you must understand this is not a first-class concern for Ant. Ant can reuse Ant quite well ;-)

If you want to reuse a piece of code from Ant and think it is not accessible enough, I wouldn't expect us to reject your patches. The only thing you need to be aware of is that Ant's holy grail of backwards-compatibility applies to the public Java APIs as well, so please don't break them. Join dev@ant and tell us about your ideas.

path: /en/Apache/Ant | #

Have I ever said that IKVM.NET is cool? I should.

Octavo:/tmp bodewig$ cat > build.xml
<project>
  <echo>os.name = ${os.name}</echo>
  <echo>java.home = ${java.home}</echo>
  <echo>ant.java.version = ${ant.java.version}</echo>
  <echo>java.vendor = ${java.vendor}</echo>
  <echo>java.version = ${java.version}</echo>
</project>
^D
Octavo:/tmp bodewig$ ant
Buildfile: build.xml
     [echo] os.name = Mac OS X
     [echo] java.home = /System/Library/Frameworks/JavaVM.framework/Versions/1.4.2/Home
     [echo] ant.java.version = 1.4
     [echo] java.vendor = Apple Computer, Inc.
     [echo] java.version = 1.4.2_05

BUILD SUCCESSFUL
Total time: 2 seconds


Octavo:/tmp bodewig$ JAVACMD=/usr/bin/mono ANT_OPTS=/Users/bodewig/ikvm/bin/ikvm.exe ant
Unable to locate tools.jar. Expected to find it in /Users/bodewig/ikvm/bin/lib/tools.jar
Buildfile: build.xml
     [echo] os.name = Unix 7.8.0.0
     [echo] java.home = /Users/bodewig/ikvm/bin
     [echo] ant.java.version = 1.5
     [echo] java.vendor = Jeroen Frijters
     [echo] java.version = 1.4

BUILD SUCCESSFUL
Total time: 23 seconds

More experiments to come.

The difference between in java.version and ant.java.version means, GNU CLASSPATH already has java.lang.Readable

path: /en/dotNet/ikvmnet | #