338481 - use :local: to rewrite maps during production build
diff --git a/releng.wtpbuilder/scripts/build/maptasks.xml b/releng.wtpbuilder/scripts/build/maptasks.xml
index 497e7ef..4882bec 100644
--- a/releng.wtpbuilder/scripts/build/maptasks.xml
+++ b/releng.wtpbuilder/scripts/build/maptasks.xml
@@ -11,15 +11,13 @@
         on your operating system are not, e.g. it will be ${env.Path}
         not ${env.PATH} on Windows
     -->
-    <property
-        environment="env"/>
+    <property environment="env"/>
     <!--
         Let users override standard properties, if desired. If
         directory, file, or some properties do not exist, then standard
         properties will be used.
     -->
-    <property
-        file="${env.LOCAL_BUILD_PROPERTIES_DIR}/${ant.project.name}.properties"/>
+    <property file="${env.LOCAL_BUILD_PROPERTIES_DIR}/${ant.project.name}.properties"/>
     <property
         name="cvsProtocol"
         value="${env.BUILD_CVS_WRITE_PROTOCOL}"/>
@@ -39,10 +37,14 @@
 	
 	This needs more work, or messes up "eclipse source" directive. See 
 	https://bugs.eclipse.org/bugs/show_bug.cgi?id=337621
-	--> 
-    <!--
-    <property name="rewriteMapsLine" value=":local:" />	
-    -->
+	-->
+
+    <property
+        name="rewriteMapsLine"
+        value=":local:"/>
+    <property
+        name="unrewriteMapsLine"
+        value=":pserver:anonymous@dev.eclipse.org:"/>
     <!-- ***  assign repo info -->
     <property
         name="mapCvsRoot"
@@ -55,8 +57,7 @@
         fetchAllMaps, chances are you should just use more specific
         calls to map util in your own code
     -->
-    <target
-        name="fetchAllMaps">
+    <target name="fetchAllMaps">
         <ant
             antfile="${wtp.builder.home}/scripts/build/maptasks.xml"
             target="maputil">
@@ -169,19 +170,15 @@
         </ant>
 
     </target>
-    <target
-        name="maputil">
+    <target name="maputil">
         <!--
             remember, for now, the check out and tagging operations are
             seperate, since may have already been checked out, but not
             tagged
         -->
-        <fail
-            unless="mapcomponent"/>
-        <fail
-            unless="mapTag"/>
-        <antcall
-            target="checkOutMaps">
+        <fail unless="mapcomponent"/>
+        <fail unless="mapTag"/>
+        <antcall target="checkOutMaps">
             <param
                 name="cvsPackage"
                 value="${mapcomponent}"/>
@@ -189,26 +186,22 @@
                 name="versionTagParam"
                 value="${mapTag}"/>
         </antcall>
-        <antcall
-            target="tagMapFiles">
+        <antcall target="tagMapFiles">
             <param
                 name="cvsPackage"
                 value="${mapcomponent}"/>
         </antcall>
-        <antcall
-            target="tagMapFiles">
+        <antcall target="tagMapFiles">
             <param
                 name="cvsPackage"
                 value="${mapcomponent}"/>
         </antcall>
-        <antcall
-            target="rewriteMaps">
+        <antcall target="rewriteMaps">
             <param
                 name="cvsPackage"
                 value="${mapcomponent}"/>
         </antcall>
-        <antcall
-            target="rewriteMapsHttp">
+        <antcall target="rewriteMapsHttp">
             <param
                 name="cvsPackage"
                 value="${mapcomponent}"/>
@@ -234,14 +227,10 @@
             message="versionTagParam: ${versionTagParam}"/>
 
         <!-- if not set, fail. There are no safe assumptions. -->
-        <fail
-            unless="mapCvsRoot"/>
-        <fail
-            unless="cvsPackage"/>
-        <fail
-            unless="versionTagParam"/>
-        <fail
-            unless="buildDirectory"/>
+        <fail unless="mapCvsRoot"/>
+        <fail unless="cvsPackage"/>
+        <fail unless="versionTagParam"/>
+        <fail unless="buildDirectory"/>
         <cvs
             cvsRoot="${mapCvsRoot}"
             package="${cvsPackage}"
