You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by jb...@apache.org on 2010/08/28 21:15:08 UTC

svn commit: r990416 - in /commons/sandbox/gsoc/2010/scxml-js/trunk: getDeps.xml mvn-ant-build.xml pom.xml

Author: jbeard
Date: Sat Aug 28 19:15:08 2010
New Revision: 990416

URL: http://svn.apache.org/viewvc?rev=990416&view=rev
Log:
Updated pom.xml with dependencies. Forked build.xml to create Ant script just for maven to delegate to. The reason for this is that introduction of maven-specific properties introduces a dependency on Maven, which right now would break the Ant build. This can perhaps later be resolved with Maven Ant Tools, but for right now, a fork is preferred.

Added:
    commons/sandbox/gsoc/2010/scxml-js/trunk/mvn-ant-build.xml   (with props)
Modified:
    commons/sandbox/gsoc/2010/scxml-js/trunk/getDeps.xml
    commons/sandbox/gsoc/2010/scxml-js/trunk/pom.xml

Modified: commons/sandbox/gsoc/2010/scxml-js/trunk/getDeps.xml
URL: http://svn.apache.org/viewvc/commons/sandbox/gsoc/2010/scxml-js/trunk/getDeps.xml?rev=990416&r1=990415&r2=990416&view=diff
==============================================================================
--- commons/sandbox/gsoc/2010/scxml-js/trunk/getDeps.xml (original)
+++ commons/sandbox/gsoc/2010/scxml-js/trunk/getDeps.xml Sat Aug 28 19:15:08 2010
@@ -17,7 +17,6 @@
 -->
 <project default="get-deps" name="commons-scxml-js" basedir=".">
 
-
 	<property name="lib-java" value="lib/java"/>
 	<property name="lib-test-java" value="lib/test-java"/>
 	<property name="lib-js" value="lib/js"/>
@@ -30,23 +29,29 @@
 	
 		<mkdir dir="${tmp-dir}"/>
 
+		<!--
 		<get dest="${tmp-dir}/xalan-j_2_7_1-bin.zip" usetimestamp="true" ignoreerrors="true" src="http://mirror.csclub.uwaterloo.ca/apache/xml/xalan-j/binaries/xalan-j_2_7_1-bin.zip"/>
 		<unzip src="${tmp-dir}/xalan-j_2_7_1-bin.zip" dest="${tmp-dir}"/>
 		<move file="${tmp-dir}/xalan-j_2_7_1/serializer.jar" todir="${lib-java}"/>
 		<move file="${tmp-dir}/xalan-j_2_7_1/xalan.jar" todir="${lib-java}"/>
 		<move file="${tmp-dir}/xalan-j_2_7_1/xercesImpl.jar" todir="${lib-java}"/>
 		<move file="${tmp-dir}/xalan-j_2_7_1/xml-apis.jar" todir="${lib-java}"/>
+		-->
 
 		<!--selenium is a bit tricky, as selenium-server in maven repository is old and breaks with FF on WinXP SP3-->
+		<!--
 		<get dest="${tmp-dir}/selenium-remote-control-1.0.3.zip" usetimestamp="true" ignoreerrors="true" src="http://selenium.googlecode.com/files/selenium-remote-control-1.0.3.zip" />
 		<unzip src="${tmp-dir}/selenium-remote-control-1.0.3.zip" dest="${tmp-dir}"/>
 		<copy file="${tmp-dir}/selenium-java-client-driver-1.0.1/selenium-java-client-driver.jar" todir="${lib-test-java}"/>
 		<copy file="${tmp-dir}/selenium-server-1.0.3/selenium-server.jar" todir="${lib-test-java}"/>
+		-->
 
 
+		<!--
 		<get dest="${tmp-dir}/commons-cli-1.2-bin.zip" usetimestamp="true" ignoreerrors="true" src="http://apache.sunsite.ualberta.ca/commons/cli/binaries/commons-cli-1.2-bin.zip" />
 		<unzip src="${tmp-dir}/commons-cli-1.2-bin.zip" dest="${tmp-dir}"/>
 		<copy file="${tmp-dir}/commons-cli-1.2/commons-cli-1.2.jar" tofile="${lib-java}/commons-cli.jar"/>
+		-->
 
 		<get dest="${tmp-dir}/requirejs-0.11.0.zip" usetimestamp="true" ignoreerrors="true" src="http://requirejs.org/docs/release/0.11.0/requirejs-0.11.0.zip"/>
 		<unzip src="${tmp-dir}/requirejs-0.11.0.zip" dest="${lib-js}"/>
@@ -78,9 +83,11 @@
 		<unzip src="${tmp-dir}/jquery.svg.package-1.4.3.zip" dest="${drawing-tool-lib}"/>
 
 		<!-- we use rhino release candidate, rather than stable release because it has built-in support for Array.reduce, among other things -->
+		<!--
 		<get dest="${tmp-dir}/rhino1_7R3pre.zip" usetimestamp="true" ignoreerrors="true" src="ftp://ftp.mozilla.org/pub/mozilla.org/js/rhino1_7R3pre.zip"/>
 		<unzip src="${tmp-dir}/rhino1_7R3pre.zip" dest="${tmp-dir}"/>
 		<copy file="${tmp-dir}/rhino1_7R3pre/js.jar" tofile="${lib-java}/js.jar"/>
+		-->
 
 		<delete dir="${tmp-dir}"/>
 		

