I’d like to create a temporary directory in ant (version 1.6.5) and assign it to a property.
- The command “mktemp -d” would be ideal for this, but I cannot find similar functionality from inside ant
- I can’t find any official function in the docs apart from the tempfile task which apparently only creates files, not directories.
- I’m considering using exec to call tempfile and get the result, however this will make my build.xml dependent on UNIX/linux, which I’d like to avoid.
Background: I’m trying to speed up an existing build process which builds inside networked filesystem. The build already copies all the source to a temporary directory, however this is on the same filesystem. I’ve tested changing this to /tmp/foo and it gives a worthwhile speed increase: 3mins vs 4mins.
You could combine the tempfile task with the
java.io.tmpdirsystem property to get a file path to use to create a temporary dir:Note that the
tempfiletask does not create the file (unless you ask it to). It just sets a property which you can use to create a file or dir.Output in my environment: