From f1010e22f3919f8db76afe2c5aca38ce0a19a1c5 Mon Sep 17 00:00:00 2001
From: brutzman <brutzman@nps.edu>
Date: Sun, 16 Jun 2019 15:16:48 -0700
Subject: [PATCH] multiple updates over long period of time

---
 build.xml | 160 +++++++++++++++++++++++++++++++++++++++++++-----------
 1 file changed, 128 insertions(+), 32 deletions(-)

diff --git a/build.xml b/build.xml
index 4217c37169..bb2b3ba5e0 100644
--- a/build.xml
+++ b/build.xml
@@ -133,7 +133,7 @@ POSSIBILITY OF SUCH DAMAGE.
     <property name="javadoc.use"             value="true"/><!-- Create class and package usage pages -->
     <property name="javadoc.version"         value="true"/>
 	
-    <property name="pyjnius.path"         location="${x3djsail.dir}/src/python/pyjnius"/>
+    <property name="pyjnius.X3DautoclassPath" location="${x3djsail.dir}/src/python/pyjnius"/>
     
     <!-- https://stackoverflow.com/questions/20970732/jnius-1-1-import-error -->
     <!-- https://pyjnius.readthedocs.io/en/stable/installation.html -->
@@ -561,9 +561,10 @@ Key references:
         <delete dir="stylesheets" quiet="false" includeemptydirs="true" failonerror="false"/>
     </target>
 
-    <target name="clean.archiveSubdirectories" description="clean out duplicates in _archive subdirectories">
-        <echo message="clean/delete backup files for project ${archive.name}"/>
+    <target name="clean.archiveSubdirectories" description="clean out duplicates in archive/ and _archive/ subdirectories">
+        <echo message="clean/delete archive (backup) files for project ${archive.name}"/>
         <delete includeemptydirs="true" verbose="true">
+            <fileset dir="." includes="**/archive/**"/>
             <fileset dir="." includes="**/_archive/**"/>
         </delete>
     </target>
@@ -614,7 +615,7 @@ Key references:
     </target>
 
     <!-- warning!  do not create .x3d file names that end in five or more numeric digits since X3D-Edit uses that as a temporary backup filename -->
-    <target name="clean.duplicates" description="clean out duplicate files autogenerated by X3D-Edit, ending with 6 or more numeric values">
+    <target name="clean.duplicates" description="clean out duplicate files autogenerated by X3D-Edit, ending with 6 or more numeric values" depends="clean.RoundTrip">
         <echo message="clean/delete duplicate files autogenerated by X3D-Edit ending with 6 or more numeric values (*######.x3d)"/>
         <echo message="  including files matching *######.x3d scenes: *.html *.wrl *.x3db *.x3dv *Canonical.xml"/>
         <for param="file.path.name">
@@ -2097,8 +2098,8 @@ ignoreSetupDownloadErrors=true
                     regexp="([^\\]*\\)*([^\n]*)\.x3d"
                     select="\2"/>
                 <echo>Processing ${path.scene}/${filename.prefix}.x3d with xmllint</echo>
-                <exec executable="xmllint">
-                    <arg value="--version"/>	<!-- display the version of the XML library used -->
+                <exec executable="xmllint" vmlauncher="false" timeout="300000"><!-- 5 minute timeout in case process hangs --><!-- vmlauncher switch needed for netbeans invocation -->
+                    <arg value="--version"/><!-- display the version of the XML library used -->
                     <arg value="--valid"/>	<!-- validate the document in addition to std well-formed check -->
                     <arg value="--noout"/>	<!-- don't output the result tree -->
                     <!-- <arg value="- -dtdvalid  http://www.web3d.org/specifications/x3d-4.0.dtd"/>
@@ -2109,7 +2110,7 @@ ignoreSetupDownloadErrors=true
         </for>
     </target>
 
