6982499: ant detection is fragile on windows. especially using cygwin
authorigor
Tue, 07 Sep 2010 11:28:28 -0700
changeset 6790 0451bcf8dfa9
parent 6789 7388434c2fa8
child 6791 1d80c4d4c908
6982499: ant detection is fragile on windows. especially using cygwin Reviewed-by: ohair
jdk/make/common/shared/Defs.gmk
--- a/jdk/make/common/shared/Defs.gmk	Tue Sep 07 11:24:28 2010 -0700
+++ b/jdk/make/common/shared/Defs.gmk	Tue Sep 07 11:28:28 2010 -0700
@@ -578,10 +578,23 @@
     ANT_HOME := $(call DirExists,$(JDK_DEVTOOLS_DIR)/share/ant/latest,,)
   endif
 endif
+
+# There are few problems with ant we need to workaround:
+#  1) ant is using temporary directory java.io.tmpdir
+#     However, this directory is not unique enough and two separate ant processes
+#     can easily end up using the exact same temp directory. This may lead to weird build failures
+#     To workaround this we will define tmp dir explicitly
+#  2) ant attempts to detect JDK location based on java.exe location
+#     This is fragile as developer may have JRE first on the PATH. 
+#     To workaround this we will specify JAVA_HOME explicitly
+
+ANT_TMPDIR = $(ABS_OUTPUTDIR)/tmp
+ANT_WORKAROUNDS = ANT_OPTS=-Djava.io.tmpdir='$(ANT_TMPDIR)' JAVA_HOME='$(BOOTDIR)'
+
 ifeq ($(ANT_HOME),)
-  ANT = ant
+  ANT = $(ANT_WORKAROUNDS) ant
 else
-  ANT = $(ANT_HOME)/bin/ant
+  ANT = $(ANT_WORKAROUNDS) $(ANT_HOME)/bin/ant
 endif
 
 ifdef ALT_COPYRIGHT_YEAR