Repository navigation
Expand file tree
/
Copy pathrun
More file actions
executable file
·63 lines (52 loc) · 1.77 KB
/
Copy pathrun
File metadata and controls
executable file
·63 lines (52 loc) · 1.77 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#! /bin/bash
# ------------------------------------------------------------------
# A script to run the example programs.
#
# Usage: ./run <example-name>
#
# For example: ./run web-file-browser
# ------------------------------------------------------------------
set -e
die() {
for line in "$@"; do
echo "$line" > /dev/stderr
done
exit 1
}
# Locate the script file. Cross symlinks if necessary.
loc="$0"
while [ -h "$loc" ]; do
ls=`ls -ld "$loc"`
link=`expr "$ls" : '.*-> \(.*\)$'`
if expr "$link" : '/.*' > /dev/null; then
loc="$link" # Absolute link
else
loc="`dirname "$loc"`/$link" # Relative link
fi
done
base_dir="$(dirname "$loc")"
if [ $# -eq 0 ]; then
die "" \
"Usage: run <example-name> example-args..." \
"" \
"For example: run web-file-browser ..." \
""
fi
example_name="$1" ; shift
example_name="$(echo "$example_name" | sed 's|/*$||')"
# Remove trailing slashes, since shell tab completion will usually add one.
example_folder=${example_name//_/-}
example_package=${example_name//-/_}
if [ ! -f "$base_dir/$example_folder/pom.xml" ]; then
die "Invalid example \"$example_name\"." \
"(Couldn't find \"pom.xml\" in \"$base_dir/$example_folder\".)"
fi
if [ ! -f "$base_dir/$example_folder/target/runtime-classpath" ]; then
die "Unable to run example \"$example_name\"." \
"Couldn't find \"target/runtime-classpath\" in \"$base_dir/$example_folder\"."
"Run \"mvn compile\" at the top-level of the project first."
fi
base_dir=`dirname "$loc"`
classpath="$base_dir/$example_folder/target/classes:$(cat $base_dir/$example_folder/target/runtime-classpath)"
main_class=com.dropbox.core.examples."$example_package".Main
exec java -ea -cp "$classpath" "$main_class" "$@"