-
Notifications
You must be signed in to change notification settings - Fork 21
/
Copy pathrun
executable file
·42 lines (33 loc) · 1.61 KB
/
run
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
#!/bin/sh
# To run our code, we must have it in our classpath.
# We use $(ls target/*.jar) instead of hardcoding the name so that
# this script can be reused in other projects more easily.
TARGET=$(ls target/catan-1.0.jar 2>/dev/null)
if [ -z "$TARGET" ]; then
echo "No jar file in target/, try 'mvn package'".
exit 1
fi
# In the pom.xml, we've already explained what other libraries we
# depend on. Maven downloaded them, and put them "somewhere" (our
# repository). Now we ask maven to build up the CLASSPATH that lets us
# run against those libraries.
# We store the CLASSPATH in .mvn-classpath if the pom.xml is newer
# than our existing .mvn-classpath file. (We avoid this command if
# .mvn-classpath is fresh, since it's rather slow.)
if [ ! .mvn-classpath -nt pom.xml ]; then
mvn dependency:build-classpath -Dmdep.outputFile=.mvn-classpath -q
fi
# Now, we set $CP to the contents of the .classpath file.
CP=$(cat .mvn-classpath)
# Again, we're trying to make the script more reusable by guessing the
# package name from the current directory, instead of hard coding.
# But this relies on some conventions in naming. You'll have to call
# your class "Main" and use our recommended package structure.
# (You're free to change that, and then change the ./run script in
# your handin to match.)
PROJECT=$(basename "$(pwd)")
# Find the package that Main is in. TAs use "staff", students should
# rename it to their own username. In the file names and in the source!
# The funny symbol: "$@" passes the command-line arguments on from
# this script to your Java program.
java -ea -cp $TARGET:$CP edu.brown.cs.catan.Main "$@"