Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Add local repository to maven settings.xml

Tags:

maven

I have a local repository on my machine. I need to add it to maven's settings.xml. All the examples I've found online look like this:

<settings>
  <profiles>
    <profile>
      <id>myprofile</id>
      <repositories>
        <repository>
          <id>androidsupport</id>
          <name>Android Support</name>
          <url>http://www.whatever.com/maven2/</url>
        </repository>
     </repositories>
    </profile>

      <activeProfiles>
        <activeProfile>myprofile</activeProfile>
      </activeProfiles>
  </profiles>
</settings>

I need to point it to a local repo. How can I do that?

like image 232
ConditionRacer Avatar asked May 17 '16 21:05

ConditionRacer


People also ask

What is local repository in settings xml?

The Local Repository 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. Usually, this directory is named . m2.

Where should I put Maven settings xml?

The Maven settings file, settings. xml , is usually kept in the . m2 directory inside your home directory.

How do I access my local Maven repository?

1) Maven Local Repository By default, maven local repository is %USER_HOME%/. m2 directory. For example: C:\Users\SSS IT\. m2.


1 Answers

I think you can do it via adding into settings.xml this:

<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">
      <localRepository>C:/MyLocalRepository</localRepository>
</settings>

More details you can find there.

To add more internal repositories you can use:

<project>
  ...
  <repositories>
    <repository>
      <id>my-internal-site</id>
      <url>file:///C:/MyLocalRepository</url>
    </repository>
  </repositories>
  ...
</project>

More details you can find there.

like image 106
RMachnik Avatar answered Sep 28 '22 07:09

RMachnik