↓ Skip to main content
Java

Tip #Maven

·1 min

A decent developer trick is to ensure your maven points to the right JAVA version, and if you have freshly installed maven it will be pointing to the default available.

On my system’s dev or otherwise I normally take the help of the profile.d directory to allow me set the custom version.

This directory defines a system-wide behavior.

I created a maven.sh in this folder & put the contents as below

export JAVA_HOME=/usr/lib/jvm/java-11-openjdk-11.0.16.1.1-1.el7_9.x86_64
export M2_HOME=/usr/share/maven
export MAVEN_HOME=/usr/share/maven
export PATH=${M2_HOME}/bin:${PATH}

Then source it source /etc/profile.d/maven.sh

Once you do that you can validate the mvn --version

Apache Maven 3.0.5 (Red Hat 3.0.5-17)
Maven home: /usr/share/maven
Java version: 11.0.16.1, vendor: Red Hat, Inc.
Java home: /usr/lib/jvm/java-11-openjdk-11.0.16.1.1-1.el7_9.x86_64
Default locale: en_US, platform encoding: UTF-8
OS name: "linux", version: "3.10.0-1160.76.1.el7.x86_64", arch: "amd64", family: "unix"
Author
Samarthya
Engineer, learner, tinkerer. This is my trophy shelf of everyday work and leisure.

Related

Building your artifact(s)

·7 mins
Everything starts form a single source file and as the time goes by, it gradually transforms into multiple modules, bulky source files and a source control repository. Mostly by this time the team has already adopted a a build tool, and a repository to publish the versioned artifacts. Journey is similar for every project successful or not.

Maven Profiles

·2 mins
The concept of profiles let’s a developer define what he wants to build and what to do in specific cases. In this blog I will talk about the problem that I solved using profiles.

Maven: Lifecycles

·9 mins
If you have worked with big projects you must have encountered pom.xml the central configuration for your projects that helps you build, test, and define your CI pipeline. There are other options that are available too, but that is for some other day.