automatic version determine

This commit is contained in:
overflowerror 2018-07-10 21:49:26 +02:00
parent e7ce527aba
commit 61a756eea4
2 changed files with 42 additions and 0 deletions

View file

@ -1,9 +1,13 @@
#!/bin/bash
DEPLOY=$1
VERSIONS=./versions
EXIT_SUCCESS=0
EXIT_COMPILE_FAILED=1
EXIT_PACKING_FAILED=2
EXIT_INSTRUMENTATION_FAILED=3
EXIT_READY_FAILED=4
mkdir -p ../bin/
mkdir -p ../build/
@ -11,28 +15,61 @@ mkdir -p ../build/NurseBot_lib/
pushd ../src/
echo "Building... "
javac -cp $(find ../build/NurseBot_lib -iname "*.jar" | tr "\n" ":") -d ../bin/ $(find ./ -iname "*.java")
if test ! $? = 0; then
echo "... failed"
exit $EXIT_COMPILE_FAILED
fi
echo "... done"
popd
pushd ../bin/
echo "Packing jar..."
jar cmf ../buildtools/MANIFEST.MF ../build/NurseBot.jar $(find ./ -iname "*.class")
if test ! $? = 0; then
echo "... failed"
exit $EXIT_PACKING_FAILED
fi
echo "... done"
popd
echo "Building instrumentation..."
./instrumentation.sh
if test ! $? = 0; then
echo "... failed"
exit $EXIT_INSTRUMENTATION_FAILED
fi
echo "... done"
echo "Copying instrumentation..."
cp ../bin/activejdbc_models.properties ../build/
if test ! $? = 0; then
echo "... failed"
exit $EXIT_INSTRUMENTATION_FAILED
fi
echo "... done"
pushd ../build
echo "Determine version..."
version=$(java -jar NurseBot.jar -v)
echo "This is version $version."
if test ! "$DEPLOY" = ""; then
echo "Set to deploy..."
cp NurseBot.jar $DEPLOY/$VERSERIONS
if test ! $? = 0; then
echo "... failed"
exit $EXIT_READY_FAILED
fi
echo "... done"
fi
echo "Overall done."
popd
exit $EXIT_SUCCESS

View file

@ -44,6 +44,11 @@ public class NurseNoakes extends TelegramLongPollingBot {
private static final int EXIT_CODE_INSTRUMENTATION_MISSING = 10;
public static void main(String[] args) {
if (Arrays.asList(args).contains("-v")) {
System.out.println(VERSION);
System.exit(0);
}
ApiContextInitializer.init();
TelegramBotsApi botsApi = new TelegramBotsApi();