[releng] improve scripts

Change-Id: Ib742deeea8bc5aa08e8619a27e925c862336460d
Signed-off-by: David Williams <david_williams@us.ibm.com>
diff --git a/build.xml b/build.xml
index bfa40da..9f03c69 100644
--- a/build.xml
+++ b/build.xml
@@ -73,7 +73,7 @@
         purpose of the .options ... so list which mirrors that artifacts come from.
 
     <copy
-      file="${buildWorkarea}/${BUILD_TOOLS}/p2options/.options"
+      file="${BUILD_HOME}/${BUILD_TOOLS}/p2options/.options"
       todir="${ECLIPSE_HOME}/eclipse/" />
     -->
     <!--
@@ -474,7 +474,7 @@
     <!-- -Dorg.eclipse.update.jarprocessor.pack200=${JAVA_6_HOME}/jre/bin -Declipse.p2.mirrors=false" -->
     <property
       name="BUILDER_VM_ARGS"
-      value="-Xmx1024m -Djava.io.tmpdir=${BUILD_HOME}/tmp"  />
+      value="-Xmx1024m -Djava.io.tmpdir=${BUILD_HOME}/tmp" />
     <echo message="AGG_APP_ARGS: ${AGG_APP_ARGS}" />
     <echo message="BUILDER_VM_ARGS: -vmargs ${BUILDER_VM_ARGS}" />
 
@@ -484,7 +484,7 @@
       failonerror="false"
       resultproperty="buildStatus">
       <arg value="-debug" />
-      <arg value="file://${buildWorkarea}/${BUILD_TOOLS}/p2options/.options" />
+      <arg value="file://${BUILD_HOME}/${BUILD_TOOLS}/p2options/.options" />
       <!--
         Adding -consolelog makes for too much, unneeded output, since the aggregator
         produces its verbose own output, slightly cleaner.
@@ -522,18 +522,23 @@
          so we pause a few seconds for NSF to catch up.
     -->
     <echo message="Waiting 2 seconds..." />
-    <sleep seconds="2"/>
-      <echo message="Waiting 2 seconds..." />
-      <sleep seconds="2"/>
-      <echo message="Waiting 2 seconds..." />
-      <sleep seconds="2"/>
-    
+    <sleep seconds="2" />
+    <echo message="Waiting 2 seconds..." />
+    <sleep seconds="2" />
+    <echo message="Waiting 2 seconds..." />
+    <sleep seconds="2" />
 
+    <antcall target="runTests" />
+
+  </target>
+
+  <!-- runTests can be ran as manual job, but then should use custom workspace, 
+       to run against previous build, and acquire the lock, for that job -->
+  <target name="runTests">
     <ant
-      antfile="${buildWorkarea}/testInstance/eclipse/dropins/${RELENG_TESTS_BUNDLE_ID}/runTests.xml"
-      target="cleanBuild"
-      dir="${buildWorkarea}" />
-
+      antfile="${BUILD_HOME}/testInstance/eclipse/dropins/${RELENG_TESTS_BUNDLE_ID}/runTests.xml"
+      target="cleanBuildTests"
+      dir="${BUILD_HOME}" />
   </target>
 
   <target name="checkStatus">
@@ -593,7 +598,7 @@
       <!-- -Dorg.eclipse.update.jarprocessor.pack200=${JAVA_6_HOME}/jre/bin -Declipse.p2.mirrors=false" -->
     <property
       name="BUILDER_VM_ARGS"
-      value="-Xmx1024m -Djava.io.tmpdir=${BUILD_HOME}/tmp"  />
+      value="-Xmx1024m -Djava.io.tmpdir=${BUILD_HOME}/tmp" />
     <echo message="AGG_APP_ARGS: ${AGG_APP_ARGS}" />
     <echo message="BUILDER_VM_ARGS: -vmargs ${BUILDER_VM_ARGS}" />
 
@@ -603,7 +608,7 @@
       failonerror="false"
       resultproperty="buildStatus">
       <arg value="-debug" />
-      <arg value="file://${buildWorkarea}/${BUILD_TOOLS}/p2options/.options" />
+      <arg value="file://${BUILD_HOME}/${BUILD_TOOLS}/p2options/.options" />
       <!--
         Adding -consolelog makes for too much, unneeded output, since the aggregator
         produces its verbose own output, slightly cleaner.
@@ -637,9 +642,9 @@
     <antcall target="createBuildinfo" />
 
     <ant
-      antfile="${buildWorkarea}/testInstance/eclipse/dropins/${RELENG_TESTS_BUNDLE_ID}/runTests.xml"
+      antfile="${BUILD_HOME}/testInstance/eclipse/dropins/${RELENG_TESTS_BUNDLE_ID}/runTests.xml"
       target="cachedBuild"
-      dir="${buildWorkarea}" />
+      dir="${BUILD_HOME}" />
 
   </target>
 
@@ -675,7 +680,7 @@
 <!--    -Dorg.eclipse.update.jarprocessor.pack200=${JAVA_6_HOME}/jre/bin -Declipse.p2.mirrors=false" -->
     <property
       name="BUILDER_VM_ARGS"
