Following are the steps that I have completed for using GitHub as a Maven Repository
- Created a new public repository:
https://github.com/keshavram-roomie/library - Went to
https://start.spring.ioand generated a maven project as is. - Added
maven-deploy-plugin
<plugin>
<artifactId>maven-deploy-plugin</artifactId>
<version>2.8.1</version>
<configuration>
<altDeploymentRepository>internal.repo::default::file://${project.build.directory}/mvn-repo</altDeploymentRepository>
</configuration>
</plugin>
- Added
site-maven-plugin
<plugin>
<groupId>com.github.github</groupId>
<artifactId>site-maven-plugin</artifactId>
<version>0.11</version>
<configuration>
<message>Maven artifacts for ${project.version}</message>
<!-- git commit message -->
<noJekyll>true</noJekyll>
<!-- disable webpage processing -->
<outputDirectory>${project.build.directory}/mvn-repo</outputDirectory>
<!-- matches distribution management repository url above -->
<branch>refs/heads/mvn-repo</branch>
<!-- remote branch name -->
<includes>
<include>**/*</include>
</includes>
<repositoryName>library</repositoryName>
<!-- github repo name -->
<repositoryOwner>keshavram-roomie</repositoryOwner>
<!-- github username -->
</configuration>
<executions>
<!-- run site-maven-plugin's 'site' target as part of the build's normal 'deploy' phase -->
<execution>
<goals>
<goal>site</goal>
</goals>
<phase>deploy</phase>
</execution>
</executions>
</plugin>
- Created
~/.m2/settings.xml
<settings>
<servers>
<server>
<id>github</id>
<username>keshavram-roomie</username>
<password>password</password>
</server>
</servers>
</settings>
- Executed
chmod 700 ~/.m2/settings.xml - Hit
mvn deploy -e -X
The following are the last lines of errors
[DEBUG] Using 'github' server credentials
[DEBUG] Using basic authentication with username: keshavram-roomie
[DEBUG] Creating blob from /path/to/project/target/mvn-repo/com/roomie/library/0.0.1-SNAPSHOT/library-0.0.1-20230830.110614-2.jar.md5
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 9.692 s
[INFO] Finished at: 2023-08-30T16:36:24+05:30
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal com.github.github:site-maven-plugin:0.11:site (default) on project library: Error creating blob: Not Found (404) -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal com.github.github:site-maven-plugin:0.11:site (default) on project library: Error creating blob: Not Found (404)
Caused by: org.apache.maven.plugin.MojoExecutionException: Error creating blob: Not Found (404)
Caused by: org.eclipse.egit.github.core.client.RequestException: Not Found (404)
[ERROR]
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
It seems like it's trying to read a file that was just generated but couldn't find it. Because when I checked, the file was there. Is it possible that the folder is not being refreshed?
Check first if this is similar to this answer, which stated:
repositoryNamehas to be the name of the repository only, in this caselibrary. (you did that)Regarding the second point, "Working with the Apache Maven registry" confirms:
You need an access token to publish, install, and delete private, internal, and public packages.
So double-check your password: it must be a token, not your actual GitHub user account password.