Home > Net >  Artifact cannot be resolved from gitlab repository - only in pom.xml, while GET works?
Artifact cannot be resolved from gitlab repository - only in pom.xml, while GET works?

Time:03-29

I created a commons artifact in a gitlab repository.

I can already download the artifact from within a webbrowser:

https://git.my-company.com/api/v4/projects/295/packages/maven/com/example/hello-commons/1.0.0/hello-commons-1.0.0.jar

But when I try letting maven fetch the dependency, I get the following error:

[WARNING] The POM for com.example:hello-commons:jar:1.0.0 is missing, no dependency information available Downloading from gitlab-maven: https://git.my-company.com/api/v4/projects/295/packages/maven/com/example/hello-commons/1.0.0/hello-commons-1.0.0.jar

This is my pom.xml, what might be missing?

<repositories>
    <repository>
        <id>gitlab-maven</id>
        <url>https://git.my-company.com/api/v4/projects/295/packages/maven</url>
    </repository>
</repositories>
<distributionManagement>
    <repository>
        <id>gitlab-maven</id>
        <url>https://git.my-company.com/api/v4/projects/295/packages/maven</url>
    </repository>
</distributionManagement>

CodePudding user response:

I didn't know that a private token has to be set into ~/.m2/settings.xml as follows:

<settings>
  <servers>
    <server>
      <id>gitlab-maven</id>
      <configuration>
        <httpHeaders>
          <property>
            <name>Private-Token</name>
            <value>PRIVATE_TOKEN_UUID</value>
          </property>
        </httpHeaders>
      </configuration>
    </server>
  </servers>
</settings>

The token must be of scope read_api.

CodePudding user response:

Check in your local m2 repository (C:\Users\YourUserName.m2\repository) If the folder com/example/hello-commons has been created. If the folder created but download failed it won't retry for a while. Try to delete that folder and run your maven build again

  • Related