Author: jghoman
Date: Fri Feb  3 19:12:46 2012
New Revision: 1240303

URL: http://svn.apache.org/viewvc?rev=1240303&view=rev
Log:
GIRAPH-136: Error message for bin/giraph could be improved.

Modified:
    incubator/giraph/trunk/CHANGELOG
    incubator/giraph/trunk/bin/giraph

Modified: incubator/giraph/trunk/CHANGELOG
URL: 
http://svn.apache.org/viewvc/incubator/giraph/trunk/CHANGELOG?rev=1240303&r1=1240302&r2=1240303&view=diff
==============================================================================
--- incubator/giraph/trunk/CHANGELOG (original)
+++ incubator/giraph/trunk/CHANGELOG Fri Feb  3 19:12:46 2012
@@ -1,6 +1,10 @@
 Giraph Change Log
 
-Release 0.1.0 - unreleased
+Release 0.2.0 - unreleased
+  
+  GIRAPH-136: Error message for bin/graph could be improved. (jghoman)
+
+Release 0.1.0 - 2012-01-31
 
   GIRAPH-120: Add Sebastian Schelter to site. (ssc)
 

Modified: incubator/giraph/trunk/bin/giraph
URL: 
http://svn.apache.org/viewvc/incubator/giraph/trunk/bin/giraph?rev=1240303&r1=1240302&r2=1240303&view=diff
==============================================================================
--- incubator/giraph/trunk/bin/giraph (original)
+++ incubator/giraph/trunk/bin/giraph Fri Feb  3 19:12:46 2012
@@ -15,6 +15,14 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
+# friendly message for those who forget to tell us what to do
+if [ $# = 0 ]; then
+  echo "Usage: giraph [-D<Hadoop property>] <jar containing vertex> 
<parameters to jar>"
+  echo "At a minimum one must provide a path to the jar containing the vertex 
to be executed."
+  exit 1
+fi
+
+
 # resolve links - $0 may be a softlink
 THIS="$0"
 while [ -h "$THIS" ]; do
@@ -31,7 +39,7 @@ done
 THIS_DIR=`dirname "$THIS"`
 GIRAPH_HOME=`cd "$THIS_DIR/.." ; pwd`
 
-# extra properites to send straight to Hadoop
+# extra properties to send straight to Hadoop
 HADOOP_PROPERTIES=
 while [ $1 ] && [ ${1:0:2} == "-D" ] ; do
     HADOOP_PROPERTIES="$1 $HADOOP_PROPERTIES"
@@ -42,29 +50,46 @@ USER_JAR=$1
 shift
 
 if [ ! -e "$USER_JAR" ]; then
-  echo "Can't find user jar to execute."
+  echo "Can't find user jar (${USER_JAR}) to execute."
   exit 1
 fi
 
 # add user jar to classpath
 CLASSPATH=${USER_JAR}
 
+CLASS=org.apache.giraph.GiraphRunner
+
 # so that filenames w/ spaces are handled correctly in loops below
 IFS=
 
 # add release dependencies to CLASSPATH
-for f in $GIRAPH_HOME/lib/*.jar; do
-  CLASSPATH=${CLASSPATH}:$f;
-done
-
-CLASS=org.apache.giraph.GiraphRunner
-
-for f in $GIRAPH_HOME/lib/giraph*.jar ; do
-  if [ -e "$f" ]; then
-    JAR=$f
-  fi
-done
-
+if [ -d "$GIRAPH_HOME/lib" ]; then
+       for f in $GIRAPH_HOME/lib/*.jar; do
+         CLASSPATH=${CLASSPATH}:$f;
+       done
+
+       for f in $GIRAPH_HOME/lib/giraph*.jar ; do
+         if [ -e "$f" ]; then
+           JAR=$f
+           break
+         fi
+       done
+else
+       echo "No lib directory, assuming dev environment"
+       if [ ! -d "$GIRAPH_HOME/target" ]; then
+               echo "No target directory. Build Giraph jar before proceeding."
+               exit 1
+       fi
+       
+       CLASSPATH=`mvn dependency:build-classpath | grep -v "[INFO]"`
+       
+       for f in $GIRAPH_HOME/target/giraph*.jar ; do
+         if [ -e "$f" ]; then
+           JAR=$f
+           break
+         fi
+       done
+fi
 # restore ordinary behaviour
 unset IFS
 


Reply via email to