0

I am correctly deploying my JAR file using the command line below, however I would like to create a pom.xml file and invoke mvn deploy or something similar to deploy this package to github packages.

Is this possible? How can I do it?

mvn deploy:deploy-file -DgroupId=com.soma -DartifactId=my-module \
  -Dversion=1.0.0 -Dpackaging=jar -Dfile=my-module.jar \
  -DrepositoryId=github \
  -Durl=https://maven.pkg.github.com/$USER/my-artifacts

In other words, I prefer to use Maven to automate my workflow over bash shell.

I appreciate any help.

João Paraná
  • 1,031
  • 1
  • 9
  • 18

1 Answers1

0

The following minimal pom.xml should work by executing mvn deploy with the following caveats:

  • Replace $USER with your actual GitHub user ID

  • Put your JAR in target/my-module-1.0.0-SNAPSHOT.jar

  • Make sure your ${user.home}/.m2/settings.xml has a <server/> entry with your GitHub user and token

<?xml version="1.0" encoding="utf-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
                             http://maven.apache.org/maven-v4_0_0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <groupId>com.soma</groupId>
  <artifactId>my-module</artifactId>
  <version>1.0.0</version>
  <distributionManagement>
    <downloadUrl>https://maven.pkg.github.com/$USER/${project.groupId}/</downloadUrl>
    <repository>
      <id>github</id>
      <url>https://maven.pkg.github.com/$USER/${project.groupId}/</url>
    </repository>
  </distributionManagement>
</project>

This should be straightforward if you already have a Maven build for the project.

(I have run into problems with GitHub throttling requests when trying to deploy multimodule projects or quickly redeploying an artifact.)

Allen D. Ball
  • 1,916
  • 1
  • 9
  • 16