smali

понедельник, 27 февраля 2017 г.

Ubuntu 12.04 - Installing both maven3 and maven2 as alternatives


http://dev-maziarz.blogspot.nl/2012/09/ubuntu-1204-installing-both-maven3-and.html



Maven and /etc/alternatives


Ubuntu 12.04 comes with maven 3.0.4 as a default - that's great, but not for those who still needs maven 2.x. Unfortunately maven2 package can be installed can be installed only as the maven3 replacement - for those needed both, that sounds rather poor solution. Luckly there is /etc/alternatives mechanism that is perfect in such a case. It basically allows us having both with relativly easy way. But in that case alternatives does not work out of the box. The only way to handle this is installing maven2 binaries manually and register it as an alternative for mvn command.

How to do this - step by step solution: 

  1. Lets start with installing maven3 (3.0.4-2)
    $ sudo apt-get install maven
  2. Once done we look at recently installed mvn using update-alternatives command.
    $ update-alternatives --list mvn
     /usr/share/maven/bin/mvn
    $ update-alternatives --display mvn
    mvn - auto mode
      link currently points to /usr/share/maven/bin/mvn
    /usr/share/maven/bin/mvn - priority 150
      slave mvn.1.gz: /usr/share/maven/man/mvn.1.gz
      slave mvnDebug: /usr/share/maven/bin/mvnDebug
      slave mvnDebug.1.gz: /usr/share/maven/man/mvnDebug.1.gz
    Current 'best' version is '/usr/share/maven/bin/mvn'.
    Optionally fix the mvnDebug link into /usr/bin/mvnDebug
    ln -s /etc/alternatives/mvnDebug /usr/bin/mvnDebug
  3. Download maven 2 and extract it into /usr/share/maven2 folder.
  4. # cd /usr/share && wget http://archive.apache.org/dist/maven/binaries/apache-maven-2.2.1-bin.tar.gz
    
    # tar xzvf apache-maven-2.2.1-bin.tar.gz && mv apache-maven-2.2.1 maven2 && rm apache-maven-2.2.1-bin.tar.gz
    
  5. Add alternatives
    # update-alternatives --install /usr/bin/mvn mvn /usr/share/maven2/bin/mvn 200 --slave /usr/bin/mvnDebug mvnDebug /usr/share/maven2/bin/mvnDebug
    
    Priority 200 as a greater then 150 makes maven2 it the default (auto).

  1. Now you can display current alternatives for mvn command
    $ update-alternatives --display mvn
    mvn - auto mode
      link currently points to /usr/share/maven2/bin/mvn
    /usr/share/maven/bin/mvn - priority 150
      slave mvn.1.gz: /usr/share/maven/man/mvn.1.gz
      slave mvnDebug: /usr/share/maven/bin/mvnDebug
      slave mvnDebug.1.gz: /usr/share/maven/man/mvnDebug.1.gz
    /usr/share/maven2/bin/mvn - priority 200
      slave mvnDebug: /usr/share/maven2/bin/mvnDebug
    Current 'best' version is '/usr/share/maven2/bin/mvn'.
    
  2. In order to switch between maven versions use
     # update-alternatives --config mvn
    
  3. The same way you can add 3.2 release:
    # update-alternatives --install /usr/bin/mvn mvn /usr/share/maven32/bin/mvn 320 --slave /usr/bin/mvnDebug mvnDebug /usr/share/maven32/bin/mvnDebug
    

1 комментарий:

  1. Thank you for taking the time to provide us with your valuable information. We strive to provide our candidates with excellent care and we take your comments to heart.As always, we appreciate your confidence and trust in us.

    Best Dental Clinic In OMR

    ОтветитьУдалить