Maven Resolver Cannot Get Github Private Repo Dependency

I have 2 private repos in 2 IntelliJ IDEA projects:

  • core-java
  • main-cloud (which has other sub maven projects)
    • main-common

I can easily build and deploy the core-java project and its artifacts upload to the github private repo with NO issues:
clean source:jar deploy -DuniqueVersion=false -Dmaven.source.useDefaultManifestFile=true -DdeplyAtEnd=true -Dmaven.source.includePom=true -Dmaven.install.skip=true -X

However, if I try to build and deploy the main-cloud project I get the error that the dependency core-java cannot be obtained:
Could not transfer artifact org.core:core-java:pom:1.0.24-20210118.053141-1 from/to github-core-java (https://maven.pkg.github.com/owner/core-java): Transfer failed for https://maven.pkg.github.com/owner/core-java/org/core/core-java/1.0.24-SNAPSHOT/core-java-1.0.24-20210118.053141-1.pom 400 Bad Request

A more detailed view of the error is as follows:

[ERROR] Failed to execute goal on project main-common: Could not resolve dependencies for project co.main:main-common:jar:0.0.4-SNAPSHOT: Failed to collect dependencies at org.core:core-java:jar:1.0.24-SNAPSHOT: Failed to read artifact descriptor for org.core:core-java:jar:1.0.24-SNAPSHOT: Could not transfer artifact org.core:core-java:pom:1.0.24-20210118.053141-1 from/to github-core-java (https://maven.pkg.github.com/owner/core-java): Transfer failed for https://maven.pkg.github.com/owner/core-java/org/core/core-java/1.0.24-SNAPSHOT/core-java-1.0.24-20210118.053141-1.pom 400 Bad Request -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal on project main-common: Could not resolve dependencies for project co.main:main-common:jar:0.0.4-SNAPSHOT: Failed to collect dependencies at org.core:core-java:jar:1.0.24-SNAPSHOT
    at org.apache.maven.lifecycle.internal.LifecycleDependencyResolver.getDependencies (LifecycleDependencyResolver.java:269)
    at org.apache.maven.lifecycle.internal.LifecycleDependencyResolver.resolveProjectDependencies (LifecycleDependencyResolver.java:147)
    at org.apache.maven.lifecycle.internal.MojoExecutor.ensureDependenciesAreResolved (MojoExecutor.java:248)
    ...
Caused by: org.apache.maven.project.DependencyResolutionException: Could not resolve dependencies for project co.main:main-common:jar:0.0.4-SNAPSHOT: Failed to collect dependencies at org.core:core-java:jar:1.0.24-SNAPSHOT
    at org.apache.maven.project.DefaultProjectDependenciesResolver.resolve (DefaultProjectDependenciesResolver.java:178)
    at org.apache.maven.lifecycle.internal.LifecycleDependencyResolver.getDependencies (LifecycleDependencyResolver.java:243)
    at org.apache.maven.lifecycle.internal.LifecycleDependencyResolver.resolveProjectDependencies (LifecycleDependencyResolver.java:147)
    ...
Caused by: org.eclipse.aether.collection.DependencyCollectionException: Failed to collect dependencies at org.core:core-java:jar:1.0.24-SNAPSHOT
    at org.eclipse.aether.internal.impl.collect.DefaultDependencyCollector.collectDependencies (DefaultDependencyCollector.java:291)
    at org.eclipse.aether.internal.impl.DefaultRepositorySystem.collectDependencies (DefaultRepositorySystem.java:284)
    at org.apache.maven.project.DefaultProjectDependenciesResolver.resolve (DefaultProjectDependenciesResolver.java:169)
    ...
Caused by: org.eclipse.aether.resolution.ArtifactDescriptorException: Failed to read artifact descriptor for org.core:core-java:jar:1.0.24-SNAPSHOT
    at org.apache.maven.repository.internal.DefaultArtifactDescriptorReader.loadPom (DefaultArtifactDescriptorReader.java:255)
    at org.apache.maven.repository.internal.DefaultArtifactDescriptorReader.readArtifactDescriptor (DefaultArtifactDescriptorReader.java:171)
    at org.eclipse.aether.internal.impl.collect.DefaultDependencyCollector.resolveCachedArtifactDescriptor (DefaultDependencyCollector.java:541)
    ...
Caused by: org.eclipse.aether.resolution.ArtifactResolutionException: Could not transfer artifact org.core:core-java:pom:1.0.24-20210118.053141-1 from/to github-core-java (https://maven.pkg.github.com/owner/core-java): Transfer failed for https://maven.pkg.github.com/owner/core-java/org/core/core-java/1.0.24-SNAPSHOT/core-java-1.0.24-20210118.053141-1.pom 400 Bad Request
    at org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolve (DefaultArtifactResolver.java:424)
    at org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolveArtifacts (DefaultArtifactResolver.java:229)
    at org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolveArtifact (DefaultArtifactResolver.java:207)
    ...
Caused by: org.eclipse.aether.transfer.ArtifactTransferException: Could not transfer artifact org.core:core-java:pom:1.0.24-20210118.053141-1 from/to github-core-java (https://maven.pkg.github.com/owner/core-java): Transfer failed for https://maven.pkg.github.com/owner/core-java/org/core/core-java/1.0.24-SNAPSHOT/core-java-1.0.24-20210118.053141-1.pom 400 Bad Request
    at org.eclipse.aether.connector.basic.ArtifactTransportListener.transferFailed (ArtifactTransportListener.java:52)
    at org.eclipse.aether.connector.basic.BasicRepositoryConnector$TaskRunner.run (BasicRepositoryConnector.java:369)
    at org.eclipse.aether.util.concurrency.RunnableErrorForwarder$1.run (RunnableErrorForwarder.java:75)
    ...
Caused by: org.apache.maven.wagon.TransferFailedException: Transfer failed for https://maven.pkg.github.com/owner/core-java/org/core/core-java/1.0.24-SNAPSHOT/core-java-1.0.24-20210118.053141-1.pom 400 Bad Request
    at org.apache.maven.wagon.providers.http.wagon.shared.AbstractHttpClientWagon.fillInputData (AbstractHttpClientWagon.java:1196)
    at org.apache.maven.wagon.providers.http.wagon.shared.AbstractHttpClientWagon.fillInputData (AbstractHttpClientWagon.java:1138)
    at org.apache.maven.wagon.StreamWagon.getInputStream (StreamWagon.java:126)
    ...

So lets see what Maven was able to obtain:

username (imac0) # cd /Users/username/.m2/repository/org/core/core-java/1.0.24-SNAPSHOT/

username (imac0) # ls
core-java-1.0.24-20210118.053141-1.pom.lastUpdated       maven-metadata-github-core-java.xml                      maven-metadata-github-core-java.xml.sha1                 resolver-status.properties

username (imac0) # cat core-java-1.0.24-20210118.053141-1.pom.lastUpdated 
#NOTE: This is a Maven Resolver internal implementation file, its format can be changed without prior notice.
#Mon Jan 18 00:33:53 EST 2021
@default-github-core-java-https\://maven.pkg.github.com/owner/core-java/.lastUpdated=1610948033580
https\://maven.pkg.github.com/owner/core-java/.error=Could not transfer artifact org.core\:core-java\:pom\:1.0.24-20210118.053141-1 from/to github-core-java (https\://maven.pkg.github.com/owner/core-java)\: Transfer failed for https\://maven.pkg.github.com/owner/core-java/org/core/core-java/1.0.24-SNAPSHOT/core-java-1.0.24-20210118.053141-1.pom 400 Bad Request

So it wasn’t able to get the core-java POM or JAR. Hmmm… looking at pom.xml of main-common I have what appears to be correct:

  <dependencies>
    <dependency>
      <groupId>org.core</groupId>
      <artifactId>core-java</artifactId>
      <version>1.0.24-SNAPSHOT</version>
    </dependency>
    ...
  </dependencies>
  ...
  <repositories>
    <repository>
      <id>github-core-java</id>
      <name>GitHub OWNER core Maven Packages core-java</name>
      <url>https://maven.pkg.github.com/owner/core-java</url>
      <releases><enabled>true</enabled><updatePolicy>always</updatePolicy></releases>
      <snapshots><enabled>true</enabled><updatePolicy>always</updatePolicy></snapshots>
    </repository>
  </repositories>

  ... 

and settings.xml also seems to be fine:

<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-core-java</id>
      <configuration>
        <httpHeaders>
          <property>
            <name>Authorization</name>
            <value>Basic {{base64-encoded username:personal_access_token}}</value>
          </property>
        </httpHeaders>
      </configuration>
    </server>
    <server>
      <id>github-main-cloud</id>
      <configuration>
        <httpHeaders>
          <property>
            <name>Authorization</name>
            <value>Basic {{base64-encoded username:personal_access_token}}</value>
          </property>
        </httpHeaders>
      </configuration>
    </server>
  </servers>
</settings>

So how about we try using the same base64 token encoded in settings.xml and the same URLs that Maven could not download:

cd /Users/username/.m2/repository/org/core/core-java/1.0.24-SNAPSHOT/

curl --header 'Authorization: Basic {{base64-encoded username:personal_access_token}}' \
     --header 'Accept: application/vnd.github.v3.raw' \
     --remote-name \
     --location https://maven.pkg.github.com/owner/core-java/org/core/core-java/1.0.24-SNAPSHOT/core-java-1.0.24-20210118.053141-1.pom

curl --header 'Authorization: Basic {{base64-encoded username:personal_access_token}}' \
     --header 'Accept: application/vnd.github.v3.raw' \
     --remote-name \
     --location https://maven.pkg.github.com/owner/core-java/org/core/core-java/1.0.24-SNAPSHOT/core-java-1.0.24-20210118.053141-1.jar

and somewhat surprisingly (using the same authentication) I now have a POM and JAR.

Moreover, doing build and deploy again I get:

[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------

Does anyone know how to fix this problem. I could make a BASH script for the workaround but it just seems silly to have to resort to this length to obtain a dependency.

Thanks,

–Nikolaos