以下是我使用GitHub作为Maven Repository完成的步骤
- 创建了一个新的公共存储库:
https://github.com/keshavram-roomie/library
- 转到
https://start.spring.io
并按原样生成了一个maven项目。 - 添加
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>
- 添加
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>
- 创建
~/.m2/settings.xml
<settings>
<servers>
<server>
<id>github</id>
<username>keshavram-roomie</username>
<password>password</password>
</server>
</servers>
</settings>
- 已执行
chmod 700 ~/.m2/settings.xml
- 点击
mvn deploy -e -X
以下是最后几行错误
[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
它似乎试图读取刚生成的文件,但找不到它。因为我查的时候,文件还在。有没有可能文件夹没有被刷新?
1条答案
按热度按时间aydmsdu91#
首先检查它是否类似于this answer,它表示:
repositoryName
必须仅是存储库的名称,在本例中为library
。(你做到了)关于第二点,“Working with the Apache Maven registry“确认:
您需要一个访问令牌来发布、安装和删除私有、内部和公共包。
您可以使用个人访问令牌(经典)来验证GitHub Packages或GitHub API。创建个人访问令牌(经典)时,可以根据需要为令牌分配不同的作用域。有关个人访问令牌(经典)的包相关作用域的更多信息,请参阅“关于GitHub包的权限”。
要在GitHub操作工作流中对GitHub Packages注册表进行身份验证,您可以使用:用途:
GITHUB_TOKEN
发布与工作流存储库关联的包。read:packages
的作用域来安装与其他私有仓库(GITHUB_TOKEN
无法访问)相关的软件包。请仔细检查您的密码:它必须是一个token,而不是你实际的GitHub用户帐户密码。