10raw
10raw

Reputation: 574

how to build maven with any version on demand?

I have a situation where my system has one maven installed (e.g version 3.7.1. I have some projects that needs that version so this version is my default and if I build a project using mvn the version 3.7.1 is used by default to build the project. Now I have to work on a project where it needs maven version 3.8.1 and I am looking for a way to do it. I am planning to install the maven version 3.8.1 in same system and would like to call this maven while building the new project. Can anyone help me on how to add envionment variable for new maven and call it whenever necessary while building without removing the 3.7.1 version

Upvotes: 0

Views: 47

Answers (2)

Moritz
Moritz

Reputation: 2526

Aside from having separate Maven installations on your system, you could also have a look at the Maven Wrapper.

The maven wrapper allows you to attach a small script to your code base, which downloads and runs a specific version of Maven. In this way there are no dependencies to any Maven installations on your system.

After placing the Maven Wrapper in your project, you would then simply run ./mvnw install instead of mvn install.

Upvotes: 1

Dmitry Rakovets
Dmitry Rakovets

Reputation: 589

I am using SDKMAN to manage different versions of maven or java. SDKMAN is a tool for managing parallel versions of multiple Software Development Kits on most Unix based systems. It provides a convenient Command Line Interface (CLI) and API for installing, switching, removing and listing Candidates.

It is very convenient and this problem no longer exists for me.

Upvotes: 0

Related Questions