java - 如何将 maven 插件上传到 Github 包?
问题描述
考虑我有一个 maven 插件项目,我想将它发布到 Github 的名为“Github Packages”的公共 maven 存储库。我已经按照说明完成了所有工作,对于正常项目,一切都可以开箱即用。但是对于带有 packaging=maven-plugin 的 maven 插件项目,该指令不起作用。
在构建日志中,我看到如下内容:
[警告] 无法从/到 github 传输元数据 repo-name/maven-metadata.xml ( https://maven.pkg.github.com/user-name/repo-name ): 传输文件失败: https:// /maven.pkg.github.com/user-name/repo-name/group-id/maven-metadata.xml。返回码是:422,ReasonPhrase:Unprocessable Entity。
似乎 maven 部署插件在 group-id 的根目录中需要 maven-metadata.xml,但找不到它,也没有人把它放在那里。如何解决这个问题呢?
我使用 Apache Maven 3.3.9,并使用命令:
mvn clean deploy
--添加:我正在使用的 pom 文件示例:
<?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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<repositories>
<repository>
<id>central</id>
<url>https://repo1.maven.org/maven2</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
<repository>
<id>github</id>
<name>GitHub my_repo Apache Maven Packages</name>
<url>https://maven.pkg.github.com/my_nick/my_repo</url>
</repository>
</repositories>
<version>1.0.0</version>
<groupId>x</groupId>
<artifactId>some-plugin</artifactId>
<packaging>maven-plugin</packaging>
<dependencies>
<dependency>
<groupId>x</groupId>
<artifactId>my-dependency</artifactId>
<version>1.0.0</version>
</dependency>
<dependency>
<groupId>com.github.javaparser</groupId>
<artifactId>javaparser-core</artifactId>
<version>3.15.12</version>
</dependency>
<dependency>
<groupId>org.apache.maven.plugin-tools</groupId>
<artifactId>maven-plugin-annotations</artifactId>
<version>3.6.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-plugin-api</artifactId>
<version>3.6.3</version>
</dependency>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-core</artifactId>
<version>3.6.3</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-plugin-plugin</artifactId>
<version>3.6.0</version>
</plugin>
</plugins>
</build>
</project>
解决方案
推荐阅读
- android - Game Maker Studio 2:Android:NDK 中的错误:setup-app.mk
- javascript - 在 JavaScript 中,如何更改正则表达式以匹配所有非字母数字字符?
- javascript - 使用 Github API 获取发布的所有提交部分
- reactjs - 防止在我的减速器逻辑中出现重复条目
- tensorflow - 如何在 Tensorflow 中共享过滤器权重
- reactjs - 如何在下拉列表中添加单击以捕获单击事件?
- android - 在另一台计算机上打开时在 Android Studio 中构建的问题
- mysql - 如何使用通配符查询来自mysql的json数据
- android - Android文本到语音绝对拒绝工作
- python - 使用 Keras 模型进行强化学习