3e8c80a26f
Motivation: exec-maven-plugin does not flush stdout and stderr, making the console output from the examples invisible to users Modification: Use maven-antrun-plugin instead Result: A user sees the output from the examples immediately.
65 lines
1.5 KiB
Bash
Executable File
65 lines
1.5 KiB
Bash
Executable File
#!/bin/bash -e
|
|
EXAMPLE_MAP=(
|
|
'spdy-client:io.netty.example.spdy.client.SpdyClient'
|
|
'spdy-server:io.netty.example.spdy.server.SpdyServer'
|
|
'http2-client:io.netty.example.http2.client.Http2Client'
|
|
'http2-server:io.netty.example.http2.server.Http2Server'
|
|
)
|
|
|
|
EXAMPLE=''
|
|
EXAMPLE_CLASS=''
|
|
EXAMPLE_ARGS='-D_'
|
|
I=0
|
|
|
|
while [[ $# -gt 0 ]]; do
|
|
ARG="$1"
|
|
shift
|
|
if [[ "$ARG" =~ (^-.+) ]]; then
|
|
EXAMPLE_ARGS="$EXAMPLE_ARGS $ARG"
|
|
else
|
|
EXAMPLE="$ARG"
|
|
for E in "${EXAMPLE_MAP[@]}"; do
|
|
KEY="${E%%:*}"
|
|
VAL="${E##*:}"
|
|
if [[ "$EXAMPLE" == "$KEY" ]]; then
|
|
EXAMPLE_CLASS="$VAL"
|
|
break
|
|
fi
|
|
done
|
|
break
|
|
fi
|
|
done
|
|
|
|
if [[ -z "$EXAMPLE" ]] || [[ -z "$EXAMPLE_CLASS" ]] || [[ $# -ne 0 ]]; then
|
|
echo " Usage: $0 [-D<name>[=<value>] ...] <example-name>" >&2
|
|
echo "Example: $0 -Dport=8443 -Dssl http-server" >&2
|
|
echo " $0 -Dhost=127.0.0.1 -Dport=8009 echo-client" >&2
|
|
echo >&2
|
|
echo "Available examples:" >&2
|
|
echo >&2
|
|
I=0
|
|
for E in "${EXAMPLE_MAP[@]}"; do
|
|
if [[ $I -eq 0 ]]; then
|
|
echo -n ' '
|
|
fi
|
|
|
|
printf '%-24s' "${E%%:*}"
|
|
((I++)) || true
|
|
|
|
if [[ $I -eq 2 ]]; then
|
|
I=0
|
|
echo
|
|
fi
|
|
done >&2
|
|
if [[ $I -ne 0 ]]; then
|
|
echo >&2
|
|
fi
|
|
echo >&2
|
|
exit 1
|
|
fi
|
|
|
|
cd "`dirname "$0"`"/example
|
|
echo "[INFO] Running: $EXAMPLE ($EXAMPLE_CLASS $EXAMPLE_ARGS)"
|
|
exec mvn -nsu compile antrun:run -Dcheckstyle.skip=true -Dantfile=src/antrun/run-example.xml -DargLine.example="$EXAMPLE_ARGS" -DexampleClass="$EXAMPLE_CLASS"
|
|
|