Javicle - a JSON Video Composition Language
Não pode escolher mais do que 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

84 linhas
2.2 KiB

  1. #!/bin/bash
  2. function die () {
  3. echo 1>&2 "${1}"
  4. exit 1
  5. }
  6. function java_major_version () {
  7. for token in $(java -version 2>&1 | grep -i version) ; do
  8. case "${token}" in '"1'*)
  9. echo -n "${token}" | tr -d '"' | awk -F '.' '{print $1}'
  10. esac
  11. done
  12. }
  13. function handle_help_request() {
  14. if [[ -z "${2}" ]]; then
  15. return
  16. fi
  17. if [[ ${2} == "-h" || ${2} == "--help" ]]; then
  18. while IFS='' read -r line || [[ -n "$line" ]]; do
  19. if [[ ${line} =~ ^#.* ]]; then
  20. if [[ ! ${line} =~ ^#!/bin/bash.* ]]; then
  21. echo "${line}"
  22. fi
  23. else
  24. break
  25. fi
  26. done <"${1}"
  27. if [[ -z "${JVCL_SKIP_ENV_VAR_HELP}" ]] ; then
  28. echo "# Environment Variables
  29. #
  30. # JVCL_SCRATCH_DIR : Use this as the scratch directory
  31. # Default is to create a new temp directory
  32. #
  33. # JVCL_NO_EXEC : If set to anything, print the commands that would
  34. # have run but do not execute anything
  35. #
  36. "
  37. fi
  38. exit 1
  39. fi
  40. }
  41. # Ensure Java is installed and that it is Java 11
  42. if [[ -z "$(which java)" ]] ; then
  43. die "Java 11 (or higher) not installed (java command not found on PATH)"
  44. fi
  45. JAVA_VERSION="$(java_major_version)"
  46. if [[ -z "${JAVA_VERSION}" ]] ; then
  47. die "Error determining Java version"
  48. elif [[ ${JAVA_VERSION} -lt 11 ]] ; then
  49. die "Java 11 (or higher) not installed (java -version check failed)"
  50. fi
  51. JVCL_DIR="$(cd "$(dirname "${0}")"/.. && pwd)"
  52. JVCL_JAR="$(find "${JVCL_DIR}"/target -type f -name "jvcl-*-prod.jar" | head -1)"
  53. if [[ -z "${JVCL_JAR}" ]] ; then
  54. # Ensure maven is installed
  55. if [[ -z "$(which mvn)" ]] ; then
  56. die "Maven not installed (mvn command not found on PATH), cannot build JVCL jar"
  57. fi
  58. mvn -DskipTests=true -Puberjar clean package || die "Error building JVCL jar"
  59. JVCL_JAR="$(find "${JVCL_DIR}"/target -type f -name "jvcl-*-prod.jar" | head -1)"
  60. if [[ -z "${JVCL_JAR}" ]] ; then
  61. die "No JVCL jar file found after successful build"
  62. fi
  63. fi
  64. SCRATCH_DIR=""
  65. NO_EXEC=""
  66. if [[ -z "${JVCL_SKIP_ENV_VAR_HELP}" ]] ; then
  67. if [[ -n "${JVCL_SCRATCH_DIR}" ]] ; then
  68. SCRATCH_DIR="--temp-dir ${JVCL_SCRATCH_DIR}"
  69. fi
  70. if [[ -n "${JVCL_NO_EXEC}" ]] ; then
  71. NO_EXEC="--no-exec"
  72. fi
  73. fi
  74. JVCL_OPTIONS="${SCRATCH_DIR} ${NO_EXEC}"
  75. handle_help_request "${0}" "${1}"