#!/bin/bash

# conda-build should be taking care of this, but do it anyway
export JAVA_HOME="${PREFIX}"
export ANT_HOME="${PREFIX}"

./refine build
./refine server_test

# mac_dist tries to make a dmg, but linux_dist works on mac too
./refine "linux_dist" "${PKG_VERSION}"

# extract the tarball, but remove version name
tar -xf "${SRC_DIR}/dist/openrefine-linux-${PKG_VERSION}.tar.gz" -C "${PREFIX}"
mv "${PREFIX}/openrefine-${PKG_VERSION}" "${PREFIX}/openrefine"

# entry point
cat <<'EOF' > "${PREFIX}/bin/refine"
#!/bin/bash
"${CONDA_PREFIX}/openrefine/refine" "$@"
EOF

chmod +x "${PREFIX}/bin/refine"