-    <target name="refresh.local" depends="clean.backups,clean.duplicates,commonSetup,processScenes,catalog" description="quick master refresh of all .x3d examples:  processScenes, catalog, zip">
+    <target name="refresh.local" depends="clean.backups,clean.duplicates,clean.RoundTrip,commonSetup,processScenes,catalog" description="quick master refresh of all .x3d examples:  processScenes, catalog, zip">
         <!-- unreliable when network delays occur: validate.DTD -->
         <antcall target="echo.timestamp"/>
         <echo message="${archive.name} refresh.local complete."/>
@@ -2252,7 +2253,7 @@ ignoreSetupDownloadErrors=true
         <echo>processScenes.X3dToHtmlListing complete.</echo>
     </target>
 
-    <target name="processScenes.X3dToX3domXhtml" description="convert each .x3d scene into *X3dom.xhtml version for X3DOM" depends="get.saxon">
+    <target name="processScenes.X3dToX3domXhtml" description="convert each .x3d scene into *X3dom.xhtml version for X3DOM" depends="get.saxon,clean.RoundTrip">
         <for param="file.path.name">
             <path>
                 <fileset refid="x3dScenes"/>
@@ -2315,7 +2316,7 @@ ignoreSetupDownloadErrors=true
         <echo>processScenes.X3dToX3domXhtml complete.</echo>
     </target>
 
-    <target name="processScenes.X3dToX_ITE.html" description="convert each .x3d scene into *X_ITE.html version for X3DOM" depends="get.saxon">
+    <target name="processScenes.X3dToX_ITE.html" description="convert each .x3d scene into *X_ITE.html version for X3DOM" depends="get.saxon,clean.RoundTrip">
         <for param="file.path.name">
             <path>
                 <fileset refid="x3dScenes"/>
@@ -2598,7 +2599,7 @@ ignoreSetupDownloadErrors=true
         <antcall target="processScenes.json"/>
     </target> -->
 
-    <target name="processScenes.json" description="convert each .x3d scene to Javascript Object Notation .json version" depends="get.saxon">
+    <target name="processScenes.json" description="convert each .x3d scene to Javascript Object Notation .json version" depends="get.saxon,clean.RoundTrip">
         <for param="file.path.name">
             <path>
                 <fileset refid="x3dScenes"/>
@@ -2677,7 +2678,7 @@ ignoreSetupDownloadErrors=true
         <echo>processScenes.json complete.</echo>
     </target>
 
-    <target name="processScenes.X3dToX3dvClassicVrmlEncoding" depends="get.saxon">
+    <target name="processScenes.X3dToX3dvClassicVrmlEncoding" depends="get.saxon,clean.RoundTrip">
         <for param="file.path.name">
             <path>
                 <fileset refid="x3dScenes"/>
@@ -2731,7 +2732,7 @@ ignoreSetupDownloadErrors=true
         <echo>processScenes.X3dToX3dvClassicVrmlEncoding complete.</echo>
     </target>
 
-    <target name="processScenes.X3dToX3dbCompressedBinaryEncoding" description="convert each .x3d scene to .x3db Compressed Binary Encoding version">
+    <target name="processScenes.X3dToX3dbCompressedBinaryEncoding" description="convert each .x3d scene to .x3db Compressed Binary Encoding version" depends="clean.RoundTrip">
         <!-- dependency:  see xj3d.dir etc. definitions, perform local Xj3D "build all" -->
         <echo message="processScenes.X3dToX3dbCompressedBinaryEncoding conversion depends on local Xj3D installation, current directory xj3d.dir=${xj3d.dir}"/>
         <for param="file.path.name">
@@ -3370,7 +3371,7 @@ app.replica.args=-mode scene -mipmaps -antialias 8 -anisotropicDegree 16 -verbos
         </concat>
     </target>
 
-    <target name="zip" depends="clean.backups,commonSetup" description="generate .zip distribution">
+    <target name="zip" depends="clean.backups,clean.RoundTrip,commonSetup" description="generate .zip distribution">
         <echo>Building ${zipFileName} distribution</echo>
         <!-- TODO:  figure out
         <if>
@@ -3577,6 +3578,16 @@ app.replica.args=-mode scene -mipmaps -antialias 8 -anisotropicDegree 16 -verbos
         <echo>Building ${zipFileName} (${archive.zip.length} bytes) complete</echo>
     </target>
 
