1

I created a parent POM to be shared by multiple projects. It is a POM-only project. Here is what it is like.

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <modelVersion>4.0.0</modelVersion>

    <groupId>myorg</groupId>
    <artifactId>project-parent</artifactId>
    <version>0.2.8</version>
    <packaging>pom</packaging>

    <name>project-parent</name>
    <description>Parent pom providing dependency and plugin management for services built with Maven
    </description>

    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.7.0</version>
        <relativePath/>
    </parent>

    <distributionManagement>
        <repository>
            <id>github</id>
            <name>GitHub OWNER Apache Maven Packages</name>
            <url>https://maven.pkg.github.com/[OWNER]/my-repo</url>
        </repository>
    </distributionManagement>
</project>

I used GitHub Actions to deploy the pom to GitHub Packages. From the log, I could see the deployment was successful.

However, when I referenced it in a child POM, I got the following error.

 Could not find artifact myorg:project-parent:pom:0.2.8 in github (https://maven.pkg.github.com/[OWNER]/my-repo) and 'parent.relativePath' points at no local POM @ line 13, column 10

I referenced the repository in the sub-project's POM, like this

   <parent>
    <groupId>myorg</groupId>
    <artifactId>project-parent</artifactId>
    <version>0.2.8</version>
    <relativePath/>
   </parent>
   ...
   <repositories>
    <repository>
        <id>github</id>
        <name>GitHub OWNER Apache Maven Packages</name>
        <url>https://maven.pkg.github.com/[OWNER]/my-repo</url>
    </repository>
   </repositories>

I stored my GitHub credential in the local settings.xml for the child project. I stored the credentiali in the GitHub Secrets for Actions. They worked as expected.

I've tried many things:

  • went thru many postings on this site
  • checked the distribution repository setting in the parent pom
  • downloaded the parent pom files directly from GitHub Packages, and the file was correct
  • checked the depedency repository setting in the child pom
  • Checked the Maven cmd used in GitHub Actions, mvn --batch-mode deploy

Can someone please tell me what I could have missed? Thanks!

UPDATE - I published the parent pom to CodeArtifact and it just worked. I guess GitHub Packages might have a bug.

Eric
  • 11
  • 3

0 Answers0