Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Maven: local versus remote repository

Tags:

maven

This may well have been asked before (so apologies in advance if it has been - I just haven't found the right question yet!)

I'm working on a project with two Maven repositories: a local one (on my machine) and an internal one (on a central server). There are quite a few projects kicking around, and one parent project that uses all of them. When we're done working on a particular project, we install it to the central repository for everyone else to use.

When I build the parent project for local testing, I'd like to use the most up to date versions of each project:

  • if someone has updated a project in the central repository, I'd like to use that one
  • if I have changed a project locally and installed it into my local repository, I'd like that to override the centralised one.

What I'm seeing is the build completely ignoring my local repository and just grabbing everything from the internal one. Have I missed a setting somewhere obvious? Or is this just the way things work?

like image 901
nihilogist Avatar asked Oct 23 '22 13:10

nihilogist


1 Answers

mvn -o will take you into offline mode so nothing is downloaded.

Or in your settings.xml set the update policy to not always for snapshots or releases. See here and relevant section below

<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0
                      http://maven.apache.org/xsd/settings-1.0.0.xsd">
  ...
  <profiles>
    <profile>
      ...
      <repositories>
        <repository>
          <id>codehausSnapshots</id>
          <name>Codehaus Snapshots</name>
          <releases>
            <enabled>false</enabled>
            <updatePolicy>always</updatePolicy> 
            <checksumPolicy>warn</checksumPolicy>
          </releases>
          <snapshots>
            <enabled>true</enabled>
            <updatePolicy>never</updatePolicy>
            <checksumPolicy>fail</checksumPolicy>
          </snapshots>
          <url>http://snapshots.maven.codehaus.org/maven2</url>
          <layout>default</layout>
        </repository>
      </repositories>
      <pluginRepositories>
        ...
      </pluginRepositories>
      ...
    </profile>
  </profiles>
  ...
</settings>
like image 57
Usman Ismail Avatar answered Oct 31 '22 09:10

Usman Ismail