简体   繁体   English

从pom.xml生成.pom文件的正确方法是什么?

[英]What's the correct way to generate a .pom file from my pom.xml?

I've been learning how to publish a Java library to jcenter. 我一直在学习如何将Java库发布到jcenter。 jcenter/bintray wants me to upload the following artifacts: jcenter / bintray希望我上传以下工件:

  1. Binaries: {groupId}/{artifactId}-{version}.jar 二进制文件: {groupId}/{artifactId}-{version}.jar
  2. Source: {groupId}/{artifactId}-{version}-sources.jar 来源: {groupId}/{artifactId}-{version}-sources.jar
  3. (Optionally) Javadoc: {groupId}/{artifactId}-{version}-javadoc.jar (可选)Javadoc: {groupId}/{artifactId}-{version}-javadoc.jar
  4. POM: {groupId}/{artifactId}-{version}.pom POM: {groupId}/{artifactId}-{version}.pom

I can generate the first three no problem (binaries with a standard mvn package and sources and javadoc using the plugins described here ). 我可以生成前三个没问题(带有标准mvn package二进制文件以及使用此处描述的插件的源代码和javadoc)。

Currently I'm just manually copying my pom.xml to {groupId}/{artifactId}-{version}.pom and that works fine, but it smells. 目前,我只是将pom.xml手动复制到{groupId}/{artifactId}-{version}.pom ,效果很好,但闻起来很{groupId}/{artifactId}-{version}.pom I'm sure there must be an automated Maven way of doing this but I can't find it. 我敢肯定必须有一种自动的Maven方法来执行此操作,但我找不到它。 Can anyone help? 有人可以帮忙吗?

You can upload your Maven project directly to Bintray just by adding some code to your pom.xml and then running the appropriate mvn command : 您只需将一些代码添加到pom.xml中,然后运行适当的mvn命令,即可将Maven项目直接上传到Bintray

First add a distribution section to your maven and specify the URL from which to distribute your project: 首先,在您的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>

In order to work with Bintray you need to provide your Bintray username and API Key as upload credentials in the username and password tags of your Maven settings.xml file. 为了使用Bintray,您需要在Maven settings.xml文件的用户名和密码标签中提供Bintray用户名和API密钥作为上传凭据。 The API Key can be found when editing your Bintray profile page: 在编辑Bintray个人资料页面时可以找到API密钥:

<server>
  <id>bintray-repo-maven-example</id>
  <username>tamarjfrog</username>
  <password>***my-top-secret-api-key***</password>
</server>

the you just run this simple command: 您只需运行以下简单命令:

mvn deploy mvn部署

The project will be built, uploaded to the the Bintray repository target URL you provided, and published. 该项目将被构建,上传到您提供的Bintray存储库目标URL并发布。 For more information take a look here . 有关更多信息,请在此处查看

mvn deploy应该自动推送您的pom

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM