0

A few days ago I created a Github Package for a java library. Now I wanted to add the dependency from Github Packages to another Maven Project, but I get the following error:

Could not transfer artifact io.geilehner:storyblok-java-sdk:pom:1.0.1 from/to github (https://maven.pkg.github.com/geilix10/): Transfer failed for https://maven.pkg.github.com/geilix10/io/geilehner/storyblok-java-sdk/1.0.1/storyblok-java-sdk-1.0.1.pom 400 Bad Request

My ~/.m2/settings.xml

<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>github</id>
          <username>geilix10</username>
          <password>ghp__ PERSONAL_ACCESS_TOKEN....</password>
        </server>
      </servers>
    </settings>

My pom.xml from the project where I want to add my package.

<repositories>
    <repository>
        <id>github</id>
        <url>https://maven.pkg.github.com/geilix10/</url>
    </repository>
</repositories>

and the dependency itself:

<dependency>
            <groupId>io.geilehner</groupId>
            <artifactId>storyblok-java-sdk</artifactId>
            <version>1.0.1</version>
        </dependency>

I need the repository tag in the pom.xml because later on GitHub Actions should build this project and otherwise it would not find the package. Link to the package: https://github.com/geilix10/storyblok-java-sdk/packages/716104?version=1.0.1

#Edit

After adjusting my settings.xml to (as suggested):

<?xml version="1.0" encoding="UTF-8"?>
<settings>
    <activeProfiles>
        <activeProfile>default</activeProfile>
    </activeProfiles>
    <servers>
        <server>
            <id>github</id>
            <username>geilix10</username>
            <password>TOKEN</password>
        </server>
    </servers>
    <profiles>
        <profile>
            <id>default</id>
            <repositories>
                <repository>
                    <id>github</id>
                    <name>GitHub Apache Maven Packages</name>
                    <url>https://maven.pkg.github.com/geilix10/*</url>
                    <snapshots>
                        <enabled>false</enabled>
                    </snapshots>
                </repository>
            </repositories>
        </profile>
    </profiles>
</settings>

And my pom.xml :

<repositories>
    <repository>
        <id>github</id>
        <url>https://maven.pkg.github.com/geilix10/storyblok-java-sdk/</url>
    </repository>
</repositories>
<dependency>
    <groupId>io.geilehner</groupId>
    <artifactId>storyblok-java-sdk</artifactId>
    <version>1.0.1</version>
</dependency>

And using the command to retrieve the package suggested by Allen D. I receive the following error message:

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-dependency-plugin:3.1.2:get (default-cli) on project regiolix: Couldn't download artifact: org.eclipse.aether.resolution.DependencyResolutionException: Failed to read artifact descriptor for io.geilehner:storyblok-java-sdk:jar:1.0.1: Could not transfer artifact io.geilehner:storyblok-java-sdk:pom:1.0.1 from/to github (https://maven.pkg.github.com/geilix10/): Failed to transfer file https://maven.pkg.github.com/geilix10/io/geilehner/storyblok-java-sdk/1.0.1/storyblok-java-sdk-1.0.1.pom with status code 400 -> [Help 1]
Markus G.
  • 1,620
  • 2
  • 25
  • 49

1 Answers1

1

Explicitly add your repository to the URLs.

In your settings.xml:

      <repositories>                                                            
        ...                                                           
        <repository>                                                            
          <id>github</id>                                                                         
          <url>https://maven.pkg.github.com/geilix10/*</url>                  
          <snapshots>                                                           
            <enabled>true</enabled>                                             
          </snapshots>                                                          
        </repository>
        ...

(Snapshots setting as you need...)

In you POM:

<repositories>
    <repository>
        <id>github</id>
        <url>https://maven.pkg.github.com/geilix10/storyblok-java-sdk/</url>
    </repository>
</repositories>

Refer to https://github.com/allen-ball/ganymede for reference.

I was able to download your artifact with:

mvn dependency:get -DremoteRepositories=https://maven.pkg.github.com/geilix10/storyblok-java-sdk -Dartifact=io.geilehner:storyblok-java-sdk:1.0.1

after updating my settings.xml with:

<?xml version="1.0" encoding="UTF-8"?>                                          
<settings ...>                                                                  
  <activeProfiles>                                                              
    <activeProfile>default</activeProfile>                                      
  </activeProfiles>                                                             
  <servers>                                                                     
    <server>                                                                    
      <id>github</id>                                                           
      <username>allen-ball</username>                                           
      <password>REDACTED</password>                                             
    </server>                                                                   
    ...                                                                         
  </servers>                                                                    
  <profiles>                                                                    
    <profile>                                                                   
      <id>default</id>                                                          
      ...                                                                       
      <repositories>                                                            
        ...                                                                     
        <repository>                                                            
          <id>github</id>                                                       
          <name>GitHub Apache Maven Packages</name>                             
          <url>https://maven.pkg.github.com/geilix10/*</url>                    
          <snapshots>                                                           
            <enabled>true</enabled>                                             
          </snapshots>                                                          
        </repository>                                                           
        ...                                                                     
      </repositories>                                                           
      ...                                                                       
    </profile>                                                                  
  </profiles>                                                                   
</settings>
Allen D. Ball
  • 1,916
  • 1
  • 9
  • 16
  • Unfortunately the same error message is shown. Could not transfer artifact io.geilehner:storyblok-java-sdk:pom:1.0.1 from/to github (https://maven.pkg.github.com/geilix10/storyblok-java-sdk/): Transfer failed for https://maven.pkg.github.com/geilix10/storyblok-java-sdk/io/geilehner/storyblok-java-sdk/1.0.1/storyblok-java-sdk-1.0.1.pom 400 Bad Request. Just curious... are you able to install it? – Markus G. Apr 12 '21 at 16:03
  • Updated answer above. – Allen D. Ball Apr 12 '21 at 16:15
  • I'm sorry -- I'm at a loss. The one practical difference in my configuration is I have my PAT encrypted with a Maven master password in my settings.xml but I don't see how that would matter. I suggest you examine your PAT, make sure package:read is set, and possible regenerate with all privileges as an experiment. – Allen D. Ball Apr 13 '21 at 14:25