Skip to content

Instantly share code, notes, and snippets.

@tresf
Last active November 22, 2020 01:22
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tresf/d3ea928895320f2f44196f270d8ef9f0 to your computer and use it in GitHub Desktop.
Save tresf/d3ea928895320f2f44196f270d8ef9f0 to your computer and use it in GitHub Desktop.
####################################################################
# #
# EXPERIMENTAL STEPS FOR FORCING HOMEBREW TO USE A 3RD-PARTY JDK #
# #
# USE AT YOUR OWN RISK #
# #
#################################################################$##
# We'll grab a stop-gap openjdk and save it to ~/Applications/openjdk
mkdir -p ~/Applications/openjdk
#### SKIP THIS ####
# Microsof's JDK is broken, Microsoft has been contacted about this.
# MYJDK=https://github.com/microsoft/openjdk-aarch64/releases/download/16-ea%2B10-macos/jdk-16-ea+10-macos+aarch64.tar.gz
# curl -sL $MYJDK | tar xvz --strip 1 -C ~/Applications/openjdk
#### USE THIS ####
# Get Zulu's JDK instead (it's not a tarball, so it can't easily be scripted, sorry!)
# - Manually download from here: https://cdn.azul.com/zulu/bin/zulu11.43.1007-ca-jdk11.0.9.1-macos_aarch64.zip
# - Extract to ~/Applications/
# - Rename from "zulu11.43.1007-ca-jdk11.0.9.1-macos_aarch64" to "openjdk"
# If needed, unquarantine
sudo xattr -r -d com.apple.quarantine ~/Applications/openjdk
# Get homebrew ready
sudo mkdir -p /opt/homebrew && sudo chown -R $(whoami):staff /opt/homebrew
curl -L https://github.com/Homebrew/brew/tarball/master | tar xz --strip 1 -C /opt/homebrew
# Add homebrew to your path
echo -e "\nexport PATH=\"/opt/homebrew/bin:\$PATH\"" >> ~/.zshrc
source ~/.zshrc
# Initialize brew
brew upgrade
#### SKIP THIS ####
# Microsof's JDK is broken, Microsoft has been contacted about this.
# Symlink stop-gap Microsoft openjdk
# ln -s ~/Applications/openjdk/Contents/Home /opt/homebrew/opt/openjdk
#### USE THIS ####
# Symlink stop-gap Zulu openjdk
ln -s ~/Applications/openjdk /opt/homebrew/opt/openjdk
# Let /usr/libexec/java_home know about it too (Maven needs this)
export JAVA_HOME=$(brew --prefix openjdk)
# Install ant without dependencies
brew install --ignore-dependencies ant
# Verify ant is working
ant -version
# Install maven without dependencies
brew install --ignore-dependencies maven
# Verify maven is working
mvn -version
# Install gradle without dependencies
brew install --ignore-dependencies gradle
# Verify gradle is working
gradle -version
# To revert
brew uninstall ant maven gradle
rm /opt/homebrew/opt/openjdk
rm -rf ~/Applications/openjdk
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment