THRIFT-1089 JavaScript Quality Assurance with lint


git-svn-id: https://svn.apache.org/repos/asf/thrift/trunk@1081707 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/lib/js/test/build.xml b/lib/js/test/build.xml
index ee38edb..be4e7d5 100644
--- a/lib/js/test/build.xml
+++ b/lib/js/test/build.xml
@@ -18,7 +18,8 @@
 -->
 <project name="Java Script Test" default="test" basedir="."
   xmlns:ivy="antlib:org.apache.ivy.ant"
-  xmlns:artifact="antlib:org.apache.maven.artifact.ant">
+  xmlns:artifact="antlib:org.apache.maven.artifact.ant"
+  xmlns:jsl="antlib:com.googlecode.jslint4java">
 
   <description>Java Script Test based on Thrift Java Library</description>
 
@@ -51,6 +52,8 @@
     <pathelement location="${jar.file}" />
   </path>
 
+  <taskdef uri="antlib:com.googlecode.jslint4java" resource="com/googlecode/jslint4java/antlib.xml" classpathref="libs.classpath" />
+
   <target name="dependencies">
     <fail>
       <condition>
@@ -116,6 +119,35 @@
     </exec>
   </target>
 
+  <target name="lint" description="code quality checks" depends="gjslint, jslint"/>
+
+  <target name="jslint">
+    <!--
+         the following options would probably make sense in the future:
+         browser,undef,eqeqeq,plusplus,bitwise,regexp,strict,newcap,immed
+    -->
+  	<jsl:jslint options="evil,forin,browser,bitwise,regexp,newcap,immed">
+      <formatter type="plain" />
+      <fileset dir="${genjs}" includes="**/*.js" />
+      <fileset dir=".." includes="thrift.js" />
+    </jsl:jslint>
+  </target>
+
+  <target name="check-gjslint">
+    <echo>check if gjslint is available:</echo>
+    <exec executable="gjslint" failifexecutionfails="no" resultproperty="gjslint.present" failonerror="false">
+      <arg line="--helpshort"/>
+    </exec>
+  </target>
+    
+  <target name="gjslint" depends="check-gjslint" if="gjslint.present">
+    <exec executable="gjslint" failifexecutionfails="no">
+      <arg line="--nojsdoc"/>
+      <arg line="${genjs}/*.js"/>
+      <arg line="../thrift.js"/>
+    </exec>
+  </target>
+
   <target name="clean">
     <delete dir="${build}" />
     <delete dir="${genjava}" />