2014-05-20 12:46:19 +02:00
|
|
|
#!/bin/bash -e
|
2014-05-21 06:35:28 +02:00
|
|
|
EXAMPLE_MAP=(
|
|
|
|
'spdy-server:io.netty.example.spdy.server.SpdyServer'
|
|
|
|
'spdy-client:io.netty.example.spdy.client.SpdyClient'
|
|
|
|
'http2-server:io.netty.example.http2.server.Http2Server'
|
|
|
|
'http2-client:io.netty.example.http2.client.Http2Client'
|
2014-05-20 16:24:34 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
EXAMPLE=''
|
|
|
|
EXAMPLE_CLASS=''
|
2014-05-21 06:35:28 +02:00
|
|
|
EXAMPLE_ARGS='-D_'
|
2014-05-20 16:24:34 +02:00
|
|
|
I=0
|
|
|
|
|
|
|
|
while [[ $# -gt 0 ]]; do
|
|
|
|
ARG="$1"
|
|
|
|
shift
|
|
|
|
if [[ "$ARG" =~ (^-.+) ]]; then
|
2014-05-21 06:35:28 +02:00
|
|
|
EXAMPLE_ARGS="$EXAMPLE_ARGS $ARG"
|
2014-05-20 16:24:34 +02:00
|
|
|
else
|
|
|
|
EXAMPLE="$ARG"
|
2014-05-21 06:35:28 +02:00
|
|
|
for E in "${EXAMPLE_MAP[@]}"; do
|
|
|
|
KEY="${E%%:*}"
|
|
|
|
VAL="${E##*:}"
|
|
|
|
if [[ "$EXAMPLE" == "$KEY" ]]; then
|
|
|
|
EXAMPLE_CLASS="$VAL"
|
|
|
|
break
|
|
|
|
fi
|
|
|
|
done
|
2014-05-20 16:24:34 +02:00
|
|
|
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
|
2014-05-20 16:38:53 +02:00
|
|
|
echo " $0 -Dhost=127.0.0.1 -Dport=8009 echo-client" >&2
|
2014-05-20 12:46:19 +02:00
|
|
|
echo >&2
|
|
|
|
echo "Available examples:" >&2
|
2014-05-20 16:38:53 +02:00
|
|
|
echo >&2
|
2014-05-21 06:35:28 +02:00
|
|
|
for E in "${EXAMPLE_MAP[@]}"; do
|
|
|
|
echo " ${E%%:*}"
|
2014-05-20 16:24:34 +02:00
|
|
|
done | sort >&2
|
2014-05-20 16:38:53 +02:00
|
|
|
echo >&2
|
2014-05-20 12:46:19 +02:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2014-05-20 16:24:34 +02:00
|
|
|
cd "`dirname "$0"`"/example
|
|
|
|
echo "[INFO] Running: $EXAMPLE ($EXAMPLE_CLASS $EXAMPLE_ARGS)"
|
2014-05-21 10:29:18 +02:00
|
|
|
exec mvn -nsu compile exec:exec -DargLine.example="$EXAMPLE_ARGS" -DexampleClass="$EXAMPLE_CLASS"
|
2014-05-20 12:46:19 +02:00
|
|
|
|