+    <target name="view.javadoc.local" description="view local package javadoc in web browser (Netbeans only)">
+        <nbbrowse file="javadoc/index.html" />
+        <!-- TODO implementation-independent approach if possible.  other Ant approachs have to be customized for each OS -->
+    </target>
+
+    <target name="view.javadoc.online" description="view local package javadoc in web browser (Netbeans only)">
+        <nbbrowse url="http://www.web3d.org/x3d/content/examples/${archive.name}/javadoc" /> <!-- do not follow with /index.html -->
+        <!-- TODO implementation-independent approach if possible.  other Ant approachs have to be customized for each OS -->
+    </target>
+
     <target name="view.examples.local" description="view local examples in web browser (Netbeans only)">
         <nbbrowse file="index.html" />
         <!-- TODO implementation-independent approach if possible.  other Ant approachs have to be customized for each OS -->
@@ -3584,6 +3595,7 @@ app.replica.args=-mode scene -mipmaps -antialias 8 -anisotropicDegree 16 -verbos
 
     <target name="view.examples.online" description="view online examples in web browser (Netbeans only)">
         <nbbrowse url="http://www.web3d.org/x3d/content/examples/${archive.name}" />
+        <!-- TODO implementation-independent approach if possible.  other Ant approachs have to be customized for each OS -->
     </target>
 
     <target  name="clean.X3dTidy">
@@ -3707,7 +3719,20 @@ app.replica.args=-mode scene -mipmaps -antialias 8 -anisotropicDegree 16 -verbos
 							<exclude name="X3dSpecifications/SAIExample*.*"/>
 							<!-- ConformanceNist -->
 							<exclude name="Miscellaneous/Script/**/*"/>
-							<!-- Savage Defense -->
+							<!-- Savage -->
+							<exclude name="services/WebServices/**/*"/>
+							<exclude name="CommunicationsAndSensors/Sonobuoys/rra/**/*"/>
+							<exclude name="CommunicationsAndSensors/Sonobuoys/rra-orig/**/*"/>
+							<exclude name="CommunicationsAndSensors/TSSR/CommPduGenerator.*"/>
+							<exclude name="Scenarios/PiracyIncidents/java/**/*"/>
+							<exclude name="Scenarios/TankManeuver/SRTG.*"/>
+							<exclude name="Tools/Slider/FloatScaler.*"/>
+							<exclude name="Tools/Slider/ScaledSFFloatScript.*"/>
+							<exclude name="Tools/Slider/SingleTypeConversionScript.*"/>
+							<exclude name="Tools/Slider/SliderScript.*"/>
+							<exclude name="Tools/Slider/widget/**/*"/>
+							<exclude name="Tools/Terrain/GeoManager.*"/>
+							<!-- SavageDefense -->
 							<exclude name="qrcode/**/*.*"/>
             </fileset>
 			<!--
@@ -3719,13 +3744,26 @@ app.replica.args=-mode scene -mipmaps -antialias 8 -anisotropicDegree 16 -verbos
         </delete>
     </target>
 
-    <target  name="clean.python">
+    <target  name="clean.python" depends="clean.RoundTrip">
         <echo message="ensuring any prior converted python source files are cleared out..."/>
 		<!-- possible TODO python documentation, if ever added -->
-        <delete verbose="true">
+        <delete verbose="true" failonerror="false">
             <fileset dir=".">
 				<include name="**/*.py"/>
 				<include name="**/*.new.x3d"/>
+				<include name="**/*.newf.x3d"/>
+				<include name="**/*.newFile.x3d"/>
+				<exclude name="_archive/*"/>
+				<exclude name="**/originals/**/*"/>
+            </fileset>
+        </delete>
+    </target>
+
+    <target  name="clean.RoundTrip">
+        <echo message="ensuring any prior converted *RoundTrip*.* source files are cleared out..."/>
+        <delete verbose="true">
+            <fileset dir=".">
+				<include name="**/*RoundTrip*.*"/>
 				<exclude name="_archive/*"/>
 				<exclude name="**/originals/**/*"/>
             </fileset>
