I want to do multiple builds in ant but the files in /tmp getting cleared by one build and fails the other. How to set a different value for TEMP variable. Tried setting env key="TEMPDIR" path="/tmp/mytemp1", env key="TEMP" path="/tmp/mytemp1", env key="TMP" path="/tmp/mytemp1", env key=" java.io.tmpdir" path="/tmp/mytemp1" but no luck. In short, how can I change value of TEMP for each process?
Asked
Active
Viewed 404 times
1 Answers
1
I would suggest you look at using the standard ANT tempfile task to create temporary files.
A more common approach to this problem is to create a "build" directory in the project workspace and a "clean" target to remove files that are created by the ANT build:
<property name="build.dir" location"build"/>
<property name="classes.dir" location"${build.dir}/classes"/>
<target name="compile">
<mkdir dir="${classes.dir}"/>
<javac srcdir="${src.dir}" destdir="${classes.dir}"...
</target>
<target name="clean">
<delete dir="${build.dir}"/>
</target>
To ensure a clean build of the project you run it as follows:
ant clean compile
Update
Other stackoverflow questions related to setting temp directory

Community
- 1
- 1

Mark O'Connor
- 76,015
- 10
- 139
- 185
-
Thanks for the reply. But I am looking for not to clean up the files. I want to have different tmp dirs for each build so that one build will not affect another. How can I assign value to java.io.tmpdir in ant at runtime? – Baiju Apr 24 '13 at 05:36
-
Thanks for the update. I have seen these posts earlier but I didn't get proper way to implement this is ant script. I tried using env, key pair in exec task but it ddn't work. I am trying trying to provide different tmp value in exec task which will invoke runassembler command and this runassember using the /tmp to pack the ears. – Baiju Apr 25 '13 at 04:08
-
@Baiju Sounds like you're paddling upstream. Using a "clean" target is the standard way to solve this problem. Personally I like to see the files created by my build, rather than have them hidden away in the /tmp directory. – Mark O'Connor Apr 26 '13 at 13:29