You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@thrift.apache.org by jf...@apache.org on 2011/04/20 18:35:21 UTC

svn commit: r1095454 - in /thrift: branches/0.6.x/lib/js/test/build.xml branches/0.6.x/lib/js/test/ivy.xml trunk/lib/js/test/build.xml trunk/lib/js/test/ivy.xml

Author: jfarrell
Date: Wed Apr 20 16:35:20 2011
New Revision: 1095454

URL: http://svn.apache.org/viewvc?rev=1095454&view=rev
Log:
Thrift-1133: Java and JavaScript tutorial is broken since we have Java maven deployment
patch: jfarrell
client: js

Fixing build.xml for the js test cases to use ant-tasks.


Removed:
    thrift/branches/0.6.x/lib/js/test/ivy.xml
    thrift/trunk/lib/js/test/ivy.xml
Modified:
    thrift/branches/0.6.x/lib/js/test/build.xml
    thrift/trunk/lib/js/test/build.xml

Modified: thrift/branches/0.6.x/lib/js/test/build.xml
URL: http://svn.apache.org/viewvc/thrift/branches/0.6.x/lib/js/test/build.xml?rev=1095454&r1=1095453&r2=1095454&view=diff
==============================================================================
--- thrift/branches/0.6.x/lib/js/test/build.xml (original)
+++ thrift/branches/0.6.x/lib/js/test/build.xml Wed Apr 20 16:35:20 2011
@@ -7,7 +7,7 @@
  "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
+ 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
@@ -17,8 +17,8 @@
  under the License.
 -->
 <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>
 
@@ -32,16 +32,19 @@
   <property name="thrift.dir" location="../../../" />
   <property name="thrift.java.dir" location="${thrift.dir}/lib/java" />
 
-  <property name="thrift.compiler" location="${thrift.dir}/compiler/cpp/thrift" />
+  <!-- Include the base java properties file -->
+  <property file="${thrift.java.dir}/build.properties" />
 
-  <!-- take ivy from java, test depends anyway on java! -->
-  <property name="ivy.dir" location="${thrift.java.dir}/build/ivy" />
-  <property name="ivy.lib.dir" location="${ivy.dir}/lib" />
+  <property name="thrift.compiler" location="${thrift.dir}/compiler/cpp/thrift" />
 
   <path id="libs.classpath">
-    <pathelement path="${thrift.java.dir}/libthrift.jar" />
-    <pathelement path="${thrift.java.dir}/libthrift-test.jar" />
-    <fileset dir="${thrift.java.dir}/build/ivy/lib">
+    <fileset dir="${thrift.java.dir}/build/">
+      <include name="*.jar" />
+    </fileset>
+    <fileset dir="${thrift.java.dir}/build/lib">
+      <include name="*.jar" />
+    </fileset>
+    <fileset dir="${build}/lib">
       <include name="*.jar" />
     </fileset>
   </path>
@@ -55,29 +58,19 @@
     <fail>
       <condition>
         <not>
-          <resourcecount count="1">
-            <fileset id="fs" dir="${thrift.java.dir}" includes="libthrift.jar"/>
+          <resourcecount count="2">
+            <fileset id="fs" dir="${thrift.java.dir}/build" includes="libthrift*.jar"/>
           </resourcecount>
         </not>
       </condition>
-      You need libthrift.jar located at
-      ${thrift.java.dir}
+      You need libthrift*.jar and libthrift*test.jar located at
+      ${thrift.java.dir}/build
       Did you compile Thrift Java library and its test suite by "ant compile-test"?
     </fail>
     <fail>
       <condition>
         <not>
           <resourcecount count="1">
-            <fileset id="fs" dir="${ivy.dir}" includes="ivy-2*.jar"/>
-          </resourcecount>
-        </not>
-      </condition>
-      ivy is missing at ${ivy.dir}
-    </fail>
-    <fail>
-      <condition>
-        <not>
-          <resourcecount count="1">
             <fileset id="fs" dir="${thrift.dir}" includes="compiler/cpp/thrift"/>
           </resourcecount>
         </not>
@@ -89,6 +82,7 @@
   <target name="init" depends="dependencies">
     <tstamp />
     <mkdir dir="${build}"/>
+    <mkdir dir="${build}/lib"/>
   </target>
 
   <target name="compile" description="compile the test suite" depends="init, generate, resolve">
@@ -96,11 +90,11 @@
     <javac srcdir="${src}" destdir="${build}" classpathref="libs.classpath" />
   </target>
 
