Search code examples
javamavenpom.xml

Update Maven Version


How can we update the version of maven in a java project.

I have tried changing the version in pom.xml file but that is leading to build failures when PR is raised. What other things can be done to change the version?

I want to change this and update the version to 3.8.8

<requireMavenVersion>
   <version>3.3.9</version>
</requireMavenVersion>

Solution

  • What you want to do cannot be done. Maven cannot update itself. You ... and the other people building your project ... will need to update the version of Maven in the normal way:

    • If you / they are running builds on workstations, etc, use the platform's package installer or whatever to update Maven,

    • If you are doing builds on a CI system, you may need to update the installed Maven on the CI server. Ask the admin to do it.

    • If you are publishing your project, put the required Maven version into the project's build instructions / README file.


    Does that mean if once we have used a certain maven version for a project (in this case a remote repository), we will have to stick to that version forever

    No ...

    and if we want to change the version we can only do it individually by installing the required version?

    Yes. Or on the CI server if that is what you are using.

    You should avoid specifying a tight Maven version constraint in your POM file. Use version ranges (see the documentation) ... or no version constraint at all. (Typically, Maven builds are largely insensitive to the Maven version that is used.)


    How can we update the CI to have a new version of Maven?

    Read the CI system documentation. That will explain what you need to do. Or talk to the person who manages it for you.