@@ -279,28 +268,35 @@
     <target
         name="rewriteMaps"
         if="rewriteMapsLine">
-        <echo
-            message="rewriteMapsLine: ${rewriteMapsLine}"/>
+        <echo message="rewriteMapsLine: ${rewriteMapsLine}"/>
     	<!-- we have to check for existence, since in some builds, such as maintenance, 
     		we check out all maps, but not all maps have been branched. -->
         <available
             property="packageExists"
             file="${buildDirectory}/maps/${cvsPackage}"/>
-        <antcall
-            target="rewritePackage"/>
+        <antcall target="rewritePackage"/>
     </target>
     <target
-        name="rewriteMapsHttp"
-        if="rewriteHttpLines">
-        <echo
-            message="rewriteHttpLines: ${rewriteHttpLines}"/>
+        name="unrewriteMaps"
+        if="unrewriteMapsLine">
+        <echo message="unrewriteMapsLine: ${unrewriteMapsLine}"/>
 	       <!-- we have to check for existence, since in some builds, such as maintenance, 
 	              we check out all maps, but not all maps have been branched. -->
         <available
             property="packageExists"
             file="${buildDirectory}/maps/${cvsPackage}"/>
-        <antcall
-            target="rewritePackageHttp"/>
+        <antcall target="unrewritePackage"/>
+    </target>
+    <target
+        name="rewriteMapsHttp"
+        if="rewriteHttpLines">
+        <echo message="rewriteHttpLines: ${rewriteHttpLines}"/>
+	       <!-- we have to check for existence, since in some builds, such as maintenance, 
+	              we check out all maps, but not all maps have been branched. -->
+        <available
+            property="packageExists"
+            file="${buildDirectory}/maps/${cvsPackage}"/>
+        <antcall target="rewritePackageHttp"/>
     </target>
     <target
         name="rewritePackage"
@@ -309,11 +305,28 @@
             dir="${buildDirectory}/maps/${cvsPackage}"
             token=":pserver:anonymous@dev.eclipse.org:"
             value="${rewriteMapsLine}">
-            <include
-                name="**/*.map"/>
+            <include name="**/*.map"/>
         </replace>
 
     </target>
+
+    <target
+        name="unrewritePackage"
+        if="packageExists">
+        <replace
+            dir="${buildDirectory}/maps/${cvsPackage}"
+            token="${rewriteMapsLine}"
+            value="${unrewriteMapsLine}">
+            <include name="**/*.map"/>
+        </replace>
+       <replace
+           dir="${buildDirectory}/sourceReferences.properties"
+           token="\:local\:"
+           value="${unrewriteMapsLine}">
+           <include name="**/*.map"/>
+       </replace>
+    </target>
+
     <target
         name="rewritePackageHttp"
         if="packageExists">
@@ -321,15 +334,12 @@
             dir="${buildDirectory}/maps/${cvsPackage}"
             token="http://download.eclipse.org/"
             value="${rewriteHttpLines}">
-            <include
-                name="**/*.map"/>
+            <include name="**/*.map"/>
         </replace>
     </target>
 
-    <target
-        name="checktagMaps">
-        <condition
-            property="tagMaps">
+    <target name="checktagMaps">
+        <condition property="tagMaps">
             <equals
                 arg1="${build.donottagmaps}"
                 arg2="false"/>
@@ -338,21 +348,16 @@
             level="info"
             message="tagMaps: ${tagMaps}"/>
     </target>
-    <target
-        name="checkLocal">
-        <condition
-            property="mapsLocal">
-            <available
-                file="${buildDirectory}/maps/${cvsPackage}"/>
+    <target name="checkLocal">
+        <condition property="mapsLocal">
+            <available file="${buildDirectory}/maps/${cvsPackage}"/>
         </condition>
-        <echo
-            message="mapsLocal: ${mapsLocal}"/>
+        <echo message="mapsLocal: ${mapsLocal}"/>
     </target>
     <!-- 
         Default target
     -->
-    <target
-        name="noDefault">
+    <target name="noDefault">
         <echo
             level="error"
             message="You must specify a target when invoking this file"/>