-  <target name="jstest" description="" depends="compile">
+  <target name="jstest" description="" depends="compile, lint">
     <jar jarfile="${jar.file}" basedir="${build}"/>
   </target>
 
-  <target name="test" description="run the test server" depends="jstest">
+  <target name="testserver" description="run the test server" depends="jstest">
     <java classname="test.Httpd" fork="true"
       classpathref="test.classpath" failonerror="true">
       <arg value="../" />
@@ -112,7 +106,40 @@
       <arg line="--gen java ${thrift.dir}/test/ThriftTest.thrift" />
     </exec>
     <exec executable="${thrift.compiler}" failonerror="true">
-      <arg line="--gen js ${thrift.dir}/test/ThriftTest.thrift" />
+      <arg line="--gen js:jquery ${thrift.dir}/test/ThriftTest.thrift" />
+    </exec>
+  </target>
+
+  <!-- @TODO QUnit tests as part of the testsuite-->
+  <target name="test" description="run test suite" depends="init, generate, resolve, lint"/>
+
+  <target name="lint" description="code quality checks" depends="generate, gjslint, jslint"/>
+
+  <target name="jslint">
+    <taskdef uri="antlib:com.googlecode.jslint4java" resource="com/googlecode/jslint4java/antlib.xml" classpathref="libs.classpath" />
+    <!--
+         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>
 
@@ -123,35 +150,21 @@
     <delete file="${jar.file}" />
   </target>
 
-  <!-- ivy tasks from java build.xml ... don't know how to import them instead of copying -->
-  <target name="resolve" depends="ivy-init-antlib" description="retrieve dependencies with ivy" unless="noivy">
-    <ivy:retrieve />
-  </target>
-
-  <target name="ivy-probe-antlib">
-    <condition property="ivy.found">
-      <typefound uri="antlib:org.apache.ivy.ant" name="cleancache"/>
-    </condition>
-  </target>
-
-  <target name="ivy-init-antlib" depends="ivy-probe-antlib" unless="ivy.found">
-    <typedef uri="antlib:org.apache.ivy.ant" onerror="fail"
-      loaderRef="ivyLoader">
-      <classpath>
-        <fileset dir="${ivy.dir}">
-          <include name="ivy-2.*.jar" />
-        </fileset>
-      </classpath>
-    </typedef>
-    <fail>
-      <condition >
-        <not>
-          <typefound uri="antlib:org.apache.ivy.ant" name="cleancache"/>
-        </not>
-      </condition>
-      You need Apache Ivy 2.0 or later from http://ant.apache.org/
-      It could not be loaded from ${ivy_repo_url}
-    </fail>
-  </target>
+  <target name="resolve" unless="mvn.finished">
+    <typedef uri="antlib:org.apache.maven.artifact.ant" classpath="${thrift.java.dir}/build/tools/${mvn.ant.task.jar}"/>
 
+    <artifact:dependencies filesetId="js.test.dependency.jars">
+      <dependency groupId="org.apache.httpcomponents" artifactId="httpclient" version="4.0.1"/>
+      <dependency groupId="com.googlecode.jslint4java" artifactId="jslint4java-ant" version="1.4.6"/>
+    </artifact:dependencies>
+
+    <!-- Copy the dependencies to the build/lib dir -->
+    <copy todir="${build}/lib">
+      <fileset refid="js.test.dependency.jars"/>
+      <mapper type="flatten"/>
+    </copy>
+    
+    <property name="mvn.finished" value="true"/>
+  </target>
 </project>
+

Modified: thrift/trunk/lib/js/test/build.xml
URL: http://svn.apache.org/viewvc/thrift/trunk/lib/js/test/build.xml?rev=1095454&r1=1095453&r2=1095454&view=diff
==============================================================================
--- thrift/trunk/lib/js/test/build.xml (original)
+++ thrift/trunk/lib/js/test/build.xml Wed Apr 20 16:35:20 2011
@@ -7,7 +7,7 @@
  "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
+ 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
@@ -17,7 +17,6 @@
  under the License.
 -->
 <project name="Java Script Test" default="test" basedir="."
-  xmlns:ivy="antlib:org.apache.ivy.ant"
   xmlns:artifact="antlib:org.apache.maven.artifact.ant"
   xmlns:jsl="antlib:com.googlecode.jslint4java">
 
@@ -33,11 +32,10 @@
   <property name="thrift.dir" location="../../../" />
   <property name="thrift.java.dir" location="${thrift.dir}/lib/java" />
 