Added: commons/sandbox/gsoc/2010/scxml-js/trunk/mvn-ant-build.xml
URL: http://svn.apache.org/viewvc/commons/sandbox/gsoc/2010/scxml-js/trunk/mvn-ant-build.xml?rev=990416&view=auto
==============================================================================
--- commons/sandbox/gsoc/2010/scxml-js/trunk/mvn-ant-build.xml (added)
+++ commons/sandbox/gsoc/2010/scxml-js/trunk/mvn-ant-build.xml Sat Aug 28 19:15:08 2010
@@ -0,0 +1,914 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+-->
+<project name="scxml-js" basedir="." default="run-all-unit-tests">
+
+	<path location="${compile_classpath}" id="maven.compile.classpath"/>
+	<path location="${runtime_classpath}" id="maven.runtime.classpath"/>
+	<path location="${test_classpath}" id="maven.test.classpath"/>
+	<path location="${plugin_classpath}" id="maven.plugin.classpath"/>
+
+	<taskdef resource="net/sf/antcontrib/antcontrib.properties">
+		<classpath>
+			<path refid="maven.plugin.classpath" />
+		</classpath>
+	</taskdef>
+
+	<!-- location properties -->
+	<property name="src" value="src"/>
+
+	<property name="lib" location="lib"/>
+	<property name="lib-java" location="${lib}/java"/>
+	<property name="lib-js" location="${lib}/js"/>
+	<property name="lib-test-java" location="${lib}/test-java"/>
+	<property name="lib-test-js" location="${lib}/test-js"/>
+
+	<property name="build" value="target"/>
+	<property name="build-js" location="${build}/build-js"/>
+	<property name="build-class" location="${build}/classes"/>
+	<property name="build-jar" location="${build}/jar"/>
+
+
+	<property name="ie_browser_name" value="ie"/>
+
+	<property name="is_for_ie" value="is-for-ie"/>
+	<property name="is_not_for_ie" value="is-not-for-ie"/>
+
+	<property name="backends" value="switch,table,state"/>
+	<!--
+	<property name="backends" value="switch"/>
+	-->
+	<property name="browsers" value="firefox,chrome"/>
+	<!--
+	<property name="browsers" value="firefox,${ie_browser_name},chrome"/>
+	-->
+	<property name="for-ie" value="${is_for_ie},${is_not_for_ie}"/>
+
+	<!-- selenium configuration options -->
+	<property name="selenium_host" value="localhost"/>
+	<property name="selenium_port" value="4444"/>
+	<property name="selenium_root_url" value="http://localhost:8081/"/>
+	<property name="selenium_timeout" value="20000"/>
+
+	<property name="selenium_firefox_id" value="*firefox"/>
+	<property name="selenium_ie_id" value="*iexplore"/>
+	<property name="selenium_chrome_id" value="*googlechrome"/>
+	<property name="selenium_safari_id" value="*safari"/>
+
+	<!-- classpath configuration stuff -->
+	<path id="rhino-classpath" location="${lib-java}/js.jar"/>
+	<path id="closure-classpath" location="${lib-js}/requirejs/build/lib/closure/compiler.jar"/>
+
+	<path id="requirejs_bootstrap_paths">
+		<pathelement location="${lib-js}/requirejs/require.js"/> 
+		<pathelement location="${lib-js}/requirejs/require/rhino.js"/> 
+		<pathelement location="${lib-js}/requirejs/require/text.js"/> 
+		<pathelement location="${lib-js}/requirejs/require/xml.js"/> 
+	</path>
+
+	<property name="path_to_dojo_base" location="${lib-test-js}/dojo-release-1.4.2-src/dojo"/>
+	<property name="path_to_dojo" value="${path_to_dojo_base}/dojo.js"/>
+
+	<fileset id="stylesheets-to-preprocess" dir="${src}/xslt/backends/js">
+		<include name="StatePatternStatechartGenerator.xsl"/>
+		<include name="StateTableStatechartGenerator.xsl"/>
+		<include name="SwitchyardStatechartGenerator.xsl"/>
+	</fileset>
+
+	<path id="scxml_tests_xml">
+		<pathelement location="test/kitchen_sink/KitchenSink.xml"/>
+		<!--
+		<pathelement location="test/kitchen_sink/KitchenSink_dataModule.xml"/>
+		<pathelement location="test/kitchen_sink/KitchenSink_performance.xml"/>
+		<pathelement location="test/kitchen_sink/KitchenSink_executableContent.xml"/>
+		-->
+		<pathelement location="test/conditional_transition/TestConditionalTransition.xml"/>
+		<!--
+		<pathelement location="test/in_predicate/TestInPredicate.xml"/>
+		<pathelement location="test/event_system_properties/TestEventSystemProperties.xml"/>
+		<pathelement location="test/prefix_events/TestPrefixEvents.xml"/>
+		<pathelement location="test/parallel/TestParallel.xml"/>
+		-->
+	</path>
+
+	<target name="clean">
+		<delete dir="${build}"/>
+	</target>
+	
+	<target name="init">
+		<mkdir dir="${build}"/>
+	</target>
+
+	<macrodef name="rhinoscript">
+		<text name="text"/>
+
+		<sequential>
+			<!-- TODO: update classpath here -->
+			<script language="javascript" manager="bsf">
+				<classpath>
+					<path refid="rhino-classpath"/>
+					<path refid="maven.plugin.classpath"/>
+				</classpath><![CDATA[
+					var shell = org.mozilla.javascript.tools.shell.Main;
+					var args = ["-e","var a='STRING';"];
+					shell.exec(args);
+
+					var shellGlobal = shell.global;
+
+					//grab functions from shell global and place in current global
+					var load=shellGlobal.load;
+					var print=shellGlobal.print;
+					var defineClass=shellGlobal.defineClass;
+					var deserialize=shellGlobal.deserialize;
+					var doctest=shellGlobal.doctest;
+					var gc=shellGlobal.gc;
+					var help=shellGlobal.help;
+					var loadClass=shellGlobal.loadClass;
+					var quit=shellGlobal.quit;
+					var readFile=shellGlobal.readFile;
+					var readUrl=shellGlobal.readUrl;
+					var runCommand=shellGlobal.runCommand;
+					var seal=shellGlobal.seal;
+					var serialize=shellGlobal.serialize;
+					var spawn=shellGlobal.spawn;
+					var sync=shellGlobal.sync;
+					var toint32=shellGlobal.toint32;
+					var version=shellGlobal.version;
+					var environment=shellGlobal.environment;
+
+					var console ={
+						log : print,
+						debug : print
+					}
+	
+					@{text}
+			]]></script>
+		</sequential>
+	</macrodef>
+
+	<macrodef name="compile-with-scxml-js-ie">
+		<attribute name="backend"/>
+		<attribute name="test-path"/>
+		<attribute name="out-path"/>
+
+		<sequential>
+			<echo>Compiling @{test-path} to @{out-path} with backend @{backend} and flags for IE...</echo>
+
+			<java classname="org.mozilla.javascript.tools.shell.Main" output="@{out-path}">
+				<classpath>
+					<path refid="rhino-classpath"/>
+					<path refid="maven.compile.classpath"/>
+				</classpath>
+
+				<arg value="${basedir}/runner.js"/>
+				<arg value="${basedir}"/>
+				<arg value="src/javascript/scxml/cgf/main"/>
+				
+				<arg value="--backend=@{backend}"/>
+				<arg value="--beautify"/>
+				<arg value="--ie"/>
+				<arg value="@{test-path}"/>
+			</java>
+		</sequential>
+	</macrodef>
+
+	<macrodef name="compile-with-scxml-js-no-ie">
+		<attribute name="backend"/>
+		<attribute name="test-path"/>
+		<attribute name="out-path"/>
+
+		<sequential>
+			<echo>Compiling @{test-path} to @{out-path} with backend @{backend}...</echo>
+
+			<java classname="org.mozilla.javascript.tools.shell.Main" output="@{out-path}">
+				<classpath>
+					<path refid="rhino-classpath"/>
+					<path refid="maven.compile.classpath"/>
+				</classpath>
+
+				<arg value="${basedir}/runner.js"/>
+				<arg value="${basedir}"/>
+				<arg value="src/javascript/scxml/cgf/main"/>
+				
+				<arg value="--backend=@{backend}"/>
+				<arg value="--beautify"/>
+				<arg value="@{test-path}"/>
+			</java>
+		</sequential>
+	</macrodef>
+
+	<macrodef name="generate-unit-test-html-template">
+		<attribute name="generatedJsCodeRelativePath"/>
+		<attribute name="testScriptModulePath"/>
+		<attribute name="out-path"/>
+
+		<sequential>
+			<echo file="@{out-path}"><![CDATA[
+				<html>
+					<head>
+						<script src="../../../../lib/js/requirejs/require.js" type="text/javascript">true;</script>
+						<script type="text/javascript" src="../../../../lib/test-js/dojo-release-1.4.2-src/dojo/dojo.js" djConfig="isDebug:true">true;</script>
+						<script type="text/javascript">
+							dojo.require("doh.runner");
+							window.dohIsComplete = false;
+							window.oldDohOnEnd = window.doh._onEnd;
+							window.doh._onEnd = function() { window.dohIsComplete = true; window.oldDohOnEnd.apply(window.doh); };
+						</script>
+						<script type="text/javascript" src="../../../../test/testHelpers.js">true;</script>
+						<script type="text/javascript" src="@{generatedJsCodeRelativePath}">true;</script>
+						<script type="text/javascript">
+							require(
+								{ baseUrl : "/" },
+								["@{testScriptModulePath}"],
+								function(unitTestModule){ 
+									unitTestModule.register(StatechartExecutionContext);
+
+									dojo.require("doh.runner");
+									doh.run();
+								});
+						</script>
+					</head>
+					<body>
+						<h1>Test</h1>
+					</body>
+				</html>
+			]]></echo>
+		</sequential>
+
+	</macrodef>
+
+	<macrodef name="generate-in-browser-unit-test-html-template">
+		<attribute name="testScriptModulePath"/>
+		<attribute name="out-path"/>
+		<attribute name="modulePathToXMLTest"/>
+		<attribute name="backendName"/>
+		<attribute name="is-ie"/>
+
+		<sequential>
+
+			<!-- map @{is-ie} to boolean values that generated js understands -->
+			<if>
+				<equals arg1="@{is-ie}" arg2="${is_for_ie}"/>
+				<then>
+					<property name="@{testScriptModulePath}-@{out-path}-@{modulePathToXMLTest}-@{backendName}-@{is-ie}" value="true"/>
+				</then>
+				<else>
+					<property name="@{testScriptModulePath}-@{out-path}-@{modulePathToXMLTest}-@{backendName}-@{is-ie}" value="false"/>
+				</else>
+			</if>
+
+			<echo file="@{out-path}"><![CDATA[
+				<html>
+				<head>
+					<script src="../../../../lib/js/requirejs/require.js" type="text/javascript">true;</script>
+					<script src="../../../../lib/js/requirejs/require/xml.js" type="text/javascript">true;</script>
+					<script src="../../../../lib/js/requirejs/require/text.js" type="text/javascript">true;</script>
+					<script djConfig="isDebug:true" src="../../../../lib/test-js/dojo-release-1.4.2-src/dojo/dojo.js" type="text/javascript">true;</script>
+					<script type="text/javascript">
+						dojo.require("doh.runner");
+						window.dohIsComplete = false;
+						window.oldDohOnEnd = window.doh._onEnd;
+						window.doh._onEnd = function() { window.dohIsComplete = true; window.oldDohOnEnd.apply(window.doh); };
+					</script>
+					<script src="../../../../test/testHelpers.js" type="text/javascript">true;</script>
+					<script>
+						var resultText;
+
+						require(
+							{
+								"baseUrl":"/"
+							},
+							[ "src/javascript/scxml/cgf/SCXMLCompiler",
+								"xml!@{modulePathToXMLTest}",
+								"@{testScriptModulePath}"],
+
+							function(compiler,documentToCompile,testScriptModule){
+								require( [window.DOMParser ?
+										"src/javascript/scxml/cgf/util/xsl/browser" :
+										"src/javascript/scxml/cgf/util/xsl/ie"],
+									function(transform){
+
+									var compileLog = true;
+
+									compiler.compile({
+										inFiles:[documentToCompile],
+										backend:"@{backendName}",
+										beautify:true,
+										verbose:false,
+										log:compileLog,
+										ie:${@{testScriptModulePath}-@{out-path}-@{modulePathToXMLTest}-@{backendName}-@{is-ie}}
+									}, function(scArr){
+										var transformedJs = scArr[0];
+
+										console.log(transformedJs);
+
+										//eval
+										eval(transformedJs);
+
+										testScriptModule.register(StatechartExecutionContext);
+
+										dojo.require("doh.runner"); 
+										doh.run();
+									},transform);
+								});
+							});
+
+					</script>
+				</head>
+				<body>
+				</body>
+				</html>			
+			]]></echo>
+		</sequential>
+
+	</macrodef>
+	
+	<macrodef name="run-unit-tests-with-selenium-macro">
+		<attribute name="unit-tests-html-property-name"/>
+			
+		<sequential>
+			<rhinoscript><![CDATA[
+				//TODO: consolidate this code
+				function unitTestWithSelenium(sel,url,timeout){
+					sel.open(url);
+
+					sel.waitForPageToLoad("5000");
+					
+					// wait for all the tests to finish
+					sel.waitForCondition("window.dohIsComplete", timeout );
+					
+					// get the results
+					var testCount = Number(sel.getEval("window.doh._testCount"));
+					var failCount = Number(sel.getEval("window.doh._failureCount"));
+					var errorCount = Number(sel.getEval("window.doh._errorCount"));
+					
+					return {
+						testCount:testCount,
+						failCount:failCount,
+						errorCount:errorCount,
+						testsPassed:(testCount - failCount - errorCount)
+					};
+				}
+
+				print("Running Selenium unit tests...");
+
+				var unitTestResults = [];
+
+				browsers.split(",").forEach(function(browserName){
+
+					print("Running test for " + browserName + "...");
+
+					var browserId = project.getProperty("selenium_" + browserName + "_id");
+
+					var bSel = new Packages.com.thoughtworks.selenium.DefaultSelenium(selenium_host, selenium_port, browserId, selenium_root_url);
+
+					print("bSel",bSel);
+
+					bSel.start();
+
+					//list comprehension to get the cartesian product
+					var configurations = [{forIE:forIE,backend:backend,testPath:testPath}
+						for each (forIE in project.getProperty("for-ie").split(','))
+						for each (backend in backends.split(','))
+						for each (testPath in Array.prototype.slice.call(scxml_tests_xml.list()))];
+
+					//use pattern matching in the parameter
+					configurations.forEach(function({forIE:forIE,backend:backend,testPath:testPath}){
+			
+						print("forIE:"+forIE+","+"backend:"+backend+","+"testPath:"+testPath);
+
+						//get path to html test
+						//@{for-ie}-@{backend}-@{test-path}-unit-test-html-location
+						var unitTestHtmlLocationPropertyName=forIE + "-" + backend + "-" + testPath + "-@{unit-tests-html-property-name}";
+						var unitTestHtmlLocation = project.getProperty(unitTestHtmlLocationPropertyName);
+
+						print("unitTestHtmlLocation:"+unitTestHtmlLocation);
+						
+						//ensure we are not testing an ie html test
+						//on a non-ie browser
+						if(browserName==ie_browser_name && forIE==is_for_ie ||
+							browserName!=ie_browser_name && forIE==is_not_for_ie){
+
+							var unitTestResult = unitTestWithSelenium(bSel,unitTestHtmlLocation,selenium_timeout); 
+
+							print("unitTestResult:" + unitTestResult); 
+
+							var unitTestResultObj = {
+								data : unitTestResult,
+								browser : browserName,
+								scxmlTest : testPath,
+								backend : backend
+							};
+
+							unitTestResults.push(unitTestResultObj);
+
+							//report errors and failures that may occur
+							if(unitTestResult.failCount || unitTestResult.errorCount){
+								print("UNIT TEST ERROR");
+								//TODO: add better error handling here that integrates with Ant
+							}
+
+						}
+					});
+
+					bSel.stop();
+				});
+
+				var totalTests = unitTestResults.reduce(function(a,b){return a + b.data.testCount},0);
+				var totalTestsFailed = unitTestResults.reduce(function(a,b){return a + b.data.errorCount},0);
+				var totalTestsErrored = unitTestResults.reduce(function(a,b){return a + b.data.failCount},0);
+				var totalTestsPassed = unitTestResults.reduce(function(a,b){return a + b.data.testsPassed},0);
+
+				print("Test Results:");
+				print("Total Tests: " + totalTests);
+				print("Total Tests Failed: " + totalTestsFailed);
+				print("Total Tests Errored: " + totalTestsErrored);
+				print("Total Tests Passed: " + totalTestsPassed);
+			]]></rhinoscript>
+		</sequential>
+	</macrodef>
+
+	<target name="preprocess-stylesheets" depends="init">
+		<xslt 
+			classpathref="maven.compile.classpath" 
+			style="${src}/xslt/util/preprocess_import.xsl" 
+			destdir="${build}"
+			scanincludeddirectories="false"
+			useImplicitFileset="false">
+
+			<fileset refid="stylesheets-to-preprocess"/>
+
+			<mapper>
+				<chainedmapper>
+					<flattenmapper/>
+					<globmapper from="*.xsl" to="*_combined.xsl"/>
+				</chainedmapper>
+			</mapper>
+		</xslt>
+	</target>
+
+	<target name="setup-properties">
+
+		<for param="test-path">
+			<path refid="scxml_tests_xml"/>
+			<sequential>
+				<!-- for generate-unit-tests-html task -->
+
+				<!-- compute unit test module location -->
+				<!-- to simplify, we expect it to be in a particular location -->
+
+				<dirname property="@{test-path}-dir" file="@{test-path}"/>
+
+				<!-- convert to relative path -->
+				<!-- remove basedir, then remove first slash if there is one, then do other manipulations -->
+				<pathconvert property="@{test-path}-unit-test-js-module">
+					<path location="${@{test-path}-dir}"/>
+					<chainedmapper>
+						<globmapper from="${basedir}*" to="*"/>
+						<scriptmapper language="javascript">
+							self.addMappedName(source[0] == project.getProperty("file.separator") ? 
+										source.slice(1):
+										source);
+						</scriptmapper>
+						<scriptmapper language="javascript">
+							self.addMappedName(source.replace("\\","/","g"));
+						</scriptmapper>
+						<globmapper from="*" to="*/scripts/unitTest"/>
+					</chainedmapper>
+				</pathconvert>
+
+				
+				<!-- these properties are for generate-in-browser-unit-test-html -->
+
+				<!-- module path to the xml -->
+				<pathconvert property="@{test-path}-unit-test-xml-module">
+					<path location="@{test-path}"/>
+					<chainedmapper>
+						<globmapper from="${basedir}*" to="*"/>
+						<scriptmapper language="javascript">
+							self.addMappedName(source[0] == project.getProperty("file.separator") ? 
+										source.slice(1):
+										source);
+						</scriptmapper>
+						<scriptmapper language="javascript">
+							self.addMappedName(source.replace("\\","/","g"));
+						</scriptmapper>
+					</chainedmapper>
+				</pathconvert>
+
+				<!--
+				<echo>@{test-path}-unit-test-xml-module</echo>
+				<echo>${@{test-path}-unit-test-xml-module}</echo>
+				-->
+
+			</sequential>
+		</for>
+
+
+		<for list="${for-ie}" param="for-ie">
+			<sequential>
+				<for list="${backends}" param="backend">
+					<sequential>
+						<for param="test-path">
+							<path refid="scxml_tests_xml"/>
+							<sequential>
+
+								<!-- for generate-javascript task -->
+
+								<!-- do some manipulation -->
+								<pathconvert property="@{for-ie}-@{backend}-@{test-path}-target-test-path">
+									<path path="@{test-path}"/>
+									<chainedmapper>
+									  <flattenmapper/>
+									  <globmapper from="*.xml" to="${build}${file.separator}generate-javascript${file.separator}@{for-ie}${file.separator}@{backend}${file.separator}*.js" handledirsep="true"/>
+									</chainedmapper>
+								</pathconvert>
+
+								<echo>@{for-ie}-@{backend}-@{test-path}-target-test-path</echo>
+								<echo>${@{for-ie}-@{backend}-@{test-path}-target-test-path}</echo>
+
+								<dirname property="@{for-ie}-@{backend}-@{test-path}-target-test-path-dir" file="${@{for-ie}-@{backend}-@{test-path}-target-test-path}"/>
+
+								<!-- for generate-unit-tests-html task -->
+
+								<!-- compute unit test html target location -->
+								<pathconvert property="@{for-ie}-@{backend}-@{test-path}-unit-test-html-location">
+									<path location="${@{for-ie}-@{backend}-@{test-path}-target-test-path}"/>
+									<chainedmapper>
+										<globmapper from="${basedir}*" to="*"/>
+										<scriptmapper language="javascript">
+											self.addMappedName(source[0] == project.getProperty("file.separator") ? 
+														source.slice(1):
+														source);
+										</scriptmapper>
+										<scriptmapper language="javascript">
+											self.addMappedName(source.replace("\\","/","g"));
+										</scriptmapper>
+										<globmapper from="${build}/generate-javascript/*.js" to="${build}/generate-unit-tests-html/*.html" handledirsep="true"/>
+									</chainedmapper>
+								</pathconvert>
+
+								<echo>@{for-ie}-@{backend}-@{test-path}-unit-test-html-location</echo>
+								<echo>${@{for-ie}-@{backend}-@{test-path}-unit-test-html-location}</echo>
+
+								<!-- compute relative path to js from html unit test folder -->
+								<pathconvert property="@{for-ie}-@{backend}-@{test-path}-target-test-relative-path">
+									<path location="${@{for-ie}-@{backend}-@{test-path}-target-test-path}"/>
+									<chainedmapper>
+										<globmapper from="${basedir}*" to="*"/>
+										<scriptmapper language="javascript">
+											self.addMappedName(source[0] == project.getProperty("file.separator") ? 
+														source.slice(1):
+														source);
+										</scriptmapper>
+										<scriptmapper language="javascript">
+											self.addMappedName(source.replace("\\","/","g"));
+										</scriptmapper>
+										<globmapper from="${build}/*" to="../../../*" handledirsep="true"/>
+									</chainedmapper>
+								</pathconvert>
+								
+								<!--
+								<echo>@{for-ie}-@{backend}-@{test-path}-target-test-relative-path</echo>
+								<echo>${@{for-ie}-@{backend}-@{test-path}-target-test-relative-path}</echo>
+								-->
+
+								<!-- get the dirname of the html target so we can make the directory structure -->
+								<dirname property="@{for-ie}-@{backend}-@{test-path}-unit-test-html-target-dir" file="${@{for-ie}-@{backend}-@{test-path}-unit-test-html-location}"/>
+
+
+								<!-- these properties are for generate-in-browser-unit-test-html -->
+								<pathconvert property="@{for-ie}-@{backend}-@{test-path}-in-browser-unit-test-html-location">
+									<path location="${@{for-ie}-@{backend}-@{test-path}-target-test-path}"/>
+									<chainedmapper>
+										<globmapper from="${basedir}*" to="*"/>
+										<scriptmapper language="javascript">
+											self.addMappedName(source[0] == project.getProperty("file.separator") ? 
+														source.slice(1):
+														source);
+										</scriptmapper>
+										<scriptmapper language="javascript">
+											self.addMappedName(source.replace("\\","/","g"));
+										</scriptmapper>
+										<globmapper from="${build}/generate-javascript/*.js" to="${build}/generate-in-browser-unit-tests-html/*.html" handledirsep="true"/>
+									</chainedmapper>
+								</pathconvert>
+
+								<dirname property="@{for-ie}-@{backend}-@{test-path}-in-browser-unit-test-html-target-dir" file="${@{for-ie}-@{backend}-@{test-path}-in-browser-unit-test-html-location}"/>
+
+								<!--
+								<echo>@{for-ie}-@{backend}-@{test-path}-in-browser-unit-test-html-location</echo>
+								<echo>${@{for-ie}-@{backend}-@{test-path}-in-browser-unit-test-html-location}</echo>
+								-->
+
+							</sequential>
+						</for>
+					</sequential>
+				</for>
+			</sequential>
+		</for>
+
+	</target>
+
+	<!-- run unit and performance tests -->
+	<target name="generate-javascript" depends="preprocess-stylesheets,setup-properties">
+		<mkdir dir="${build}/generate-javascript"/>
+	
+		<for list="${for-ie}" param="for-ie">
+			<sequential>
+				<for list="${backends}" param="backend">
+					<sequential>
+						<for param="test-path">
+							<path refid="scxml_tests_xml"/>
+							<sequential>
+
+								<echo>${@{for-ie}-@{backend}-@{test-path}-target-test-path}, ${@{for-ie}-@{backend}-@{test-path}-target-test-path-dir}</echo> 
+
+								<mkdir dir="${@{for-ie}-@{backend}-@{test-path}-target-test-path-dir}"/>
+								
+								<if>
+									<equals arg1="@{for-ie}" arg2="is-for-ie"/>
+									<then>
+										<compile-with-scxml-js-ie
+											test-path="@{test-path}"
+											backend="@{backend}"
+											out-path="${@{for-ie}-@{backend}-@{test-path}-target-test-path}"/>
+									</then>
+									<else>
+										<compile-with-scxml-js-no-ie
+											test-path="@{test-path}"
+											backend="@{backend}"
+											out-path="${@{for-ie}-@{backend}-@{test-path}-target-test-path}"/>
+									</else>
+								</if>
+							</sequential>
+						</for>
+					</sequential>
+				</for>
+			</sequential>
+		</for>
+	</target>
+
+	<target name="generate-unit-test-html" depends="setup-properties">
+		<mkdir dir="${build}/generate-unit-tests-html"/>
+
+		<for list="${for-ie}" param="for-ie">
+			<sequential>
+				<for list="${backends}" param="backend">
+					<sequential>
+						<for param="test-path">
+							<path refid="scxml_tests_xml"/>
+							<sequential>
+
+								<echo>${@{test-path}-unit-test-js-module},${@{for-ie}-@{backend}-@{test-path}-unit-test-html-location},${@{for-ie}-@{backend}-@{test-path}-unit-test-html-target-dir},${@{for-ie}-@{backend}-@{test-path}-target-test-relative-path}</echo> 
+
+								<!-- execute some tasks -->
+								<mkdir dir="${@{for-ie}-@{backend}-@{test-path}-unit-test-html-target-dir}"/>
+
+								<generate-unit-test-html-template
+									generatedJsCodeRelativePath="${@{for-ie}-@{backend}-@{test-path}-target-test-relative-path}"
+									testScriptModulePath="${@{test-path}-unit-test-js-module}"
+									out-path="${@{for-ie}-@{backend}-@{test-path}-unit-test-html-location}"/>
+							</sequential>
+						</for>
+					</sequential>
+				</for>
+			</sequential>
+		</for>
+	</target>
+
+
+	<target name="generate-in-browser-unit-test-html" depends="setup-properties">
+		<mkdir dir="${build}/generate-in-browser-unit-tests-html"/>
+
+		<for list="${for-ie}" param="for-ie">
+			<sequential>
+				<for list="${backends}" param="backend">
+					<sequential>
+						<for param="test-path">
+							<path refid="scxml_tests_xml"/>
+							<sequential>
+
+								<!-- execute some tasks -->
+								<mkdir dir="${@{for-ie}-@{backend}-@{test-path}-in-browser-unit-test-html-target-dir}"/>
+
+								<generate-in-browser-unit-test-html-template
+									testScriptModulePath="${@{test-path}-unit-test-js-module}"
+									out-path="${@{for-ie}-@{backend}-@{test-path}-in-browser-unit-test-html-location}"
+									backendName="@{backend}" 
+									is-ie="@{for-ie}" 
+									modulePathToXMLTest="${@{test-path}-unit-test-xml-module}" />
+							</sequential>
+						</for>
+					</sequential>
+				</for>
+			</sequential>
+		</for>
+	</target>
+
+	<target name="run-unit-tests-with-selenium" depends="generate-unit-test-html,generate-javascript">
+		<run-unit-tests-with-selenium-macro 
+			unit-tests-html-property-name="unit-test-html-location"/>
+	</target>
+
+
+	<target name="run-in-browser-unit-tests-with-selenium" depends="preprocess-stylesheets,generate-in-browser-unit-test-html">
+		<run-unit-tests-with-selenium-macro 
+			unit-tests-html-property-name="in-browser-unit-test-html-location"/>
+	</target>
+
+	<target name="run-unit-tests-with-rhino" depends="generate-javascript">
+		<rhinoscript><![CDATA[
+			//load requirejs
+			Array.prototype.slice.call(requirejs_bootstrap_paths.list()).forEach(function(requireJsPath){
+				load(requireJsPath);
+			});
+
+
+			//this is a bit weird, but we define this here in case we need to load dojo later using the RequireJS loader
+			djConfig = {
+				"baseUrl" : path_to_dojo_base+"/"
+			}
+
+			function tailRecurse(list,stepCallback,baseCaseCallback){
+				var target = list.pop();
+				
+				if(target){
+					stepCallback(target, 
+						function(){tailRecurse(list,stepCallback,baseCaseCallback)});
+				}else{
+					if(baseCaseCallback) baseCaseCallback();
+				}
+			}
+
+			var isComplete = false;
+
+			require(
+				{baseUrl:basedir},
+				[path_to_dojo, 
+					"lib/test-js/env.js",
+					"test/testHelpers.js"],
+				function(){
+
+					dojo.require("doh.runner");	
+
+					var forIE = "is-for-ie";
+					var scxmlXmlTestPathList = Array.prototype.slice.call(scxml_tests_xml.list());
+					var backendsList = backends.split(",");
+
+					var oldDohOnEnd = doh._onEnd;
+					doh._onEnd = function() { isComplete = true; oldDohOnEnd.apply(doh); };
+
+					//we use tailRecurse function because of asynchronous RequireJS call used to load the unit test module
+					tailRecurse(scxmlXmlTestPathList,
+						function(scxmlXmlTestPath,step){
+							var jsUnitTestPathPropertyName = scxmlXmlTestPath + "-" + "unit-test-js-module";
+							var jsUnitTestPath = project.getProperty(jsUnitTestPathPropertyName);
+
+							require([jsUnitTestPath],
+								function(unitTestModule){
+
+									var jsUnitTestPathPropertyNames = 
+										[{forIE:forIE, backend:backend,test_path:scxmlXmlTestPath}
+											for each (backend in backendsList)];
+
+									jsUnitTestPathPropertyNames.forEach(function(target){
+
+										var jsTargetTestPathPropertyName =  
+											target.forIE + "-" + target.backend + "-" + target.test_path + "-" + "target-test-path";
+										var jsTargetTestPath = project.getProperty(jsTargetTestPathPropertyName);
+
+										//load and register
+										load(jsTargetTestPath);
+
+										unitTestModule.register(StatechartExecutionContext)
+										delete StatechartExecutionContext;
+									}) 
+
+									step();
+								});
+						},
+						function(){
+							//run with dojo
+							doh.run();
+						}
+					);
+
+				}
+			);
+
+			//hold up execution until doh completes
+			while(!isComplete){
+				java.lang.Thread.sleep(20);
+			}
+
+		]]></rhinoscript>
+	</target>
+
+	<target name="run-all-unit-tests" 
+		depends="run-unit-tests-with-selenium,run-in-browser-unit-tests-with-selenium,run-unit-tests-with-rhino" />
+
+
+	<!-- build standalone executable -->
+
+	<property name="build-js-main" location="${build-js}/main-built.js"/>
+	<property name="build-class-main-name" value="SCXMLCompiler"/>
+	<property name="build-class-main" location="${build-class}/${build-class-main-name}.class"/>
+	<property name="build-jar-main" location="${build-jar}/scxml-js.jar"/>
+
+	<property name="build-js-main-rhino-frontend-module" value="${src}/javascript/scxml/cgf/build/rhino"/>
+
+	<property name="js-build-script" location="${lib-js}/requirejs/build/build.js"/>
+	<property name="js-build-dir" location="${lib-js}/requirejs/build"/>
+
+	<property name="test" location="test"/>
+
+	<target name="compile-single-js" depends="preprocess-stylesheets">
+		<mkdir dir="${build-js}"/>
+
+		<java classname="org.mozilla.javascript.tools.shell.Main">
+			<classpath>
+				<path refid="rhino-classpath"/>
+				<path refid="closure-classpath"/>
+			</classpath>
+			<arg value="${js-build-script}"/>
+			<arg value="${js-build-dir}"/>
+			<arg value="name=${build-js-main-rhino-frontend-module}"/> 
+			<arg value="out=${build-js-main}"/>
+			<arg value="baseUrl=."/>
+			<arg value="includeRequire=true"/>
+			<arg value="inlineText=true"/> 
+			<arg value="optimize=none"/>
+		</java>
+	</target>
+
+	<target name="compile-single-class" depends="compile-single-js">
+		<mkdir dir="${build-class}"/>
+
+		<!-- TODO: set -opt -->
+		<java classname="org.mozilla.javascript.tools.jsc.Main">
+			<classpath>
+				<path refid="rhino-classpath"/>
+			</classpath>
+			<arg value="-o"/>
+			<arg value="${build-class-main-name}.class"/>
+			<arg value="${build-js-main}"/>
+		</java>
+		<move file="${build-js}/${build-class-main-name}.class" todir="${build-class}"/>
+	</target>
+
+	<target name="jar-single-class" depends="compile-single-class">
+		<mkdir dir="${build-jar}"/>
+
+		<jar destfile="${build-jar-main}"
+			basedir="${build-class}"
+			includes="${build-class-main-name}.class">
+			<manifest>
+				<attribute name="Main-Class" value="${build-class-main-name}" />
+			</manifest>
+		</jar>
+	</target>
+
+	<!-- these targets are here to do a simple test of the compiled jar and class-->
+	<target name="run-single-class" depends="compile-single-class">
+		<java classname="${build-class-main-name}" output="${build}/out.js">
+			<classpath>
+				<path refid="maven.compile.classpath"/>
+				<pathelement location="${build-class}"/>
+			</classpath>
+			<arg value="--backend"/>
+			<arg value="state"/>
+			<arg value="--beautify"/>
+			<arg value="test/parallel/TestParallel.xml"/>
+		</java>
+	</target>
+
+	<target name="run-single-jar" depends="jar-single-class">
+		<java classname="${build-class-main-name}" output="${build}/out.js">
+			<classpath>
+				<path refid="maven.compile.classpath"/>
+				<pathelement location="${build-jar-main}"/>
+			</classpath>
+			<arg value="--backend"/>
+			<arg value="state"/>
+			<arg value="--beautify"/>
+			<arg value="test/parallel/TestParallel.xml"/>
+		</java>
+	</target>
+
+</project>
+

