Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why does maven 2 try to download dependencies that I already have?

Tags:

java

maven-2

When I launch the "mvn install" command, maven sometimes tries to download dependencies that it has already downloaded. That's expected for SNAPSHOT but why does maven do that for other JARs?

I know I can avoid that behavior by "-o" flag but I just wonder what the cause is.

like image 532
paulgreg Avatar asked Sep 24 '08 11:09

paulgreg


People also ask

Why does Maven download dependencies every time?

When you run a Maven build, then Maven automatically downloads all the dependency jars into the local repository. It helps to avoid references to dependencies stored on remote machine every time a project is build. Maven local repository by default get created by Maven in %USER_HOME% directory.

Does Maven automatically download compile dependencies?

Maven's local repository is a directory on the local machine that stores all the project artifacts. When we execute a Maven build, Maven automatically downloads all the dependency jars into the local repository.

Why Maven dependencies are not getting downloaded?

If you run Maven and it fails to download your required dependencies it's likely to be caused by your local firewall & HTTP proxy configurations. See the Maven documentation for details of how to configure the HTTP proxy.

How do I delete and redownload Maven dependencies?

In Maven, you can use Apache Maven Dependency Plugin, goal dependency:purge-local-repository to remove the project dependencies from the local repository, and re-download it again.


3 Answers

I'd look for dependencies that don't have a specified version number. Maven will periodically check to make sure that it has the most up-to-date version of these artifacts.

like image 62
Steve Moyer Avatar answered Sep 24 '22 23:09

Steve Moyer


This is probably not what you're seeing, but in the past I've had to manually install artifacts into my local repository and if you forget to include the -Dgenerate.pom=true option there will be no pom in the repo for that artifact and Maven will go out to central (and any other remote repos you have configured) to try to download that pom on every build.

like image 32
Mike Deck Avatar answered Sep 22 '22 23:09

Mike Deck


While we're on the subject of this, I've run into a major bug in Maven 2.0.x. In offline mode, maven will still attempt to download the latest snapshot, and when it can't find your snapshot repo, it fails the build. Imagine the hilarity that ensues when this happens on site with a client and you just needed to make a small change (but I digress).

Here's the bug: http://jira.codehaus.org/browse/MNG-2433 here's a workaround: http://mail-archives.apache.org/mod_mbox/maven-users/200601.mbox/%[email protected]%3E

like image 42
Spencer Kormos Avatar answered Sep 23 '22 23:09

Spencer Kormos