pbhle
pbhle

Reputation: 2936

Use only local maven repository for needed jars

Is it possible to first download jars needed to orgnisation local maven repository and then to machine repository to use.

my scenario is:

1.My project is using abc.jar and it is not exist on my local repository then I want it to download from public repository to orgnisation local maven repository first.

2.And then my project will use this abc.jar from orgnisation local maven repository.

is it possible or I want to deploy manually each jar to orgnisation local maven repository.

Because right now if my project need any jar then it finds it on local maven repository if not found then download it directly to my local machine ~/.m2/repository folder. I want to download first to orgnisation local repository and then my local machine. Now my Settings.xml look like:

<?xml version="1.0" encoding="UTF-8"?>
<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">

  <servers>

  <server>
      <id>local.orgnisation.repo</id>
      <username>pallavi</username>
      <password>pallavi</password>
    </server>
    </servers>

<mirrors>
    <mirror>
      <id>local.orgnisation.repo</id>
      <name>Local repository</name>
      <url>http://local.orgnisation.repo/artifactory/repo</url>
      <mirrorOf>central</mirrorOf>
    </mirror>
  </mirrors>

<!--<profiles>
    <profile>
      <id>default</id>
      <repositories>
          <repository>
              <id>local.orgnisation.repo</id>
              <url>http://local.orgnisation.repo/artifactory/repo</url>
          </repository>
      </repositories>
        </profile>
  </profiles>-->
    <activeProfiles>
    <activeProfile>default</activeProfile>
  </activeProfiles>

</settings>

I am using artifactory repository manager. Any help will be appreciated.

Thanks,

Upvotes: 2

Views: 5803

Answers (1)

bstick12
bstick12

Reputation: 1749

You need to create a mirror entry in your Maven settings.xml for the central repository

http://maven.apache.org/guides/mini/guide-mirror-settings.html

<mirror>
  <id>local</id>
  <mirrorOf>central</mirrorOf>
  <url>URL of your artifactory repository</url>
</mirror>

Upvotes: 1

Related Questions