1

I'm trying to build maven from source (on Ubuntu 12.04) following the tutorial:

http://maven.apache.org/guides/development/guide-building-m2.html

I installed a previous version of maven using

sudo apt-get install maven

I then checked out maven using:

git clone https://git-wip-us.apache.org/repos/asf/maven.git maven

I then built maven using maven according to the apache guide, so I cd into the checkout version of maven and did:

sudo mvn install

this seemed to work fine, no errors or anything, but when I do

mvn -version

My output is:

Apache Maven 3.0.4
Maven home: /usr/share/maven
Java version: 1.7.0_40, vendor: Oracle Corporation
Java home: /usr/lib/jvm/jdk1.7.0_40/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "linux", version: "3.5.0-37-generic", arch: "amd64", family: "unix"

Which is not the version I checked out, it's the version of maven I got from apt-get. What exactly did mvn install do? Where did it install maven to, and how do I update the mvn command?

I've been digging through the output of mvn-install . It seems it's creating jar files, for example, some of the outputs are:

[INFO] Installing /opt/maven/maven-core/target/maven-core-3.1-SNAPSHOT.jar to /root/.m2/repository/org/apache/maven/maven-core/3.1-SNAPSHOT/maven-core-3.1-SNAPSHOT.jar
[INFO] Installing /opt/maven/maven-core/pom.xml to /root/.m2/repository/org/apache/maven/maven-core/3.1-SNAPSHOT/maven-core-3.1-SNAPSHOT.pom

if I cd into /root/.m2/repository/org/apache/maven/maven-core and do a ls -la

I see

drwxr-xr-x  9 root root 4096 Sep 25 15:31 .
drwxr-xr-x 33 root root 4096 Sep 25 15:31 ..
drwxr-xr-x  2 root root 4096 Sep 25 15:30 2.0
drwxr-xr-x  2 root root 4096 Sep 25 15:30 2.0.1
drwxr-xr-x  2 root root 4096 Sep 25 15:30 2.0.6
drwxr-xr-x  2 root root 4096 Sep 25 15:30 2.0.9
drwxr-xr-x  2 root root 4096 Sep 25 15:31 2.2.1
drwxr-xr-x  2 root root 4096 Sep 25 15:30 3.0
drwxr-xr-x  2 root root 4096 Sep 25 15:31 3.1-SNAPSHOT

The last entry seems really suspicious. If I change directory into that and list it's contents I see:

-rw-r--r-- 1 root root 557420 Sep 26 08:45 maven-core-3.1-SNAPSHOT.jar
-rw-r--r-- 1 root root   7270 Sep 26 08:44 maven-core-3.1-SNAPSHOT.pom
-rw-r--r-- 1 root root    706 Sep 26 08:45 maven-metadata-local.xml
-rw-r--r-- 1 root root    186 Sep 26 08:45 _maven.repositories

Which is different then what the contents of

/root/.m2/repository/org/apache/maven/maven-core/3.0

are. They are:

-rw-r--r-- 1 root root 6629 Sep 25 15:30 maven-core-3.0.pom
-rw-r--r-- 1 root root   40 Sep 25 15:30 maven-core-3.0.pom.sha1
-rw-r--r-- 1 root root  154 Sep 25 15:30 _maven.repositories

1 Answer 1

1

Heh. 99% there, but stopped by the doorman. If you meant what you said, the problem is mvn install which doesn't install mvn. Man pages say maven has no "install" switch. It should have printed a "how's that?" error. Bad maven.

The canonical build-from-source routine goes like this, from the appropriate directory:

./configure
make
sudo make install

Make install (d'oh!). Note the sudo, meaning, root privileges for you from now on, I'm sure you know.

I've never built maven myself, but after that last step I should expect to find the new program somewhere in /usr/local. /usr/local/share, in this case? With any luck, just mvn from the command line should find the new one after installing, and that's what you want of course. If not, you'll have to adjust your $PATH environment variable, and perhaps your library search configuration, but let's hope that's unnecessary.

1
  • Thanks for your help! Unfortunately there doesn't seem to be a ./configure nor a make file in the maven directory. It seems you build maven differently then other software. I did some digging and updated my question.
    – Alexander
    Sep 26, 2013 at 16:06

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .