Build exist-db on an arm Mac (M1)
This is an attempt of a step-by-step guide on how-to set-up a M1 Mac to build and run exist-db. Special thanks to @duncdrum for helping me get to this point 💯
Corrections, enhancements and other constructive feedback is very much welcome.
Prerequisites
You will need to have brew and git installed in order to follow the steps. We also assume that you did checkout this repository on your local machine.
First, if you tried to build exist-db before you should clean up any leftover artifacts:
- Remove downloaded artifacts in the maven repository
rm -rf ~/.m2/repository
- Go to your git working directory, where you checked out exist-db and remove any leftover
targetdirectories
git clean -dfX
Start here if your local machine is clean:
- Allow brew to install packages in different versions
brew tap homebrew/cask-versions - Install ARM optimised java8
brew install zulu8- (OPTIONAL) Install jenv if you want to have several JDKs installed and switch between them
brew install jenv- (OPTIONAL) Add jenv init to your bash, zsh or fish config
source (jenv init -|psub)- (OPTIONAL) Add zulu8 to jenv
jenv add /opt/homebrew/Caskroom/zulu8/8.0.322,8.60.0.21-ca/- (OPTIONAL) Use java8 globally (as @duncdrum pointed out this could also be done per project)
jenv global 1.8 - Install maven
brew install maven- (OPTIONAL) If you installed jenv in the previous step, tell it to take care of maven
jenv enable-plugin maven
Open a new terminal and make sure that:
JAVA_HOMEpoints to your zulu8 installation (or to jenv)echo $JAVA_HOME- (OPTIONAL) jenv is reporting three times
OK
; jenv doctor [OK] JAVA_HOME variable probably set by jenv PROMPT [OK] Java binaries in path are jenv shims [OK] Jenv is correctly loaded- (OPTIONAL) jenv is reporting three times
- maven uses the correct JDK
; mvn -v Apache Maven 3.8.5 (3599d3414f046de2324203b78ddcf9b5e4388aa0) Maven home: /opt/homebrew/Cellar/maven/3.8.5/libexec Java version: 1.8.0_322, vendor: Azul Systems, Inc., runtime: /Library/Java/JavaVirtualMachines/zulu-8.jdk/Contents/Home/jre Default locale: en_DE, platform encoding: UTF-8 OS name: "mac os x", version: "12.3", arch: "aarch64", family: "Mac"
Now you should be able to build exist-db
mvn clean package
The tests should all pass! But I saw some exceptions about log4j not being able to access or create log files for some extensions.
It took 7:07 minutes to package and test exist-db on my MacBook Pro, so when it works it works fine. Adding -T2C will shave off another 2 minutes and you will likely hear the fans spinning for the first time :)
Thank you very much. Using the java8 for M1 may solve my issue with freezings while using exist a couple of minutes. Will definitely give it a try
@StephanMa what JRE are you using, what version of exist? there should be no freezing with an ARM compatible JRE exist runs smoothly on M1
I would point out the jenv is strongly recommended for devs who require multiple JRE/JDKs on their local machine, but its not necessary. When using jenv zulu8 doesn't have to be configured as global it can be project specific just for exist.
The requirements on M1 aren't that different from Intel machines. You need to have JAVA_HOME set, Java 8 and maven. The only difference is that on M1 it needs to be an ARM friendly Java 8, multiple vendors have that on offer. Installing maven via homebrew has a tendency to install openjdk17 (often non arm) but that's a quirk of homebrew.
@duncdrum I reworked this issue to address your comments.
@line-o as discussed on Slack I made some minor edits. I think that the jenv doctor report is a quirk of fish, on zsh (the default macOS shell) JAVA_HOME is handled properly by jenv.
Two more findings: If you decided to go the jenv route
- add
jenv enable-plugin mavenalso to your shell init script - for ant to work also add
jenv enable-plugin ant