Search code examples
mavenartifactory

Maven - multiple private repositories in Artifactory


I have already working project which downloading .jar bundles from private repositories in Artifactory, and I'm trying to add another repository from which maven will donwload regular maven dependencies.

I've added repository tag to my parent's POM

    <repository>
      <id>MyId-1</id>
      <url>https://artifactory-url/artifactory/Myfolder-1/</url>
      <layout>default</layout>
    </repository>

to settings.xml

    <server>
      <id>MyId-1</id>
      <username>{username}</username>
      <password>{password}</password>
    </server>

But it still not found my expected dependencies.

Also in my settings.xml has defined proxy mirror to Artifactory:

  <mirrors>
    <mirror>
      <id>MyId-2</id>
      <mirrorOf>central</mirrorOf>
      <name>MyName-2</name>
      <url>https://artifactory-url/artifactory/Myfolder-2/</url>
    </mirror>
  </mirrors>

And when i change mirror's URL to my expected URL:

https://artifactory-url/artifactory/Myfolder-1/

Maven successfully downloading my expected dependencies, but doesn't download all others jars.

I also have tried add another one mirror to my settings.xml, and my mirrors tag looks like:

  <mirrors>
    <mirror>
      <id>MyId-2</id>
      <mirrorOf>central</mirrorOf>
      <name>MyName-2</name>
      <url>https://artifactory-url/artifactory/Myfolder-2/</url>
    </mirror>
    <mirror>
      <id>MyId-1</id>
      <mirrorOf>*</mirrorOf>
      <name>MyName-1</name>
      <url>https://artifactory-url/artifactory/Myfolder-1/</url>
    </mirror>
  </mirrors>

But maven ignores it and I'm getting error when trying mvn install:

Could not find artifact {my-artifact}:pom:{version} in artifactory (https://artifactory-url/artifactory/Myfolder-2/)
The POM for {my-artifact}:jar:{version} is missing, no dependency information available

Solution

  • Seems like mirror tag messed everything up. Resolved this : Removed mirroring central, and added to active profile both folders with jars, so now my repositories tag in settings.xml is :

        <repository>
            <id>MyId-1</id>
            <url>https://artifactory-url/artifactory/Myfolder-1/</url>
        </repository>
        <repository>
              <id>central</id>
              <url> https://artifactory-url/artifactory/Myfolder-2/ </url>
        <repository>