-      value="-Xmx1024m -Djava.io.tmpdir=${BUILD_HOME}/tmp"  />
+      value="-Xmx1024m -Djava.io.tmpdir=${BUILD_HOME}/tmp" />
     <echo message="AGG_APP_ARGS: ${AGG_APP_ARGS}" />
     <echo message="BUILDER_VM_ARGS: -vmargs ${BUILDER_VM_ARGS}" />
 
@@ -685,7 +690,7 @@
       failonerror="false"
       resultproperty="buildStatus">
       <arg value="-debug" />
-      <arg value="file://${buildWorkarea}/${BUILD_TOOLS}/p2options/.options" />
+      <arg value="file://${BUILD_HOME}/${BUILD_TOOLS}/p2options/.options" />
       <!--
         Adding -consolelog makes for too much, unneeded output, since the aggregator
         produces its verbose own output, slightly cleaner.
@@ -720,15 +725,15 @@
     <antcall target="createBuildinfo" />
 
     <ant
-      antfile="${buildWorkarea}/testInstance/eclipse/dropins/${RELENG_TESTS_BUNDLE_ID}/runTests.xml"
+      antfile="${BUILD_HOME}/testInstance/eclipse/dropins/${RELENG_TESTS_BUNDLE_ID}/runTests.xml"
       target="validateOnly"
-      dir="${buildWorkarea}" />
+      dir="${BUILD_HOME}" />
 
   </target>
 
   <target
     name="init"
-    depends="getBuildTimestamp, getJobName, getBuildWorkarea"
+    depends="getBuildTimestamp, getJobName, getBUILD_HOME"
     unless="isInitialized">
 
     <fail
@@ -748,11 +753,6 @@
 
     <loadproperties srcfile="${aggrPropertyFile}" />
 
-    <!-- quick fail, if set up wrong -->
-    <fail
-      unless="BUILD_HOME"
-      message="BUILD_HOME must be set before running this script" />
-
     <!--
         rewriteRepositoryURLValue is an important variable, passed in through
         production.properties. It is the trigger to change http:// values, to
@@ -821,7 +821,7 @@
 
     <property
       name="eclipseWorkspace"
-      value="${buildWorkarea}/eclipseworkingspace" />
+      value="${BUILD_HOME}/eclipseworkingspace" />
 
     <!--
       If the eclipse workspace exists, remove it, to make sure we are starting "fresh". Eclipse will create it. Be sure some "archive
@@ -833,7 +833,7 @@
 
     <property
       name="javaIOTmpdir"
-      value="${buildWorkarea}/tmp" />
+      value="${BUILD_HOME}/tmp" />
     <mkdir dir="${javaIOTmpdir}" />
     <!--
          In case java.io.tmpdir is "passed in", technically, it is BUILDER_VM_ARGS
@@ -903,7 +903,7 @@
     <echo message="buildId: ${buildTimestamp}" />
     <echo message="user.dir: ${user.dir}" />
     <echo message="user.home: ${user.home}" />
-    <echo message="buildWorkarea (HUDSON workspace): ${buildWorkarea}" />
+    <echo message="BUILD_HOME (HUDSON workspace): ${BUILD_HOME}" />
     <echo message="Eclipse WORKSPACE: ${eclipseWorkspace}" />
     <echo message="PATH: ${env.PATH}" />
     <echo message="JAVA_HOME: ${JAVA_HOME}" />
@@ -983,22 +983,32 @@
   </target>
 
   <target
-    name="getBuildWorkarea"
-    depends="getJobName, getHudsonBuildWorkarea"
-    unless="buildWorkarea">
+    name="getBUILD_HOME"
+    depends="getJobName, getHudsonBUILD_HOME"
+    unless="BUILD_HOME">
     <property
-      name="buildWorkarea"
+      name="BUILD_HOME"
       value="${basedir}" />
-    <echo message="Setting buildWorkarea as basedir: ${buildWorkarea}" />
+    <echo message="Setting BUILD_HOME as basedir: ${BUILD_HOME}" />
   </target>
 
   <target
-    name="getHudsonBuildWorkarea"
-    unless="buildWorkarea">
+    name="getHudsonBUILD_HOME"
+    depends="getWorkspace"
+    unless="BUILD_HOME">
     <property
-      name="buildWorkarea"
+      name="BUILD_HOME"
       value="${env.WORKSPACE}" />
-    <echo message="Setting buildWorkarea from Hudson Builder WORKSPACE: ${buildWorkarea}" />
+    <echo message="Setting BUILD_HOME from Hudson Builder WORKSPACE: ${BUILD_HOME}" />
+  </target>
+
+  <target
+    name="getWorkspace"
+    unless="BUILD_HOME">
+    <property
+      name="BUILD_HOME"
+      value="${WORKSPACE}" />
+    <echo message="Setting BUILD_HOME from direct property of Hudson Builder WORKSPACE: ${BUILD_HOME}" />
   </target>
 
   <target