@@ -3767,7 +3805,7 @@ app.replica.args=-mode scene -mipmaps -antialias 8 -anisotropicDegree 16 -verbos
                 <echo>$name.short           = ${name.short}</echo>
                 -->
 				<echo message="org.web3d.x3d.jsail.CommandLine ${archive.path}/${relative.path1}/${relative.path2}/${name.short}.x3d -validate"/>
-				<java classname="org.web3d.x3d.jsail.CommandLine" classpath="${x3djsail.stylesheets.dir}//${jsai.full.archive.jar.name};." fork="${fork}">
+				<java classname="org.web3d.x3d.jsail.CommandLine" classpath="${x3djsail.stylesheets.dir}/${jsai.full.archive.jar.name};." fork="${fork}">
 					<arg value="${archive.path}/${relative.path1}/${relative.path2}/${name.short}.x3d"/><!-- input model -->
 					<arg value="-validate"/>
 				</java>
@@ -3778,7 +3816,7 @@ app.replica.args=-mode scene -mipmaps -antialias 8 -anisotropicDegree 16 -verbos
         <echo>processScenes.X3DJSAIL.X3DLoaderDomTests complete.</echo>
     </target>
 
-    <target name="processScenes.java" description="generate java source, .class files, javadoc" depends="">
+    <target name="processScenes.java" description="generate java source, .class files, javadoc" depends="clean.RoundTrip">
 		<mkdir  dir="${java.classes.dir}"/>
         <echo message="Verifying Apache Ant XML Catalog resolver classpath: ${resolver.dir}/resolver.jar (${resolver.jar.length} bytes)"/>
         <for param="file.path.name">
@@ -3887,7 +3925,20 @@ app.replica.args=-mode scene -mipmaps -antialias 8 -anisotropicDegree 16 -verbos
 							<exclude name="X3dSpecifications/SAIExample*.*"/>
 							<!-- ConformanceNist -->
 							<exclude name="Miscellaneous/Script/**/*"/>
-							<!-- Savage Defense -->
+							<!-- Savage -->
+							<exclude name="services/WebServices/**/*"/>
+							<exclude name="CommunicationsAndSensors/Sonobuoys/rra/**/*"/>
+							<exclude name="CommunicationsAndSensors/Sonobuoys/rra-orig/**/*"/>
+							<exclude name="CommunicationsAndSensors/TSSR/CommPduGenerator.*"/>
+							<exclude name="Scenarios/PiracyIncidents/java/**/*"/>
+							<exclude name="Scenarios/TankManeuver/SRTG.*"/>
+							<exclude name="Tools/Slider/FloatScaler.*"/>
+							<exclude name="Tools/Slider/ScaledSFFloatScript.*"/>
+							<exclude name="Tools/Slider/SingleTypeConversionScript.*"/>
+							<exclude name="Tools/Slider/SliderScript.*"/>
+							<exclude name="Tools/Slider/widget/**/*"/>
+							<exclude name="Tools/Terrain/GeoManager.*"/>
+							<!-- SavageDefense -->
 							<exclude name="qrcode/**/*.*"/>
 						</javac>
 						<echo message="now run and validate the java model"/>
@@ -3905,10 +3956,15 @@ app.replica.args=-mode scene -mipmaps -antialias 8 -anisotropicDegree 16 -verbos
 		<!-- <antcall target="processScenes.javadoc"/> -->
     </target>
 
-    <target name="processScenes.python" description="generate python source, run validation test" depends="">
-        <echo message="$pyjnius.path=${pyjnius.path}"/>
+    <target name="processScenes.python" description="generate python source, run validation test" depends="clean.RoundTrip">
+        <echo message="$env.JAVA_HOME=${env.JAVA_HOME}"/>
+		<echo message="$env.CLASSPATH=${env.CLASSPATH}"/>
+		<echo message="$env.ANT_OPTS =${env.ANT_OPTS}"/>
+        <echo message="$pyjnius.X3DautoclassPath =${pyjnius.X3DautoclassPath}"/>
+        <echo message="PYTHONPATH                =${pyjnius.X3DautoclassPath}"/>
         <echo message="$pyjnius.configurationPath=${pyjnius.configurationPath}"/>
 		<echo message="Verifying Apache Ant XML Catalog resolver classpath: ${resolver.dir}/resolver.jar (${resolver.jar.length} bytes)"/>
