Skip to content

Instantly share code, notes, and snippets.

@orpiske
Last active Jul 2, 2022
Embed
What would you like to do?
Maven Daemon install script
#!/bin/sh
MAVEN_DAEMON_VERSION=0.8.0
GRAALVM_VERSION=22.1.0
GRAALVM_JAVA_VERSION=17
function prepare() {
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() {
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}
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}
cp -R dist/target/mvnd-${MAVEN_DAEMON_VERSION}-darwin-aarch64 ${HOME}/.local/opt/mvnd-${MAVEN_DAEMON_VERSION}
cd .. && rm -rf maven-mvnd
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"
}
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