我一直在学习如何将 Java 库发布到 jcenter。jcenter/bintray 要我上传以下工件:
{groupId}/{artifactId}-{version}.jar
{groupId}/{artifactId}-{version}-sources.jar
{groupId}/{artifactId}-{version}-javadoc.jar
{groupId}/{artifactId}-{version}.pom
我可以毫无问题地生成前三个(mvn package
使用此处描述的插件具有标准和源代码和 javadoc 的二进制文件)。
目前我只是手动复制我的pom.xml
to{groupId}/{artifactId}-{version}.pom
并且工作正常,但它闻起来很香。我确信必须有一种自动化的 Maven 方式来做到这一点,但我找不到它。任何人都可以帮忙吗?
您可以将您的 Maven 项目直接上传到Bintray,只需在 pom.xml 中添加一些代码,然后运行适当的mvn
命令:
首先向您的 Maven 添加一个分发部分,并指定从中分发您的项目的 URL:
<distributionManagement>
<repository>
<id>bintray-repo-maven-example</id>
<url>https://api.bintray.com/maven/tamarjfrog/maven-repo/maven-example/;publish=1</url>
</repository>
</distributionManagement>
为了使用 Bintray,您需要在 Maven settings.xml 文件的用户名和密码标签中提供您的 Bintray 用户名和 API 密钥作为上传凭据。编辑您的 Bintray 个人资料页面时可以找到 API 密钥:
<server>
<id>bintray-repo-maven-example</id>
<username>tamarjfrog</username>
<password>***my-top-secret-api-key***</password>
</server>
你只需运行这个简单的命令:
mvn 部署
该项目将被构建、上传到您提供的 Bintray 存储库目标 URL 并发布。有关更多信息,请查看此处。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句