+		<echo message="====================="/>
         <for param="file.path.name">
             <path>
                 <fileset refid="x3dScenes"/>
@@ -3947,20 +4003,33 @@ app.replica.args=-mode scene -mipmaps -antialias 8 -anisotropicDegree 16 -verbos
                         </filelist>
                     </sourcefiles>
                     <mapper dir="." type="glob" from="*.x3d" to="*.py"/>
+                <!--<mapper dir="." type="glob" from="*.x3d" to="*.future.py"/>-->
                     <sequential>
                         <!-- process individual files here. show full path to facilitate user loading, editing of reported files -->
                         <!-- see stylesheets/java/src/python/pyjnius/build.xml -->
+                        <!--
+						<echo message="validate original source: ${archive.path}/${relative.path1}/${relative.path2}/${name.short}.x3d"/>
+						<java classname="org.web3d.x3d.jsail.CommandLine" classpath="${x3djsail.stylesheets.dir}//${jsai.full.archive.jar.name};." fork="${fork}">
+                            <arg value="-validate"/>
+                            <arg value="${archive.path}/${relative.path1}/${relative.path2}/${name.short}.x3d"/>< ! - - input model - - >
+                        </java>
+                        <echo message="- - - - - - - - - - -"/>
+                        -->
 						<echo message="create python:"/>
 						<echo message="node xml2all.js ${archive.path}/${relative.path1}/${relative.path2}/${name.short}.x3d"/>
-						<exec executable="node" vmlauncher="false"><!-- vmlauncher switch needed for netbeans invocation -->
-							<arg value="${pyjnius.path}/xml2all.js"/>
+						<exec executable="node" vmlauncher="false" timeout="300000"><!-- 5 minute timeout in case process hangs --><!-- vmlauncher switch needed for netbeans invocation -->
+							<arg value="${pyjnius.X3DautoclassPath}/xml2all.js"/>
 							<arg value="${archive.path}/${relative.path1}/${relative.path2}/${name.short}.x3d"/>
 						</exec>
-						<!-- TODO verify result -->
-						<echo>${name.short}.x3d converted to ${name.short}.py</echo>
+                        <move     file="${archive.path}/${relative.path1}/${relative.path2}/${name.short}.py"  failonerror="false" quiet="true" verbose="false"
+                                 todir="${archive.path}/${relative.path1}/${relative.path2}/_archive"/>
+                        <move   file="${archive.path}/${relative.path1}/${relative.path2}/${name.short}.future.py" 
+                              tofile="${archive.path}/${relative.path1}/${relative.path2}/${name.short}.py"    failonerror="false" quiet="true" verbose="true"/>
+						<echo>${name.short}.x3d converted to archive/${name.short}.py (verbose syntax) and ${name.short}.py (pipeline syntax)</echo>
 						
 						<!-- now run python output to validate -->
-						<echo message="test python:"/>
+						<echo message="- - - - - - - - - - -"/>
+						<echo message="validate python:"/>
 						<if>
 							<!-- https://ant.apache.org/manual/Tasks/conditions.html -->
 							<contains string="${name.short}" substring="{name.short}" /><!-- undefined -->
@@ -3968,16 +4037,42 @@ app.replica.args=-mode scene -mipmaps -antialias 8 -anisotropicDegree 16 -verbos
 								<echo message="filename not found"/> <!-- in order to get a filename -->
 							</then>
 							<else>
-								<echo message="Loading and running ${name.short}.py program, if successful then saving as round-trip .x3d version:"/>
 								<!-- https://ant.apache.org/manual-1.9.x/Tasks/exec.html Examples -->
