|
209 | 209 | if [ $(grep "^// DEPS" ${scriptFile} | wc -l) -gt 0 ]; then |
210 | 210 | echo "[ERROR] Dependencies must be declared by using the line prefix //DEPS" 1>&2; exit 1; |
211 | 211 | fi |
212 | | -dependencies=$(grep "^//DEPS" ${scriptFile} | cut -f2- -d' ' | trim | tr ',;\n' ' ') |
| 212 | + |
| 213 | +## find all //DEPS directives and concatenate their values |
| 214 | +dependencies=$(grep "^//DEPS" ${scriptFile} | cut -f2- -d' ' | trim | tr ',;\n' ' ' | sed 's/ $//g') |
213 | 215 |
|
214 | 216 |
|
215 | 217 | ## First try dependency cache directly to avoid jvm launch for resdeps.kts |
216 | | -# fix me more consistent use of ${TMPDIR} |
217 | 218 | dependency_cache="${KSCRIPT_CACHE_DIR}/dependency_cache.txt" |
218 | 219 | if [ -n "$dependencies" ] && [ -f "$dependency_cache" ]; then |
219 | | - classpath=$(grep -F $(echo ${dependencies} | tr ' ' ';')" " ${dependency_cache} | cut -d' ' -f2) |
| 220 | +# https://stackoverflow.com/questions/22861580/bash-script-check-if-a-file-contains-a-specific-line |
| 221 | + depQuery="$(echo ${dependencies} | tr ' ' ';')" |
| 222 | + classpath=$(awk '$1 == "'$depQuery'"' ${dependency_cache} | cut -d' ' -f2) |
220 | 223 | fi |
221 | 224 |
|
222 | 225 | ## If there are dependencies but cache-lookup failed we run resdeps.kts |
@@ -289,16 +292,12 @@ elif [[ $scriptFileExt == ".kt" ]]; then |
289 | 292 | fi |
290 | 293 |
|
291 | 294 |
|
292 | | -echo "classpath is '${classpath}'" |
293 | | - |
294 | | - |
295 | 295 | # build cache-jar if it does not yet exist |
296 | 296 | if [ ! -f "${jarFile}" ]; then |
297 | 297 | ## remove previous (now outdated) cache jars |
298 | 298 | rm -f .$(basename ${scriptFile} .kts).*.jar |
299 | 299 |
|
300 | 300 |
|
301 | | - echo "kotlinc -classpath "${classpath}" -d ${jarFile} ${scriptFile}" |
302 | 301 | kotlinc -classpath "${classpath}" -d ${jarFile} ${scriptFile} |
303 | 302 |
|
304 | 303 | if [ $? -eq 1 ]; then |
|
0 commit comments