diff --git a/.java-version b/.java-version new file mode 100644 index 000000000000..98d9bcb75a68 --- /dev/null +++ b/.java-version @@ -0,0 +1 @@ +17 diff --git a/README.md b/README.md index 622eed6fa38d..a91e0cbd30c1 100644 --- a/README.md +++ b/README.md @@ -77,11 +77,44 @@ Some suggested improvements with pointers to code are in [TODO.md](TODO.md). ### Development environment C++ and Java building is supported on AlmaLinux 8. -The Java source can also be built on any platform having Java 17 and Maven installed. +The Java source can also be built on any platform having Java 17 and Maven 3.8+ installed. Use the following guide to set up a complete development environment using Docker for building Vespa, running unit tests and running system tests: [Vespa development on AlmaLinux 8](https://github.com/vespa-engine/docker-image-dev#vespa-development-on-almalinux-8). +#### Java environment for Mac +1. Install [JDK17](https://openjdk.org/projects/jdk/17/), + [Maven Version Manager](https://bitbucket.org/mjensen/mvnvm/src/master/) and [jEnv](https://www.jenv.be) + through [Homebrew](https://brew.sh/). +```sh +brew install jenv mvnvm openjdk@17 +``` + +2. For the system Java wrappers to find this JDK, symlink it with +```sh +sudo ln -sfn /opt/homebrew/opt/openjdk@17/libexec/openjdk.jdk /Library/Java/JavaVirtualMachines/openjdk-17.jdk +``` + +3. Follow "Configure your shell" in https://www.jenv.be. Configuration is shell specific. For `zsh` use the below commands: +```sh +echo 'export PATH="$HOME/.jenv/bin:$PATH"' >> ~/.zshrc +echo 'eval "$(jenv init -)"' >> ~/.zshrc +eval "$(jenv init -)" +jenv enable-plugin export +exec $SHELL -l +``` + +4. Add JDK17 to jEnv +```sh +jenv add $(/usr/libexec/java_home -v 17) +``` + +5. Verify configuration with Maven by executing below command in the root of the source code. + Output should refer to the JDK and Maven version specified in the [.java-version](.java-version) and [mvnvm.properties](mvnvm.properties). +```sh +mvn -v +``` + ### Build Java modules export MAVEN_OPTS="-Xms128m -Xmx1024m" diff --git a/mvnvm.properties b/mvnvm.properties new file mode 100644 index 000000000000..38f63fe79206 --- /dev/null +++ b/mvnvm.properties @@ -0,0 +1 @@ +mvn_version=3.9.9