You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@thrift.apache.org by ro...@apache.org on 2012/10/22 21:27:39 UTC
svn commit: r1401032 - in /thrift/trunk: ./ tutorial/ tutorial/java/
tutorial/js/
Author: roger
Date: Mon Oct 22 19:27:38 2012
New Revision: 1401032
URL: http://svn.apache.org/viewvc?rev=1401032&view=rev
Log:
THRIFT-1735 integrate tutorial into regular build
Patch: Roger Meier
Added:
thrift/trunk/tutorial/Makefile.am (with props)
thrift/trunk/tutorial/java/Makefile.am (with props)
thrift/trunk/tutorial/js/Makefile.am (with props)
Removed:
thrift/trunk/tutorial/java/JavaClient
thrift/trunk/tutorial/java/JavaServer
Modified:
thrift/trunk/Makefile.am
thrift/trunk/configure.ac
thrift/trunk/tutorial/ (props changed)
thrift/trunk/tutorial/java/ (props changed)
thrift/trunk/tutorial/java/README
thrift/trunk/tutorial/java/build.xml
thrift/trunk/tutorial/js/ (props changed)
thrift/trunk/tutorial/js/build.xml
thrift/trunk/tutorial/js/tutorial.html
Modified: thrift/trunk/Makefile.am
URL: http://svn.apache.org/viewvc/thrift/trunk/Makefile.am?rev=1401032&r1=1401031&r2=1401032&view=diff
==============================================================================
--- thrift/trunk/Makefile.am (original)
+++ thrift/trunk/Makefile.am Mon Oct 22 19:27:38 2012
@@ -19,7 +19,7 @@
ACLOCAL_AMFLAGS = -I ./aclocal
-SUBDIRS = compiler/cpp lib
+SUBDIRS = compiler/cpp lib tutorial
if WITH_TESTS
SUBDIRS += test
Modified: thrift/trunk/configure.ac
URL: http://svn.apache.org/viewvc/thrift/trunk/configure.ac?rev=1401032&r1=1401031&r2=1401032&view=diff
==============================================================================
--- thrift/trunk/configure.ac (original)
+++ thrift/trunk/configure.ac Mon Oct 22 19:27:38 2012
@@ -611,6 +611,9 @@ AC_CONFIG_FILES([
test/py/Makefile
test/py.twisted/Makefile
test/rb/Makefile
+ tutorial/Makefile
+ tutorial/java/Makefile
+ tutorial/js/Makefile
])
AC_OUTPUT
Propchange: thrift/trunk/tutorial/
------------------------------------------------------------------------------
--- svn:ignore (original)
+++ svn:ignore Mon Oct 22 19:27:38 2012
@@ -1 +1,4 @@
gen-*
+Makefile.in
+Makefile
+
Added: thrift/trunk/tutorial/Makefile.am
URL: http://svn.apache.org/viewvc/thrift/trunk/tutorial/Makefile.am?rev=1401032&view=auto
==============================================================================
--- thrift/trunk/tutorial/Makefile.am (added)
+++ thrift/trunk/tutorial/Makefile.am Mon Oct 22 19:27:38 2012
@@ -0,0 +1,56 @@
+#
+# 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.
+#
+
+SUBDIRS =
+
+if WITH_CPP
+#SUBDIRS += cpp
+endif
+
+if WITH_JAVA
+SUBDIRS += java
+SUBDIRS += js
+endif
+
+if WITH_PERL
+#SUBDIRS += perl
+endif
+
+if WITH_PHP
+#SUBDIRS += php
+endif
+
+if WITH_PYTHON
+#SUBDIRS += py
+#SUBDIRS += py.twisted
+endif
+
+if WITH_RUBY
+#SUBDIRS += rb
+endif
+
+if WITH_HASKELL
+#SUBDIRS += hs
+endif
+
+#
+# generate html for ThriftTest.thrift
+#
+check-local:
+ $(top_builddir)/compiler/cpp/thrift --gen html -r $(top_srcdir)/tutorial/tutorial.thrift
Propchange: thrift/trunk/tutorial/Makefile.am
------------------------------------------------------------------------------
svn:executable = *
Propchange: thrift/trunk/tutorial/java/
------------------------------------------------------------------------------
--- svn:ignore (original)
+++ svn:ignore Mon Oct 22 19:27:38 2012
@@ -1,2 +1,5 @@
build
+gen-*
+Makefile.in
+Makefile
tutorial.jar
Added: thrift/trunk/tutorial/java/Makefile.am
URL: http://svn.apache.org/viewvc/thrift/trunk/tutorial/java/Makefile.am?rev=1401032&view=auto
==============================================================================
--- thrift/trunk/tutorial/java/Makefile.am (added)
+++ thrift/trunk/tutorial/java/Makefile.am Mon Oct 22 19:27:38 2012
@@ -0,0 +1,37 @@
+#
+# 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
+
+tutorial: all
+ $(ANT) $(ANT_FLAGS) tutorial
+
+tutorialserver: all
+ $(ANT) $(ANT_FLAGS) tutorialserver
+
+tutorialclient: all
+ $(ANT) $(ANT_FLAGS) tutorialclient
\ No newline at end of file
Propchange: thrift/trunk/tutorial/java/Makefile.am
------------------------------------------------------------------------------
svn:executable = *
Modified: thrift/trunk/tutorial/java/README
URL: http://svn.apache.org/viewvc/thrift/trunk/tutorial/java/README?rev=1401032&r1=1401031&r2=1401032&view=diff
==============================================================================
--- thrift/trunk/tutorial/java/README (original)
+++ thrift/trunk/tutorial/java/README Mon Oct 22 19:27:38 2012
@@ -1,29 +1,20 @@
-Steps for Java tutorial
+Thrift Java Tutorial
==================================================
+1) Compile the Java library
-1) Make sure thrift is compiled, both the compiler and the Java library. You should
-be able to verify the following:
+thrift/lib/java$ make
+or:
+thrift/lib/java$ ant
-thrift/tutorial/java$ file ../../lib/java/build/libthrift-${version}-${release}.jar
-../../lib/java/libthrift.jar: Zip archive data, at least v1.0 to extract
+4) Run the tutorial:
-thrift/tutorial/java$ file ../../compiler/cpp/thrift
-../../compiler/cpp/thrift: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.15, not stripped
+start server and client with one step:
+thrift/tutorial/java$ make tutorial
-thrift/tutorial/java$ ls ../../lib/java/build/ivy/lib/
-commons-lang-2.5.jar junit-4.4.jar servlet-api-2.5.jar slf4j-api-1.5.8.jar slf4j-simple-1.5.8.jar
+or:
+thrift/tutorial/java$ make tutorialserver
+thrift/tutorial/java$ make tutorialclient
-
-2) Generate code for java:
-
-thrift/tutorial/java$ cd ..
-thrift/tutorial$ thrift -r -gen java tutorial.thrift
-
-3) Compile example
-
-thrift/tutorial/java$ ant
-
-4) Run example:
-
-thrift/tutorial/java$ ./JavaServer &
-thrift/tutorial/java$ ./JavaClient
+or:
+thrift/tutorial/java$ ant tutorialserver
+thrift/tutorial/java$ ant tutorialclient
Modified: thrift/trunk/tutorial/java/build.xml
URL: http://svn.apache.org/viewvc/thrift/trunk/tutorial/java/build.xml?rev=1401032&r1=1401031&r2=1401032&view=diff
==============================================================================
--- thrift/trunk/tutorial/java/build.xml (original)
+++ thrift/trunk/tutorial/java/build.xml Mon Oct 22 19:27:38 2012
@@ -18,10 +18,10 @@
-->
<project name="tutorial" default="tutorial" basedir=".">
- <description>Thrift Tutorial</description>
+ <description>Thrift Java Tutorial</description>
<property name="src" location="src" />
- <property name="gen" location="../gen-java" />
+ <property name="gen" location="gen-java" />
<property name="build" location="build" />
<path id="libs.classpath">
@@ -37,19 +37,71 @@
<path refid="libs.classpath" />
<pathelement path="${gen}" />
</path>
-
+ <path id="tutorial.classpath">
+ <path refid="build.classpath" />
+ <pathelement path="${build}" />
+ <pathelement path="tutorial.jar" />
+ </path>
+
<target name="init">
<tstamp />
<mkdir dir="${build}"/>
+ <mkdir dir="${build}/log"/>
</target>
- <target name="compile" depends="init">
+ <target name="compile" depends="init, generate">
<javac srcdir="${gen}" destdir="${build}" classpathref="libs.classpath" />
<javac srcdir="${src}" destdir="${build}" classpathref="build.classpath" />
</target>
- <target name="tutorial" depends="compile">
+ <target name="test" depends="tutorial" />
+
+ <target name="tutorial" description="Run the tutorial" depends="compile">
<jar jarfile="tutorial.jar" basedir="${build}"/>
+ <parallel>
+ <java classname="JavaServer" fork="true" timeout="10000"
+ classpathref="tutorial.classpath" failonerror="false" output="${build}/log/tutorial.log">
+ </java>
+ <sequential>
+ <sleep seconds="2"/>
+ <echo>tutorial client simple:</echo>
+ <java classname="JavaClient"
+ classpathref="tutorial.classpath" failonerror="true">
+ <arg line="simple"/>
+ </java>
+ <echo>tutorial client secure:</echo>
+ <java classname="JavaClient"
+ classpathref="tutorial.classpath" failonerror="true">
+ <arg line="secure"/>
+ </java>
+ </sequential>
+ </parallel>
+ </target>
+
+ <target name="generate">
+ <!-- Generate the thrift gen-java source -->
+ <exec executable="../../compiler/cpp/thrift" failonerror="true">
+ <arg line="--gen java -r ../tutorial.thrift"/>
+ </exec>
+ </target>
+
+ <target name="tutorialclient" description="Run a tutorial client" depends="compile">
+ <echo>tutorial client simple:</echo>
+ <java classname="JavaClient"
+ classpathref="tutorial.classpath" failonerror="true">
+ <arg line="simple"/>
+ </java>
+ <echo>tutorial client secure:</echo>
+ <java classname="JavaClient"
+ classpathref="tutorial.classpath" failonerror="true">
+ <arg line="secure"/>
+ </java>
+ </target>
+
+ <target name="tutorialserver" description="Run a tutorial server" depends="compile">
+ <java classname="JavaServer" fork="true"
+ classpathref="tutorial.classpath" failonerror="false" output="${build}/log/tutorial.log">
+ </java>
</target>
<target name="clean">
Propchange: thrift/trunk/tutorial/js/
------------------------------------------------------------------------------
--- svn:ignore (original)
+++ svn:ignore Mon Oct 22 19:27:38 2012
@@ -1,2 +1,5 @@
build
+gen-*
*.jar
+Makefile.in
+Makefile
Added: thrift/trunk/tutorial/js/Makefile.am
URL: http://svn.apache.org/viewvc/thrift/trunk/tutorial/js/Makefile.am?rev=1401032&view=auto
==============================================================================
--- thrift/trunk/tutorial/js/Makefile.am (added)
+++ thrift/trunk/tutorial/js/Makefile.am Mon Oct 22 19:27:38 2012
@@ -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
Propchange: thrift/trunk/tutorial/js/Makefile.am
------------------------------------------------------------------------------
svn:executable = *
Modified: thrift/trunk/tutorial/js/build.xml
URL: http://svn.apache.org/viewvc/thrift/trunk/tutorial/js/build.xml?rev=1401032&r1=1401031&r2=1401032&view=diff
==============================================================================
--- thrift/trunk/tutorial/js/build.xml (original)
+++ thrift/trunk/tutorial/js/build.xml Mon Oct 22 19:27:38 2012
@@ -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" />
Modified: thrift/trunk/tutorial/js/tutorial.html
URL: http://svn.apache.org/viewvc/thrift/trunk/tutorial/js/tutorial.html?rev=1401032&r1=1401031&r2=1401032&view=diff
==============================================================================
--- thrift/trunk/tutorial/js/tutorial.html (original)
+++ thrift/trunk/tutorial/js/tutorial.html Mon Oct 22 19:27:38 2012
@@ -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>