1

In my Groovy program, I am using Groovy AntBuilder to call the Ant ReplaceRegExp task.

def antBuilder = new AntBuilder()
antBuilder.replaceregexp(....)

However on Unix, I get the following exception:

Could not create tempfile in /tmp
    at org.apache.tools.ant.util.FileUtils.createTempFile(FileUtils.java:941)
    at org.apache.tools.ant.taskdefs.optional.ReplaceRegExp.doReplace(ReplaceRegExp.java:353)

The UNIX user I use to run the Goovy program does not have permissions for the default java temp directory. When using Ant directly, I can work around this by specifying the java.io.tmpdir for Ant using ANT_OPTS.

export ANT_OPTS="${ANT_OPTS} -Djava.io.tmpdir=/scratch/mydir/tmp"

Qs: With Groovy AntBuilder in Groovy code, how can I specify the java.io.tmpdir for AntBuilder?

Perihelion
  • 33
  • 1
  • 6

1 Answers1

0

Would setting java.io.tmpdir with setProperty or passing java.io.tmpdir via -D switch, e.g. -Djava.io.tmpdir=some_path help?

Opal
  • 81,889
  • 28
  • 189
  • 210
  • Yes, setting java.io.tmpdir with `setProperty` within the Groovy program worked. Still curious however if there is a way to set the tmp dir on the AntBuilder object itself. Maybe there isn't ... but this approach does the job. – Perihelion Jun 16 '16 at 04:47