How do I install Maven with Yum?

Malvolio picture Malvolio · Sep 23, 2011 · Viewed 216.4k times · Source

I'm trying not to learn much about either yum or maven. I've inherited this code and I don't want to spend more time than I have to in this environment.

I've got yum. My installation "has" ("is attached too"? "knows about"?) two repos: the Amazon one and JPackage, which I understand is something of a standard. (Actually, each of those repositories consists of two sub-repositories, but I don't think that's causing the problem.)

When I asked yum to install maven2, it declined, saying it had never heard of maven2.

When I asked yum to install maven2 ignoring Amazon, it does so, but it installs Maven 2.0.9, which is fairly old. The actual pom.xml I have requires a higher version.

When I Google for Maven repositories I get repositories that Maven can use to build other things, not repositories that Yum can use to install Maven. (I did find a repository containing thing that let Maven build Yum. I think Google is mocking me at this point.)

So, all I need is the repo file that points to a repo that contains whatever I need to install Maven 2.2.1.

If it weren't for all these labor-saving devices, I could probably get some work done.

Answer

OrwellHindenberg picture OrwellHindenberg · Aug 22, 2012

Icarus answered a very similar question for me. Its not using "yum", but should still work for your purposes. Try,

wget http://mirror.olnevhost.net/pub/apache/maven/maven-3/3.0.5/binaries/apache-maven-3.0.5-bin.tar.gz

basically just go to the maven site. Find the version of maven you want. The file type and use the mirror for the wget statement above.

Afterwards the process is easy

  1. Run the wget command from the dir you want to extract maven too.
  2. run the following to extract the tar,

    tar xvf apache-maven-3.0.5-bin.tar.gz
    
  3. move maven to /usr/local/apache-maven

    mv apache-maven-3.0.5  /usr/local/apache-maven
    
  4. Next add the env variables to your ~/.bashrc file

    export M2_HOME=/usr/local/apache-maven
    export M2=$M2_HOME/bin 
    export PATH=$M2:$PATH
    
  5. Execute these commands

    source ~/.bashrc

6:. Verify everything is working with the following command

    mvn -version