Created
September 23, 2022 15:35
-
-
Save orpiske/a4b66233ac6073ba3e62e53e8a350af3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
MAVEN_DAEMON_VERSION=0.8.1 | |
GRAALVM_VERSION=22.2.0 | |
GRAALVM_JAVA_VERSION=17 | |
function prepare() { | |
echo "Preparing" | |
unset JAVA_HOME | |
brew install --cask graalvm/tap/graalvm-ce-java${GRAALVM_JAVA_VERSION} | |
xattr -r -d com.apple.quarantine /Library/Java/JavaVirtualMachines/graalvm-ce-java${GRAALVM_JAVA_VERSION}-${GRAALVM_VERSION} | |
export JAVA_HOME=/Library/Java/JavaVirtualMachines/graalvm-ce-java${GRAALVM_JAVA_VERSION}-${GRAALVM_VERSION}/Contents/Home | |
export PATH=${JAVA_HOME}/bin:${PATH} | |
gu install native-image | |
} | |
function install() { | |
echo "Installing" | |
export JAVA_HOME=/Library/Java/JavaVirtualMachines/graalvm-ce-java${GRAALVM_JAVA_VERSION}-${GRAALVM_VERSION}/Contents/Home | |
export PATH=${JAVA_HOME}/bin:${PATH} | |
cd $TMPDIR | |
[[ -d maven-mvnd ]] && rm -rf maven-mvnd | |
git clone https://github.com/apache/maven-mvnd.git --branch ${MAVEN_DAEMON_VERSION} | |
local mavenMvndDir=${TMPDIR}/maven-mvnd/dist/target/maven-mvnd-${MAVEN_DAEMON_VERSION}-darwin-aarch64 | |
cd maven-mvnd && mvn -B -Dlicense.skip -DskipTests clean verify -Pnative | |
mkdir -p "${HOME}/.local/opt" | |
[[ -d ${HOME}/.local/opt/mvnd-${MAVEN_DAEMON_VERSION} ]] && rm -rf ${HOME}/.local/opt/mvnd-${MAVEN_DAEMON_VERSION} | |
if [[ ! -d ${mavenMvndDir} ]] ; then | |
echo "Maven daemon directory does not exist at ${mavenMvndDir}" | |
return 1 | |
fi | |
cp -R ${mavenMvndDir} ${HOME}/.local/opt/mvnd-${MAVEN_DAEMON_VERSION} | |
if [[ $? -ne 0 ]] ; then | |
echo "Failed to copy Maven Daemon to the installation directory at ${mavenMvndDir}" | |
return 1 | |
else | |
echo "Apache Maven Daemon ${MAVEN_DAEMON_VERSION} installed to ${HOME}/.local/opt/mvnd-${MAVEN_DAEMON_VERSION}" | |
echo "Just add the ${HOME}/.local/opt/mvnd-${MAVEN_DAEMON_VERSION}/bin to the PATH of your system and it should work" | |
fi | |
cd .. && rm -rf maven-mvnd | |
} | |
function clean() { | |
brew uninstall graalvm-ce-java${GRAALVM_JAVA_VERSION} || true | |
[[ -f "${HOME}/.local/opt/mvnd-${MAVEN_DAEMON_VERSION}" ]] && rm -rf "${HOME}/.local/opt/mvnd-${MAVEN_DAEMON_VERSION}" | |
} | |
if [[ $1 == "prepare" ]] ; then | |
prepare | |
else | |
if [[ $1 == "install" ]] ; then | |
install | |
else | |
if [[ $1 == "all" ]] ; then | |
prepare | |
install | |
else | |
if [[ $1 == "clean" ]] ; then | |
clean | |
else | |
echo "Invalid command: use: ./install.sh [command]" | |
echo "Commands: prepare, install, all or clean" | |
exit 1 | |
fi | |
fi | |
fi | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment