<commit_before><commit_msg>Add a script to build BookKeeper.<commit_after>#!/bin/bash

set -x

CWD=$(pwd)

echo "${CWD}"
java -version

usage() {
  echo "usage: $0 [release-type]"
}

release_type="$1"

if [[ -z "${release_type}" ]]; then
  usage
  exit 1
fi

current_branch=$(git rev-parse --abbrev-ref HEAD)

case "${release_type}" in
  netty*)
    if [[ "${current_branch}" != "NettyReleaseBranch" ]]; then
      echo "To build netty you need to be on NettyReleaseBranch"
      exit 1
    fi
    mvn -Pnative -Pzk3.4 -Ptwitter-science-provider clean package
    ;;
  ql*)
    if [[ "${current_branch}" != "QLReleaseBranch" ]]; then
      echo "To build ql you need to be on QLReleaseBranch"
      exit 1
    fi
    mvn -Pnative -Ptwitter-science-provider clean package
    ;;
  *)
    echo "Unknown target"
    exit 1
    ;;
esac

dist="dist"
mkdir -p "${dist}" "${dist}/conf" "${dist}/target" "${dist}/bin" "${dist}/lib"

cp bookkeeper-server/lib/* "${dist}/lib/"
cp bookkeeper-server/bin/bookkeeper "${dist}/bin"
cp bookkeeper-server/conf/bk_server.conf "${dist}/conf/"

echo "#!/bin/bash

java -cp target/*:lib/* org.apache.bookkeeper.bookie.BookieShell -conf ./conf/bk_server.conf $@" > "${dist}/bkshell"

chmod +x bkshell

mkdir -p "${dist}/lib/native"

bkversion=$(grep "version>.*</version" bookkeeper-server/pom.xml  | awk -F '[><]' '{print $3}'|head -1)

cp "bookkeeper-server/target/bookkeeper-server-${bkversion}.jar" "${dist}/target"

if [ -f "bookkeeper-server/target/native/target/usr/local/lib/libbookkeeper.so.1.0.0" ]; then
  cp "bookkeeper-server/target/native/target/usr/local/lib/libbookkeeper.so.1.0.0" "$dist/lib/native/libbookkeeper.so.1.0.0"
  ln -s bookkeeper-server/lib/native/libbookkeeper.so.1.0.0 "$dist/lib/native/libbookkeeper.so"
fi

pushd "${dist}"
chmod +x "bin/bookkeeper"

zip -r bookkeeper-server-deploy.zip .

if [[ ! -f bookkeeper-server-deploy.zip ]] || [[ ! -s bookkeeper-server-deploy.zip ]]; then
    echo "failed to build the artifact"
    exit 1
fi

popd
{'fraction_non_alphanumeric': 0.18040979510244878, 'fraction_numerical': 0.011494252873563218, 'mean_word_length': 3.55, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 6, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 1}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5288756', 'n_tokens_mistral': 758, 'n_tokens_neox': 730, 'n_words': 166}