-  <property name="thrift.compiler" location="${thrift.dir}/compiler/cpp/thrift" />
+  <!-- Include the base java properties file -->
+  <property file="${thrift.java.dir}/build.properties" />
 
-  <!-- take ivy from java, test depends anyway on java! -->
-  <property name="ivy.dir" location="${build}/ivy" />
-  <property name="ivy.lib.dir" location="${ivy.dir}/lib" />
+  <property name="thrift.compiler" location="${thrift.dir}/compiler/cpp/thrift" />
 
   <path id="libs.classpath">
     <fileset dir="${thrift.java.dir}/build/">
@@ -46,7 +44,7 @@
     <fileset dir="${thrift.java.dir}/build/lib">
       <include name="*.jar" />
     </fileset>
-    <fileset dir="${ivy.lib.dir}/">
+    <fileset dir="${build}/lib">
       <include name="*.jar" />
     </fileset>
   </path>
@@ -73,16 +71,6 @@
       <condition>
         <not>
           <resourcecount count="1">
-            <fileset id="fs" dir="${thrift.java.dir}/build/tools" includes="ivy-2*.jar"/>
-          </resourcecount>
-        </not>
-      </condition>
-      ivy is missing at ${ivy.dir}
-    </fail>
-    <fail>
-      <condition>
-        <not>
-          <resourcecount count="1">
             <fileset id="fs" dir="${thrift.dir}" includes="compiler/cpp/thrift"/>
           </resourcecount>
         </not>
@@ -94,6 +82,7 @@
   <target name="init" depends="dependencies">
     <tstamp />
     <mkdir dir="${build}"/>
+    <mkdir dir="${build}/lib"/>
   </target>
 
   <target name="compile" description="compile the test suite" depends="init, generate, resolve">
@@ -132,7 +121,7 @@
          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">
+    <jsl:jslint options="evil,forin,browser,bitwise,regexp,newcap,immed">
       <formatter type="plain" />
       <fileset dir="${genjs}" includes="**/*.js" />
       <fileset dir=".." includes="thrift.js" />
@@ -145,7 +134,7 @@
       <arg line="--helpshort"/>
     </exec>
   </target>
-    
+
   <target name="gjslint" depends="check-gjslint" if="gjslint.present">
     <exec executable="gjslint" failifexecutionfails="no">
       <arg line="--nojsdoc"/>
@@ -161,35 +150,21 @@
     <delete file="${jar.file}" />
   </target>
 
-  <!-- ivy tasks from java build.xml ... don't know how to import them instead of copying -->
-  <target name="resolve" depends="ivy-init-antlib" description="retrieve dependencies with ivy" unless="noivy">
-    <ivy:retrieve />
-  </target>
-
-  <target name="ivy-probe-antlib">
-    <condition property="ivy.found">
-      <typefound uri="antlib:org.apache.ivy.ant" name="cleancache"/>
-    </condition>
-  </target>
-
-  <target name="ivy-init-antlib" depends="ivy-probe-antlib" unless="ivy.found">
-    <typedef uri="antlib:org.apache.ivy.ant" onerror="fail"
-      loaderRef="ivyLoader">
-      <classpath>
-        <fileset dir="${thrift.java.dir}/build/tools">
-          <include name="ivy-2.*.jar" />
-        </fileset>
-      </classpath>
-    </typedef>
-    <fail>
-      <condition >
-        <not>
-          <typefound uri="antlib:org.apache.ivy.ant" name="cleancache"/>
-        </not>
-      </condition>
-      You need Apache Ivy 2.0 or later from http://ant.apache.org/
-      It could not be loaded from ${ivy_repo_url}
-    </fail>
-  </target>
+  <target name="resolve" unless="mvn.finished">
+    <typedef uri="antlib:org.apache.maven.artifact.ant" classpath="${thrift.java.dir}/build/tools/${mvn.ant.task.jar}"/>
 
+    <artifact:dependencies filesetId="js.test.dependency.jars">
+      <dependency groupId="org.apache.httpcomponents" artifactId="httpclient" version="4.0.1"/>
+      <dependency groupId="com.googlecode.jslint4java" artifactId="jslint4java-ant" version="1.4.6"/>
+    </artifact:dependencies>
+
+    <!-- Copy the dependencies to the build/lib dir -->
+    <copy todir="${build}/lib">
+      <fileset refid="js.test.dependency.jars"/>
+      <mapper type="flatten"/>
+    </copy>
+    
+    <property name="mvn.finished" value="true"/>
+  </target>
 </project>
+