Created
November 29, 2010 19:41
-
-
Save kyleburton/720456 to your computer and use it in GitHub Desktop.
Maven / Clojure Bash Script for running a compiled class.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function project_dir () { | |
if [ -z "${PROJECT_DIR:-}" ]; then | |
abspath=$(cd ${0%/*} && echo $PWD/${0##*/}) | |
path_only=$(dirname "$abspath") | |
path_only=$(dirname "$path_only") | |
path_only=$(dirname "$path_only") | |
PROJECT_DIR="$path_only" | |
export PROJECT_DIR | |
fi | |
echo $PROJECT_DIR | |
} | |
function project_classpath () { | |
if [ ! -e $(project_dir)/.classpath -o $(project_dir)/pom.xml -nt $(project_dir).classpath ]; then | |
OLD=$(pwd) | |
cd $(project_dir) | |
mvn -Dmdep.outputFile=$(project_dir)/.classpath dependency:build-classpath 2>&1 > /dev/null | |
cd $(pwd) | |
fi | |
cat $(project_dir)/.classpath | |
} | |
function run_java () { | |
cd $(project_dir) | |
RLWRAP="$(which rlwrap || echo no)" | |
if [ "no" = "$RLWRAP" ]; then | |
RLWRAP="" | |
else | |
echo "Using rlwrap..." | |
fi | |
$RLWRAP java -cp target/test-classes:target/classes:$(project_classpath) "$@" | |
} | |
run_java your.class.Name "$@" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment