Objective
Publish private maven project to GitHub packages as a private repo for use in other projects.
Getting Error
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.8.2:deploy (default-deploy) on project SecuritySpringBootContracts: Failed to deploy artifacts: Could not transfer artifact com.sagar:SecuritySpringBootContracts:jar:0.0.3 from/to contracts (https://maven.pkg.github.com/sagarnayak/SecuritySpringBootContracts): transfer failed for https://maven.pkg.github.com/sagarnayak/SecuritySpringBootContracts/com/sagar/SecuritySpringBootContracts/0.0.3/SecuritySpringBootContracts-0.0.3.jar, status: 422 Unprocessable Entity
My private repository in GitHub
https://github.com/sagarnayak/SecuritySpringBootContracts
My code
Settings.xml in C:\Users\SAGAR\ .m2
<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">
<activeProfiles>
<activeProfile>github</activeProfile>
</activeProfiles>
<profiles>
<profile>
<id>github</id>
<repositories>
<repository>
<id>central</id>
<url>https://repo1.maven.org/maven2</url>
</repository>
<repository>
<id>contracts</id>
<url>https://maven.pkg.github.com/sagarnayak/SecuritySpringBootContracts</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>
</profile>
</profiles>
<servers>
<server>
<id>contracts</id>
<username>sagarnayak</username>
<password>ghp_WRGrhj380s8vikAcZMp4j1z02</password>
</server>
</servers>
pom.xml
<?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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.5.5</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.sagar</groupId>
<artifactId>SecuritySpringBootContracts</artifactId>
<version>0.0.3</version>
<name>SecuritySpringBootContracts</name>
<description>SecuritySpringBootContracts</description>
<properties>
<java.version>11</java.version>
<kotlin.version>1.5.31</kotlin.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-reflect</artifactId>
</dependency>
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-stdlib-jdk8</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<scope>runtime</scope>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<sourceDirectory>${project.basedir}/src/main/kotlin</sourceDirectory>
<testSourceDirectory>${project.basedir}/src/test/kotlin</testSourceDirectory>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-maven-plugin</artifactId>
<configuration>
<args>
<arg>-Xjsr305=strict</arg>
</args>
<compilerPlugins>
<plugin>spring</plugin>
</compilerPlugins>
</configuration>
<dependencies>
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-maven-allopen</artifactId>
<version>${kotlin.version}</version>
</dependency>
</dependencies>
</plugin>
</plugins>
</build>
<distributionManagement>
<repository>
<id>contracts</id>
<name>contracts package</name>
<url>https://maven.pkg.github.com/sagarnayak/SecuritySpringBootContracts</url>
</repository>
</distributionManagement>
</project>
When I type mvnw deploy I get the error -
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.8.2:deploy (default-deploy) on project SecuritySpringBootContracts: Failed to deploy artifacts: Could not transfer artifact com.sagar:SecuritySpringBootContracts:jar:0.0.3 from/to contracts (https://maven.pkg.github.com/sagarnayak/SecuritySpringBootContracts): transfer failed for https://maven.pkg.github.com/sagarnayak/SecuritySpringBootContracts/com/sagar/SecuritySpringBootContracts/0.0.3/SecuritySpringBootContracts-0.0.3.jar, status: 422 Unprocessable Entity
Any suggestion is appreciated.
CodePudding user response:
As mentioned on this issue Publishing GitHub Packages returns 422 error
it appears to be the name of your package, it must be lowercase
In your pom.xml
, use for example <artifactId>security-springboot-contrats</artifactId>
instead of <artifactId>SecuritySpringBootContracts</artifactId>
CodePudding user response:
The snapshot version which got created during startup of an application is wrong, it should be similar to like 0.0.1-SNAPSHOT
Ex: 0.0.1-SNAPSHOT or 0.0.3-SNAPSHOT
in your case it got created with 0.0.3