Search code examples
mavenazure-devopsmaven-2

Download dependency from remote maven repository


I have the following pom.xml file which requires downloading various dependencies from azure feed.

pom.xml

When I want to execute mvn install, I get the next error:

Execution rest-server-generation of goal org.openapitools:openapi-generator-maven-plugin:6.4.0:generate failed: Plugin org.openapitools:openapi-generator-maven-plugin:6.4.0 or one of its dependencies could not be resolved: Could not find artifact pe.com.pichincha:mic-libs-openapi-generator:jar:1.0.0-SNAPSHOT in sonatype-snapshots (https://oss.sonatype.org/content/repositories/snapshots

The Dependency pe.com.pichincha:mic-libs-openapi-generator:jar:1.0.0-SNAPSHOT exists in azure feed. I think the error is because it is not looking for the dependency in the azure feed repository it looks for it in https://oss.sonatype.org/content/repositories/snapshots

I don't know why this happens, with other applications I just need to put these lines in the pom.xml file to look for dependencies in the azure feed repository.

  <repositories> 
      <repository> 
          <id>t002</id> 
          <url>https://pkgs.dev.azure.com/gz1606/u-devops/_packaging/t002/maven/v1</url> 
      </repository> 
  </repositories>

Solution

  • You need enable repository for SNAPSHOT versions.

    When you want to use additional repository for plugin you need a pluginRepositories

    Pom reference

    So your config can look like:

    For project dependencies:

    
    <repositories> 
      <repository> 
        <id>t002</id> 
        <url>https://pkgs.dev.azure.com/gz1606/u-devops/_packaging/t002/maven/v1</url>
        <releases>
          <enabled>true</enabled>
        </releases>
        <snapshots>
          <enabled>true</enabled>
        <snapshots>
      </repository> 
    </repositories>
    

    and for plugins:

    <pluginRepositories> 
      <pluginRepository> 
        <id>t002</id> 
        <url>https://pkgs.dev.azure.com/gz1606/u-devops/_packaging/t002/maven/v1</url>
        <releases>
          <enabled>true</enabled>
        </releases>
        <snapshots>
          <enabled>true</enabled>
        <snapshots>
      </pluginRepository> 
    </pluginRepositories>