#!/bin/bash

set -e

# Check if the jar has been built.
if [ ! -e target/bitcoinj-tools-*.jar ] || [[ "$ALWAYS_BUILD_WALLETTOOL" != "" ]]; then
  echo "Compiling WalletTool to a JAR"
  cd ../core
  mvn install -DskipTests
  cd ../tools
  [ -e target/bitcoinj-tools-*.jar ] && rm target/bitcoinj-tools-*.jar
  mvn package -DskipTests
fi

java -server -jar target/bitcoinj-tools-*.jar $*
