AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |
Back to Blog
Switch java version mac11/11/2023 Configure the maven-toolchains-plugin to use a specific JDK in the toolchain as configured in your toolchains.xml file.Add the maven-toolchains-plugin in your project POM.Few other things to do though as detailed in the toolchain documentation ![]() ![]() OS name: "mac os x", version: "13.1", arch: "aarch64", family: "mac" Java version: 17.0.3.1, vendor: Oracle Corporation, runtime: /Library/Java/JavaVirtualMachines/jdk-17.0.3.1.jdk/Contents/Homeĭefault locale: en_US, platform encoding: UTF-8 Maven home: /opt/homebrew/Cellar/maven/3.8.7/libexec JAVA_HOME="$" exec "/opt/homebrew/Cellar/maven/3.8.7/libexec/bin/mvn" save the mvn file after edit With this new found knowledge, I run nano /usr/local/Cellar/maven/3.5.4/bin/mvn This is usually in /usr/local/Cellar/maven/3.5.4 Given, my installation was done using brew - Brew is simply a package manager for Mac OS, my M2_HOME was automatically set up. To my surprise, maven began using java10 as its default java version, even though my JAVA_HOME is set to use java8 - /usr/libexec/java_home -v 1.8 Once I did this and tried running existing projects which use java8. Recently installed Java10 to see whats new and fun about it. ![]() Sort of like when you define JDK on project level in IDE. It allows you to define what different JDKs Maven can use to build the project irrespective of the JDK Maven runs with. So I added a toolchains.xml file to my ~/.m2/ folder with following content: Maven has it even documented and supports it from 2.0.9 - toolchains documentation I just recently, after seven long years with Maven, learned about toolchains.xml.
0 Comments
Read More
Leave a Reply. |