-								<exec executable="python">
-									<!-- https://stackoverflow.com/questions/5607580/how-to-set-the-path-environment-variable-from-ant-script -->
+								<!-- https://stackoverflow.com/questions/5607580/how-to-set-the-path-environment-variable-from-ant-script -->
+								<echo message="Loading archive/${name.short}.py (verbose syntax) with python, if successful then saving as archive/${name.short}_RoundTrip1.x3d version:"/>
+								<exec executable="python"  dir="${pyjnius.X3DautoclassPath}" vmlauncher="false" timeout="300000"><!-- 5 minute timeout in case process hangs -->
+									<env key="Path"       path="${pyjnius.configurationPath}"/>
+									<env key="PYTHONPATH" path="${pyjnius.X3DautoclassPath}"/>
+									<arg value="${archive.path}/${relative.path1}/${relative.path2}/_archive/${name.short}.py"/>
+									<arg value="-v"/><!-- verbose -->
+								</exec>
+                                <move     file="${archive.path}/${relative.path1}/${relative.path2}/${name.short}_RoundTrip.x3d"  quiet="true" failonerror="false" verbose="false"
+                                        tofile="${archive.path}/${relative.path1}/${relative.path2}/_archive/${name.short}_RoundTrip1.x3d"/>
+                                <echo message="Validating archive/${name.short}_RoundTrip1.x3d version:"/>
+								<!-- immutable <length property="RoundTrip1.length" file="${archive.path}/${relative.path1}/${relative.path2}/_archive/${name.short}_RoundTrip1.x3d"/> -->
+                                <java classname="org.web3d.x3d.jsail.CommandLine" classpath="${x3djsail.stylesheets.dir}/${jsai.full.archive.jar.name};." fork="${fork}">
+                                    <arg value="-validate"/>
+                                    <arg value="${archive.path}/${relative.path1}/${relative.path2}/_archive/${name.short}_RoundTrip1.x3d"/><!-- input model -->
+                                </java>
+                                <echo message="archive/${name.short}.py (verbose syntax) RoundTrip load test #1 complete"/>
+                                <echo message="- - - - - -"/>
+								
+                                <echo message="Loading ${name.short}.py (pipeline syntax) with python, if successful then saving and validating as ${name.short}_RoundTrip2.x3d version:"/>
+								<exec executable="python"  dir="${pyjnius.X3DautoclassPath}" vmlauncher="false" timeout="300000"><!-- 5 minute timeout in case process hangs -->
 									<env key="Path"       path="${pyjnius.configurationPath}"/>
-									<env key="PYTHONPATH" path="${pyjnius.path}"/>
+									<env key="PYTHONPATH" path="${pyjnius.X3DautoclassPath}"/>
 									<arg value="${archive.path}/${relative.path1}/${relative.path2}/${name.short}.py"/>
 									<arg value="-v"/><!-- verbose -->
 								</exec>
-								<echo message="====================="/>
+                                
+                                <move     file="${archive.path}/${relative.path1}/${relative.path2}/${name.short}_RoundTrip.x3d" quiet="true" failonerror="false" verbose="false"
+                                        tofile="${archive.path}/${relative.path1}/${relative.path2}/_archive${name.short}_RoundTrip2.x3d"/>
+                                <java classname="org.web3d.x3d.jsail.CommandLine" classpath="${x3djsail.stylesheets.dir}/${jsai.full.archive.jar.name};." fork="${fork}">
+                                    <arg value="-validate"/>
+                                    <arg value="${archive.path}/${relative.path1}/${relative.path2}/_archive${name.short}_RoundTrip2.x3d"/><!-- input model -->
+                                </java>
+                                <echo message="${name.short}.py (pipeline syntax) RoundTrip load test #2 complete"/>
+                                <echo message="====================="/>
 							</else>
 						</if>
                     </sequential>
@@ -3985,8 +4080,9 @@ app.replica.args=-mode scene -mipmaps -antialias 8 -anisotropicDegree 16 -verbos
             </sequential>
         </for>
         <antcall target="echo.timestamp"/>
-        <echo>processScenes.java complete.</echo>
+        <echo>processScenes.python complete.</echo>
 		<!-- <antcall target="processScenes.javadoc"/> -->
+        <echo message="==============================================================="/>
     </target>
 
 	<target name="processScenes.javadoc">
-- 
GitLab