#!/bin/bash
#
# Copyright 2013 Cloudera Inc.
#
# Licensed 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.
#

# the directory that contains this file
source_dir=$(cd "$(dirname "$0")"; pwd)

SCALA=`type -p scala`
MVN=`type -p mvn`

[ -f "pom.xml" ] || { echo "Please run me from the top level project directory" ; exit 1 ; }
[ -x "$SCALA" ] || { echo "Unable to find the scala executable (check your path)" ; exit 1 ; }
[ -x "$MVN" ] || { echo "Unable to find the mvn executable (check your path)" ; exit 1 ; }

[ -d "target/classes" ] || { echo "No target/classes directory (did you do a mvn compile yet?)" ; exit 1 ; }

echo "== Determining classpath. Please wait..."

dep_classpath=`$MVN dependency:build-classpath | grep -v '^\['`
full_classpath="target/test-classes:target/classes:$dep_classpath"

echo "== Starting a shell with Kite Data classes"

"$SCALA" -cp "$full_classpath" -i $source_dir/data-shell-inc.scala $*
