THRIFT-1735 integrate tutorial into regular build 
Patch: Roger Meier


git-svn-id: https://svn.apache.org/repos/asf/thrift/trunk@1401032 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/tutorial/js/Makefile.am b/tutorial/js/Makefile.am
new file mode 100755
index 0000000..1f57f20
--- /dev/null
+++ b/tutorial/js/Makefile.am
@@ -0,0 +1,31 @@
+#
+# 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.
+#
+
+export CLASSPATH
+
+# Make sure this doesn't fail if ant is not configured.
+clean-local:
+	ANT=$(ANT) ; if test -z "$$ANT" ; then ANT=: ; fi ; \
+	$$ANT $(ANT_FLAGS) clean
+
+check-local: all
+	$(ANT) $(ANT_FLAGS) test
+
+tutorialserver: all
+	$(ANT) $(ANT_FLAGS) tutorialserver
diff --git a/tutorial/js/build.xml b/tutorial/js/build.xml
index f757789..348f229 100644
--- a/tutorial/js/build.xml
+++ b/tutorial/js/build.xml
@@ -22,11 +22,12 @@
 
   <property name="src" location="src" />
   <property name="javasrc" location="../java/src" />
-  <property name="gen" location="../gen-java" />
+  <property name="gen" location="../java/gen-java" />
   <property name="build" location="build" />
 
   <!-- the root directory, where you unpack thrift distibution (e.g. thrift-0.x.x.tar.gz) -->
   <property name="thrift.dir" location="../../" />
+  <!-- JavaScript tutorial depends on the java tutorial thrift handler and server infrastructure -->
   <property name="thrift.java.dir" location="${thrift.dir}/lib/java" />
 
   <path id="libs.classpath">
@@ -61,17 +62,25 @@
     </javac>
   </target>
 
+  <target name="test" depends="tutorial" />
+
   <target name="tutorial" depends="compile">
     <jar jarfile="tutorial-js.jar" basedir="${build}"/>
   </target>
 
-  <target name="test" description="run the test server" depends="tutorial">
+  <target name="tutorialserver" description="run the test server" depends="tutorial, generate">
     <java classname="Httpd" fork="true"
       classpathref="build.classpath" failonerror="true">
       <arg value="../../" />
     </java>
   </target>
 
+  <target name="generate">
+    <exec executable="../../compiler/cpp/thrift" failonerror="true">
+      <arg line="--gen js -r  ../tutorial.thrift"/>
+    </exec>
+  </target>
+  
   <target name="clean">
     <delete dir="${build}" />
     <delete file="tutorial-js.jar" />
diff --git a/tutorial/js/tutorial.html b/tutorial/js/tutorial.html
index a34c9f3..e900421 100644
--- a/tutorial/js/tutorial.html
+++ b/tutorial/js/tutorial.html
@@ -23,10 +23,10 @@
   <title>Thrift Javascript Bindings - Tutorial Example</title>
 
   <script src="../../lib/js/thrift.js"                   type="text/javascript"></script>
-  <script src="../gen-js/tutorial_types.js"    type="text/javascript"></script>
-  <script src="../gen-js/shared_types.js"      type="text/javascript"></script>
-  <script src="../gen-js/SharedService.js"     type="text/javascript"></script>
-  <script src="../gen-js/Calculator.js"        type="text/javascript"></script>
+  <script src="gen-js/tutorial_types.js"    type="text/javascript"></script>
+  <script src="gen-js/shared_types.js"      type="text/javascript"></script>
+  <script src="gen-js/SharedService.js"     type="text/javascript"></script>
+  <script src="gen-js/Calculator.js"        type="text/javascript"></script>
 
   <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>