从 maven 部署到 nexus 时指定版本 [英] Specify version when deploying to nexus from maven
问题描述
我已经分叉了 Confluent 的 Kafka Connect HDFS 编写器,现在我想要将此 jar 的一个版本部署到我的本地 Nexus.
I've forked Confluent's Kafka Connect HDFS writer and now I'd like to deploy a version of this jar to my local Nexus.
mvn clean deploy
像魅力一样工作并部署 jar.
mvn clean deploy
Works like a charm and deploys the jar.
https://[nexus]/repository/releases/io/confluent/kafka-connect-hdfs/5.0.0/kafka-connect-hdfs-5.0.0.jar
到目前为止一切顺利,但为了区分融合版本和我自己的部署,我想将构建版本更改为 5.0.0-1
左右(最好是推送时的标签名称,但这是第 2 步)
So far so good, but to make a distinction between the confluent versions and my own deployment I'd like to change the version of the build to something like 5.0.0-1
or so (preferably the tag name when pushed, but that's step 2)
pom.xml 与 5.0.0-post 发布,但这里是最重要的部分:
The pom.xml is basically the same as the 5.0.0-post release, but here the most important parts:
<parent>
<groupId>io.confluent</groupId>
<artifactId>kafka-connect-storage-common-parent</artifactId>
<version>5.0.0</version>
</parent>
<artifactId>kafka-connect-hdfs</artifactId>
<packaging>jar</packaging>
<name>kafka-connect-hdfs</name>
<organization>
<name>Confluent, Inc.</name>
<url>http://confluent.io</url>
</organization>
<url>http://confluent.io</url>
<description>
A Kafka Connect HDFS connector for copying data between Kafka and Hadoop HDFS.
</description>
...
<dependencies>
...
<dependency>
<groupId>io.confluent</groupId>
<artifactId>kafka-connect-storage-common</artifactId>
<version>${confluent.version}</version>
</dependency>
<dependency>
<groupId>io.confluent</groupId>
<artifactId>kafka-connect-storage-core</artifactId>
<version>${confluent.version}</version>
</dependency>
...
</dependencies>
<build>
<plugins>
<plugin>
<groupId>io.confluent</groupId>
<version>0.10.0</version>
<artifactId>kafka-connect-maven-plugin</artifactId>
...
所以首先我在 pom.xml 中添加了 <version>
标签,但它开始使用它作为所有 confluent.version
的默认值并抱怨它不能'找不到例如:https://[nexus]/repository/releases/io/confluent/kafka-connect-storage-hive/5.0.0-1/kafka-connect-storage-hive-5.0.0-1.pom
So first I added <version>
tags to the pom.xml, but it started using that as the default for all confluent.version
and complained that it couldn't find for example: https://[nexus]/repository/releases/io/confluent/kafka-connect-storage-hive/5.0.0-1/kafka-connect-storage-hive-5.0.0-1.pom
接下来我尝试了 来自 maven 的版本插件mvn versions:set -DnewVersion=5.0.0-1 clean deploy
但是那抱怨父母:
[错误] 无法在项目 kafka-connect-hdfs 上执行目标 org.codehaus.mojo:versions-maven-plugin:2.7:set (default-cli):项目版本继承自父级.-> [帮助 1]
[ERROR] Failed to execute goal org.codehaus.mojo:versions-maven-plugin:2.7:set (default-cli) on project kafka-connect-hdfs: Project version is inherited from parent. -> [Help 1]
我什至不在乎代码中的版本是 5.0.0,我只是想在我们的工件中部署到不同的版本.
I don't even care if the version is 5.0.0 in the code, I just wat to deploy to a different version in our artifactory.
我不是 Maven 专家,所以也许我遗漏了一些非常基本的线索,但欢迎所有帮助.
I'm not a maven expert, so maybe I'm missing some very basic clue, but all help is welcome.
推荐答案
所以有一些很好的建议,但最终在我们的设置中最适合我的一件事是使用 deploy:deploy-文件
Maven 命令.
So there were some good suggestions, but in the end the one thing that worked best for me in our setup was to use the deploy:deploy-file
command for maven.
mvn deploy:deploy-file \
-Dfile=target/kafka-connect-hdfs-5.0.0.jar \
-DrepositoryId=[nexus id] \
-Durl=[nexus url] \
-Dversion=$TAG \
-DgroupId=io.confluent \
-DartifactId=kafka-connect-hdfs
主要的缺点是我必须重新指定 pom.xml 中已经存在的参数(artifactId
、groupId
等),但它可以工作,就是这样什么重要:-)
The major downside was that I had to respecify parameters that were already present in the pom.xml (artifactId
, groupId
, ect), but it works, and that's what counts :-)
这篇关于从 maven 部署到 nexus 时指定版本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!