nhplus/bin/make/check.sh

70 lines
2.3 KiB
Bash
Raw Permalink Normal View History

2024-04-10 14:03:19 +00:00
#!/bin/bash
source bin/make/colors.sh
printf "${BLUE_BG} ${CLEAR}\n"
printf "${BLUE_BG}${BLACK_FG} Checking Requirements ${CLEAR}\n"
printf "${BLUE_BG} ${CLEAR}\n"
# Check Jenv
command -v jenv >/dev/null 2>&1 || \
{ \
printf >&2 "${RED_FG}✘ Jenv${YELLOW_FG} is ${RED_FG}not installed${YELLOW_FG}! \n"; \
exit 1; \
}
printf >&2 "${GREEN_FG}✔ Jenv${BLUE_FG} is ${GREEN_FG}installed${BLUE_FG}.\n"
# Check Jenv Maven plugin
jenv plugins | grep -q 'maven' >/dev/null 2>&1 || \
{ \
printf >&2 "${RED_FG}✘ Jenv Maven Plugin${YELLOW_FG} is ${RED_FG}not installed${YELLOW_FG}! \n"; \
exit 1; \
}
printf >&2 "${GREEN_FG}✔ Jenv Maven Plugin${BLUE_FG} is ${GREEN_FG}installed${BLUE_FG}.\n"
# Check Jenv Maven plugin is Enabled
jenv plugins --enabled | grep -q 'maven' >/dev/null 2>&1 || \
{ \
printf >&2 "${RED_FG}✘ Jenv Maven Plugin${YELLOW_FG} is ${RED_FG}not enabled${YELLOW_FG}! \n"; \
exit 1; \
}
printf >&2 "${GREEN_FG}✔ Jenv Maven Plugin${BLUE_FG} is ${GREEN_FG}enabled${BLUE_FG}.\n"
# Check Maven
command -v mvn >/dev/null 2>&1 || \
{ \
printf >&2 "${RED_FG}✘ Maven${YELLOW_FG} is ${RED_FG}not installed${YELLOW_FG}! \n"; \
exit 1; \
}
printf >&2 "${GREEN_FG}✔ Maven${BLUE_FG} is ${GREEN_FG}installed${BLUE_FG}.\n"
# Check XML Lint
command -v xmllint >/dev/null 2>&1 || \
{ \
printf >&2 "${RED_FG}✘ XML Lint{YELLOW_FG} is ${RED_FG}not installed${YELLOW_FG}!\n Install it via DNF, APT or Brew.\n"; \
exit 1; \
}
printf >&2 "${GREEN_FG}✔ XML Lint${BLUE_FG} is ${GREEN_FG}installed${BLUE_FG}.\n"
# Check Java Version
required_java_version=$( \
xmllint --xpath "string(./project/component[@languageLevel]/@languageLevel)" .idea/misc.xml \
| cut -c 5- \
) && \
current_java_version=$( \
java -version 2>&1 \
| awk -F '"' '/version/ {print $2}' \
) && \
current_major_java_version=$( \
echo ${current_java_version} \
| cut -d '.' -f 1\
) && \
[ "${current_major_java_version}" = "${required_java_version}" ] || \
{ \
printf >&2 "${RED_FG}✘ Wrong Java Version${YELLOW_FG} is installed!\n Version ${RED_FG}${required_java_version}${YELLOW_FG} is ${RED_FG}required${YELLOW_FG}.\n"; \
exit 1; \
} && \
printf >&2 "${GREEN_FG}✔ Java${BLUE_FG} Version ${GREEN_FG}${current_major_java_version}${BLUE_FG} is ${GREEN_FG}installed${BLUE_FG}.\n"