How do I prevent Maven from downloading artifacts every time?

Dave picture Dave · Feb 24, 2014 · Viewed 73.8k times · Source

I’m using Maven 3.1.1. In one of my projects, I reference another one of my projects …

    <dependencies>
            <dependency>
                    <groupId>org.mainco.subco</groupId>
                    <artifactId>myprojectA</artifactId>
                    <version>${project.version}</version>
            </dependency>

The above is dependent on a couple other of my projects. However, when I run “mvn clean install,” Maven attempts to download these artifacts instead of just using what’s in my local repository. How do I get Maven to only download things if they do not exist in my local repository? Here’s the output of what I’m seeing …

davea$ mvn clean install
[INFO] Scanning for projects...
[INFO]                                                                         
[INFO] ------------------------------------------------------------------------
[INFO] Building subco admin Module 57.0.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
Downloading: http://download.java.net/maven/2/org/mainco/subco/myprojectA/57.0.0-SNAPSHOT/maven-metadata.xml
Downloading: http://download.java.net/maven/2/org/mainco/subco/subco/57.0.0-SNAPSHOT/maven-metadata.xml
Downloading: http://download.java.net/maven/2/org/mainco/subco/projectB/57.0.0-SNAPSHOT/maven-metadata.xml
Downloading: http://download.java.net/maven/2/org/mainco/subco/projectC/57.0.0-SNAPSHOT/maven-metadata.xml
[INFO]

Answer

jayalalk picture jayalalk · Feb 24, 2014

If you use offline flag it will use your libraries from local repo.

mvn clean install -o