Skip to content

Commit ec1fafe

Browse files
committed
fix security issue of zinc
1 parent f38594f commit ec1fafe

File tree

1 file changed

+24
-7
lines changed

1 file changed

+24
-7
lines changed

build/mvn

Lines changed: 24 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -139,8 +139,17 @@ if [ "$1" == "--force" ]; then
139139
shift
140140
fi
141141

142+
if [ "$1" == "--zinc" ]; then
143+
echo "Using zinc for incremental compilation. Be sure you are aware of the implications of "
144+
echo "running this server process on your machine"
145+
USE_ZINC=1
146+
shift
147+
fi
148+
142149
# Install the proper version of Scala, Zinc and Maven for the build
143-
install_zinc
150+
if [ -n "${USE_ZINC}" ]; then
151+
install_zinc
152+
fi
144153
install_scala
145154
install_mvn
146155

@@ -149,12 +158,15 @@ cd "${_CALLING_DIR}"
149158

150159
# Now that zinc is ensured to be installed, check its status and, if its
151160
# not running or just installed, start it
152-
if [ -n "${ZINC_INSTALL_FLAG}" -o -z "`"${ZINC_BIN}" -status -port ${ZINC_PORT}`" ]; then
153-
export ZINC_OPTS=${ZINC_OPTS:-"$_COMPILE_JVM_OPTS"}
154-
"${ZINC_BIN}" -shutdown -port ${ZINC_PORT}
155-
"${ZINC_BIN}" -start -port ${ZINC_PORT} \
156-
-scala-compiler "${SCALA_COMPILER}" \
157-
-scala-library "${SCALA_LIBRARY}" &>/dev/null
161+
if [ -n "${USE_ZINC}" ]; then
162+
if [ -n "${ZINC_INSTALL_FLAG}" -o -z "`"${ZINC_BIN}" -status -port ${ZINC_PORT}`" ]; then
163+
export ZINC_OPTS=${ZINC_OPTS:-"$_COMPILE_JVM_OPTS"}
164+
"${ZINC_BIN}" -shutdown -port ${ZINC_PORT}
165+
"${ZINC_BIN}" -start -port ${ZINC_PORT} -server 127.0.0.1 \
166+
-idle-timeout 30m \
167+
-scala-compiler "${SCALA_COMPILER}" \
168+
-scala-library "${SCALA_LIBRARY}" &>/dev/null
169+
fi
158170
fi
159171

160172
# Set any `mvn` options if not already present
@@ -164,3 +176,8 @@ echo "Using \`mvn\` from path: $MVN_BIN" 1>&2
164176

165177
# Last, call the `mvn` command as usual
166178
"${MVN_BIN}" -DzincPort=${ZINC_PORT} "$@"
179+
180+
if [ -n "${USE_ZINC}" ]; then
181+
# Try to shut down zinc explicitly
182+
"${ZINC_BIN}" -shutdown -port ${ZINC_PORT}
183+
fi

0 commit comments

Comments
 (0)