Skip to content

Commit fec2888

Browse files
committed
Remove call to scala in dotr
1 parent faf0ff0 commit fec2888

File tree

1 file changed

+31
-3
lines changed

1 file changed

+31
-3
lines changed

bin/dotr

Lines changed: 31 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,40 @@ if [[ "$DOTTY_ROOT" == "" ]]; then
77
fi
88
DOTTY_ROOT="$(dirname "$DOTTY_ROOT")"
99
DOTTY_ROOT="$( cd "$DOTTY_ROOT" >& /dev/null && pwd )/.." # absolute
10+
SCALA_VERSION=$(grep "scalaVersion in" "$DOTTY_ROOT/project/Build.scala"|sed -n 's/.*\"\(.*\)\".*/\1/'p)
1011

11-
# CLASS_PATH is derived from the DOTTY_ROOT
12-
CLASS_PATH="-J-Xbootclasspath/a:.:$DOTTY_ROOT/target/scala-2.11/classes/"
12+
function find_jar {
13+
# Usage:
14+
# find_jar path/to/location file.jar
15+
local artifact="$1/$2"
16+
17+
if [ ! -f "$artifact" ]; then
18+
artifact=$(find "$HOME/.coursier/cache" -iname "$2")
19+
fi
20+
21+
echo "$artifact"
22+
}
23+
24+
# Autodetecting the scala-library location, in case it wasn't provided by an environment variable
25+
if [ "$SCALA_LIBRARY_JAR" == "" ]; then
26+
SCALA_LIBRARY_JAR=$(find_jar "$HOME/.ivy2/cache/org.scala-lang/scala-library/jars" "scala-library-$SCALA_VERSION.jar")
27+
fi
28+
29+
# CLASS_PATH is derived from the DOTTY_ROOT and SCALA_LIBRARY_JAR
30+
CLASS_PATH="-Xbootclasspath/a:.:$DOTTY_ROOT/target/scala-2.11/classes/:.:$SCALA_LIBRARY_JAR"
1331

1432
function runMain {
15-
scala $CLASS_PATH $@
33+
local jbin=$(which "java")
34+
35+
if [ ! -z "$JAVA_BIN" ]; then
36+
jbin=$JAVA_BIN
37+
fi
38+
39+
if [ "$jbin" == "" ]; then
40+
echo "java bin not detected - please specify with \$JAVA_BIN or install java to a default location"
41+
else
42+
eval "$jbin $CLASS_PATH $@"
43+
fi
1644
}
1745

1846
if [ -z "$1" ]; then

0 commit comments

Comments
 (0)