Propchange: commons/sandbox/gsoc/2010/scxml-js/trunk/mvn-ant-build.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: commons/sandbox/gsoc/2010/scxml-js/trunk/pom.xml
URL: http://svn.apache.org/viewvc/commons/sandbox/gsoc/2010/scxml-js/trunk/pom.xml?rev=990416&r1=990415&r2=990416&view=diff
==============================================================================
--- commons/sandbox/gsoc/2010/scxml-js/trunk/pom.xml (original)
+++ commons/sandbox/gsoc/2010/scxml-js/trunk/pom.xml Sat Aug 28 19:15:08 2010
@@ -84,6 +84,74 @@
     <commons.jira.pid>12310492</commons.jira.pid>
   </properties> 
 
+<!--
+  <repositories>
+    <repository>
+      <id>openqa</id>
+      <url>http://maven.openqa.org</url>
+    </repository>
+  </repositories>
+-->
+
+
+  <dependencies>
+	<dependency>
+		<groupId>commons-cli</groupId>
+		<artifactId>commons-cli</artifactId>
+		<version>1.2</version>
+	</dependency>
+	<dependency>
+		<groupId>xalan</groupId>
+		<artifactId>xalan</artifactId>
+		<version>2.7.0</version>
+	</dependency>
+	<dependency>
+		<groupId>xerces</groupId>
+		<artifactId>xercesImpl</artifactId>
+		<version>2.9.1</version>
+	</dependency>
+	<dependency>
+		<groupId>xml-apis</groupId>
+		<artifactId>xml-apis</artifactId>
+		<version>2.0.2</version>
+	</dependency>
+
+	<!-- would be very nice if we could pull down rhino as well...
+		we could extend Array.prototype with reduce.
+		or just take it out... -->
+	<!--
+	<dependency>
+		<groupId>rhino</groupId>
+		<artifactId>js</artifactId>
+		<version>1.7R2</version>
+		<scope>runtime</scope>
+	</dependency>
+	-->
+
+	<!-- TODO: start/stop selenium server as part of testing lifecycle -->
+	<!--
+	<dependency>
+		<groupId>org.seleniumhq.selenium.client-drivers</groupId>
+		<artifactId>selenium-java-client-driver</artifactId>
+		<version>1.0.1</version>
+	</dependency>
+        <dependency>
+            <groupId>org.seleniumhq.selenium.server</groupId>
+            <artifactId>selenium-server</artifactId>
+            <version>1.0.3</version>
+            <classifier>standalone</classifier>
+        </dependency>
+	-->
+	<!--
+	<dependency>
+		<groupId>org.seleniumhq.selenium</groupId>
+		<artifactId>selenium-remote-control</artifactId>
+		<version>1.0.1</version>
+        </dependency>
+	-->
+	
+  </dependencies>
+
  <build>
    <plugins>
      <plugin>
