Skip to content

Commit 832cfa9

Browse files
committed
Update pdal-jni exmaples
1 parent c04d412 commit 832cfa9

File tree

4 files changed

+56
-58
lines changed

4 files changed

+56
-58
lines changed

examples/pdal-jni/build.sbt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,11 @@ resolvers ++= Seq(
2121

2222
fork := true
2323

24-
val pdalVersion = "1.7.0-RC4"
24+
val pdalVersion = "1.8.0"
2525

2626
libraryDependencies ++= Seq(
2727
"io.pdal" %% "pdal" % pdalVersion,
2828
"io.pdal" %% "pdal-scala" % pdalVersion,
2929
"io.pdal" % "pdal-native" % pdalVersion,
30-
"org.scalatest" %% "scalatest" % "3.0.5" % Test
30+
"org.scalatest" %% "scalatest" % "3.0.7" % Test
3131
)
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
sbt.version=1.1.4
1+
sbt.version=1.2.8
22

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,2 @@
1-
addSbtPlugin("com.eed3si9n" % "sbt-assembly" % "0.14.6")
2-
addSbtPlugin("com.timushev.sbt" % "sbt-updates" % "0.3.4")
3-
1+
addSbtPlugin("com.eed3si9n" % "sbt-assembly" % "0.14.9")
2+
addSbtPlugin("com.timushev.sbt" % "sbt-updates" % "0.4.0")

examples/pdal-jni/sbt

Lines changed: 51 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@
66

77
set -o pipefail
88

9-
declare -r sbt_release_version="0.13.16"
10-
declare -r sbt_unreleased_version="0.13.16"
9+
declare -r sbt_release_version="1.2.8"
10+
declare -r sbt_unreleased_version="1.2.8"
1111

12-
declare -r latest_213="2.13.0-M2"
13-
declare -r latest_212="2.12.4"
12+
declare -r latest_213="2.13.0-M5"
13+
declare -r latest_212="2.12.8"
1414
declare -r latest_211="2.11.12"
1515
declare -r latest_210="2.10.7"
1616
declare -r latest_29="2.9.3"
@@ -23,7 +23,7 @@ declare -r sbt_launch_ivy_snapshot_repo="https://repo.scala-sbt.org/scalasbt/ivy
2323
declare -r sbt_launch_mvn_release_repo="http://repo.scala-sbt.org/scalasbt/maven-releases"
2424
declare -r sbt_launch_mvn_snapshot_repo="http://repo.scala-sbt.org/scalasbt/maven-snapshots"
2525

26-
declare -r default_jvm_opts_common="-Xms512m -Xmx1536m -Xss2m"
26+
declare -r default_jvm_opts_common="-Xms512m -Xss2m"
2727
declare -r noshare_opts="-Dsbt.global.base=project/.sbtboot -Dsbt.boot.directory=project/.boot -Dsbt.ivy.home=project/.ivy"
2828

2929
declare sbt_jar sbt_dir sbt_create sbt_version sbt_script sbt_new
@@ -43,11 +43,12 @@ declare -a extra_jvm_opts extra_sbt_opts
4343

4444
echoerr () { echo >&2 "$@"; }
4545
vlog () { [[ -n "$verbose" ]] && echoerr "$@"; }
46-
die () { echo "Aborting: $@" ; exit 1; }
46+
die () { echo "Aborting: $*" ; exit 1; }
4747

4848
setTrapExit () {
4949
# save stty and trap exit, to ensure echo is re-enabled if we are interrupted.
50-
export SBT_STTY="$(stty -g 2>/dev/null)"
50+
SBT_STTY="$(stty -g 2>/dev/null)"
51+
export SBT_STTY
5152

5253
# restore stty settings (echo in particular)
5354
onSbtRunnerExit() {
@@ -67,16 +68,18 @@ get_script_path () {
6768
local path="$1"
6869
[[ -L "$path" ]] || { echo "$path" ; return; }
6970

70-
local target="$(readlink "$path")"
71+
local -r target="$(readlink "$path")"
7172
if [[ "${target:0:1}" == "/" ]]; then
7273
echo "$target"
7374
else
7475
echo "${path%/*}/$target"
7576
fi
7677
}
7778

78-
declare -r script_path="$(get_script_path "$BASH_SOURCE")"
79-
declare -r script_name="${script_path##*/}"
79+
script_path="$(get_script_path "${BASH_SOURCE[0]}")"
80+
declare -r script_path
81+
script_name="${script_path##*/}"
82+
declare -r script_name
8083

8184
init_default_option_file () {
8285
local overriding_var="${!1}"
@@ -90,29 +93,14 @@ init_default_option_file () {
9093
echo "$default_file"
9194
}
9295

93-
declare sbt_opts_file="$(init_default_option_file SBT_OPTS .sbtopts)"
94-
declare jvm_opts_file="$(init_default_option_file JVM_OPTS .jvmopts)"
96+
sbt_opts_file="$(init_default_option_file SBT_OPTS .sbtopts)"
97+
jvm_opts_file="$(init_default_option_file JVM_OPTS .jvmopts)"
9598

9699
build_props_sbt () {
97100
[[ -r "$buildProps" ]] && \
98101
grep '^sbt\.version' "$buildProps" | tr '=\r' ' ' | awk '{ print $2; }'
99102
}
100103

101-
update_build_props_sbt () {
102-
local ver="$1"
103-
local old="$(build_props_sbt)"
104-
105-
[[ -r "$buildProps" ]] && [[ "$ver" != "$old" ]] && {
106-
perl -pi -e "s/^sbt\.version\b.*\$/sbt.version=${ver}/" "$buildProps"
107-
grep -q '^sbt.version[ =]' "$buildProps" || printf "\nsbt.version=%s\n" "$ver" >> "$buildProps"
108-
109-
vlog "!!!"
110-
vlog "!!! Updated file $buildProps setting sbt.version to: $ver"
111-
vlog "!!! Previous value was: $old"
112-
vlog "!!!"
113-
}
114-
}
115-
116104
set_sbt_version () {
117105
sbt_version="${sbt_explicit_version:-$(build_props_sbt)}"
118106
[[ -n "$sbt_version" ]] || sbt_version=$sbt_release_version
@@ -157,9 +145,9 @@ addResidual () { vlog "[residual] arg = '$1'" ; residual_args+=("$1"); }
157145
addResolver () { addSbt "set resolvers += $1"; }
158146
addDebugger () { addJava "-Xdebug" ; addJava "-Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=$1"; }
159147
setThisBuild () {
160-
vlog "[addBuild] args = '$@'"
148+
vlog "[addBuild] args = '$*'"
161149
local key="$1" && shift
162-
addSbt "set $key in ThisBuild := $@"
150+
addSbt "set $key in ThisBuild := $*"
163151
}
164152
setScalaVersion () {
165153
[[ "$1" == *"-SNAPSHOT" ]] && addResolver 'Resolver.sonatypeRepo("snapshots")'
@@ -173,7 +161,19 @@ setJavaHome () {
173161
export PATH="$JAVA_HOME/bin:$PATH"
174162
}
175163

176-
getJavaVersion() { "$1" -version 2>&1 | grep -E -e '(java|openjdk) version' | awk '{ print $3 }' | tr -d \"; }
164+
getJavaVersion() {
165+
local -r str=$("$1" -version 2>&1 | grep -E -e '(java|openjdk) version' | awk '{ print $3 }' | tr -d '"')
166+
167+
# java -version on java8 says 1.8.x
168+
# but on 9 and 10 it's 9.x.y and 10.x.y.
169+
if [[ "$str" =~ ^1\.([0-9]+)\..*$ ]]; then
170+
echo "${BASH_REMATCH[1]}"
171+
elif [[ "$str" =~ ^([0-9]+)\..*$ ]]; then
172+
echo "${BASH_REMATCH[1]}"
173+
elif [[ -n "$str" ]]; then
174+
echoerr "Can't parse java version from: $str"
175+
fi
176+
}
177177

178178
checkJava() {
179179
# Warn if there is a Java version mismatch between PATH and JAVA_HOME/JDK_HOME
@@ -194,14 +194,14 @@ checkJava() {
194194
}
195195

196196
java_version () {
197-
local version=$(getJavaVersion "$java_cmd")
197+
local -r version=$(getJavaVersion "$java_cmd")
198198
vlog "Detected Java version: $version"
199-
echo "${version:2:1}"
199+
echo "$version"
200200
}
201201

202202
# MaxPermSize critical on pre-8 JVMs but incurs noisy warning on 8+
203203
default_jvm_opts () {
204-
local v="$(java_version)"
204+
local -r v="$(java_version)"
205205
if [[ $v -ge 8 ]]; then
206206
echo "$default_jvm_opts_common"
207207
else
@@ -243,11 +243,11 @@ execRunner () {
243243

244244
jar_url () { make_url "$1"; }
245245

246-
is_cygwin () [[ "$(uname -a)" == "CYGWIN"* ]]
246+
is_cygwin () { [[ "$(uname -a)" == "CYGWIN"* ]]; }
247247

248248
jar_file () {
249249
is_cygwin \
250-
&& echo "$(cygpath -w $sbt_launch_dir/"$1"/sbt-launch.jar)" \
250+
&& cygpath -w "$sbt_launch_dir/$1/sbt-launch.jar" \
251251
|| echo "$sbt_launch_dir/$1/sbt-launch.jar"
252252
}
253253

@@ -423,7 +423,7 @@ process_args "$@"
423423
readConfigFile() {
424424
local end=false
425425
until $end; do
426-
read || end=true
426+
read -r || end=true
427427
[[ $REPLY =~ ^# ]] || [[ -z $REPLY ]] || echo "$REPLY"
428428
done < "$1"
429429
}
@@ -432,10 +432,10 @@ readConfigFile() {
432432
# can supply args to this runner
433433
if [[ -r "$sbt_opts_file" ]]; then
434434
vlog "Using sbt options defined in file $sbt_opts_file"
435-
while read opt; do extra_sbt_opts+=("$opt"); done < <(readConfigFile "$sbt_opts_file")
435+
while read -r opt; do extra_sbt_opts+=("$opt"); done < <(readConfigFile "$sbt_opts_file")
436436
elif [[ -n "$SBT_OPTS" && ! ("$SBT_OPTS" =~ ^@.*) ]]; then
437437
vlog "Using sbt options defined in variable \$SBT_OPTS"
438-
extra_sbt_opts=( $SBT_OPTS )
438+
IFS=" " read -r -a extra_sbt_opts <<< "$SBT_OPTS"
439439
else
440440
vlog "No extra sbt options have been defined"
441441
fi
@@ -455,19 +455,18 @@ checkJava
455455
setTraceLevel() {
456456
case "$sbt_version" in
457457
"0.7."* | "0.10."* | "0.11."* ) echoerr "Cannot set trace level in sbt version $sbt_version" ;;
458-
*) setThisBuild traceLevel $trace_level ;;
458+
*) setThisBuild traceLevel "$trace_level" ;;
459459
esac
460460
}
461461

462462
# set scalacOptions if we were given any -S opts
463-
[[ ${#scalac_args[@]} -eq 0 ]] || addSbt "set scalacOptions in ThisBuild += \"${scalac_args[@]}\""
463+
[[ ${#scalac_args[@]} -eq 0 ]] || addSbt "set scalacOptions in ThisBuild += \"${scalac_args[*]}\""
464464

465-
# Update build.properties on disk to set explicit version - sbt gives us no choice
466-
[[ -n "$sbt_explicit_version" && -z "$sbt_new" ]] && update_build_props_sbt "$sbt_explicit_version"
465+
[[ -n "$sbt_explicit_version" && -z "$sbt_new" ]] && addJava "-Dsbt.version=$sbt_explicit_version"
467466
vlog "Detected sbt version $sbt_version"
468467

469468
if [[ -n "$sbt_script" ]]; then
470-
residual_args=( $sbt_script ${residual_args[@]} )
469+
residual_args=( "$sbt_script" "${residual_args[@]}" )
471470
else
472471
# no args - alert them there's stuff in here
473472
(( argumentCount > 0 )) || {
@@ -488,6 +487,7 @@ EOM
488487
}
489488

490489
# pick up completion if present; todo
490+
# shellcheck disable=SC1091
491491
[[ -r .sbt_completion.sh ]] && source .sbt_completion.sh
492492

493493
# directory to store sbt launchers
@@ -522,13 +522,13 @@ fi
522522

523523
if [[ -r "$jvm_opts_file" ]]; then
524524
vlog "Using jvm options defined in file $jvm_opts_file"
525-
while read opt; do extra_jvm_opts+=("$opt"); done < <(readConfigFile "$jvm_opts_file")
525+
while read -r opt; do extra_jvm_opts+=("$opt"); done < <(readConfigFile "$jvm_opts_file")
526526
elif [[ -n "$JVM_OPTS" && ! ("$JVM_OPTS" =~ ^@.*) ]]; then
527527
vlog "Using jvm options defined in \$JVM_OPTS variable"
528-
extra_jvm_opts=( $JVM_OPTS )
528+
IFS=" " read -r -a extra_jvm_opts <<< "$JVM_OPTS"
529529
else
530530
vlog "Using default jvm options"
531-
extra_jvm_opts=( $(default_jvm_opts) )
531+
IFS=" " read -r -a extra_jvm_opts <<< "$(default_jvm_opts)"
532532
fi
533533

534534
# traceLevel is 0.12+
@@ -550,13 +550,12 @@ main () {
550550
# we're not going to print those lines anyway. We strip that bit of
551551
# line noise, but leave the other codes to preserve color.
552552
mainFiltered () {
553-
local ansiOverwrite='\r\x1BM\x1B[2K'
554-
local excludeRegex=$(egrep -v '^#|^$' ~/.sbtignore | paste -sd'|' -)
553+
local -r excludeRegex=$(grep -E -v '^#|^$' ~/.sbtignore | paste -sd'|' -)
555554

556555
echoLine () {
557-
local line="$1"
558-
local line1="$(echo "$line" | sed 's/\r\x1BM\x1B\[2K//g')" # This strips the OverwriteLine code.
559-
local line2="$(echo "$line1" | sed 's/\x1B\[[0-9;]*[JKmsu]//g')" # This strips all codes - we test regexes against this.
556+
local -r line="$1"
557+
local -r line1="${line//\r\x1BM\x1B\[2K//g}" # This strips the OverwriteLine code.
558+
local -r line2="${line1//\x1B\[[0-9;]*[JKmsu]//g}" # This strips all codes - we test regexes against this.
560559

561560
if [[ $line2 =~ $excludeRegex ]]; then
562561
[[ -n $debugUs ]] && echo "[X] $line1"
@@ -573,7 +572,7 @@ mainFiltered () {
573572
# Obviously this is super ad hoc but I don't know how to improve on it. Testing whether
574573
# stdin is a terminal is useless because most of my use cases for this filtering are
575574
# exactly when I'm at a terminal, running sbt non-interactively.
576-
shouldFilter () { [[ -f ~/.sbtignore ]] && ! egrep -q '\b(shell|console|consoleProject)\b' <<<"${residual_args[@]}"; }
575+
shouldFilter () { [[ -f ~/.sbtignore ]] && ! grep -E -q '\b(shell|console|consoleProject)\b' <<<"${residual_args[@]}"; }
577576

578577
# run sbt
579578
if shouldFilter; then mainFiltered; else main; fi

0 commit comments

Comments
 (0)