@@ -99,7 +167,12 @@
             <phase>compile</phase>
             <configuration>
               <tasks>
-		<ant target="compile-single-class"/>
+                <property name="compile_classpath" refid="maven.compile.classpath"/>
+                <property name="runtime_classpath" refid="maven.runtime.classpath"/>
+                <property name="test_classpath" refid="maven.test.classpath"/>
+                <property name="plugin_classpath" refid="maven.plugin.classpath"/>
+
+		<ant target="compile-single-class" inheritRefs="true" antfile="mvn-ant-build.xml"/>
               </tasks>
             </configuration>
             <goals>
@@ -107,6 +180,48 @@
             </goals>
           </execution>
         </executions>
+	<dependencies>
+		<dependency>
+			<groupId>bsf</groupId>
+			<artifactId>bsf</artifactId>
+			<version>2.4.0</version>
+		</dependency>
+		<dependency>
+			<groupId>commons-logging</groupId>
+			<artifactId>commons-logging</artifactId>
+			<version>1.1.1</version>
+		</dependency>
+		<dependency>
+			<groupId>ant-contrib</groupId>
+			<artifactId>ant-contrib</artifactId>
+			<version>1.0b3</version>
+			<exclusions>
+				<exclusion>
+					<groupId>ant</groupId>
+					<artifactId>ant</artifactId>
+				</exclusion>
+			</exclusions>
+		</dependency>
+		<dependency>
+			<groupId>xalan</groupId>
+			<artifactId>xalan</artifactId>
+			<version>2.7.0</version>
+		</dependency>
+		<!--
+		<dependency>
+			<groupId>org.seleniumhq.selenium.client-drivers</groupId>
+			<artifactId>selenium-java-client-driver</artifactId>
+			<version>1.0.1</version>
+		</dependency>
+		-->
+		<!--
+		<dependency>
+			<groupId>rhino</groupId>
+			<artifactId>js</artifactId>
+			<version>1.7R2</version>
+		</dependency>
+		-->
+	</dependencies>
       </plugin>
       <plugin>
         <groupId>org.apache.maven.plugins</groupId>