从maven部署到nexus时指定版本

mqkwyuun  于 2021-06-07  发布在  Kafka
关注(0)|答案(2)|浏览(384)

我已经使用了confluent的kafka connect hdfs编写器,现在我想将这个jar的一个版本部署到我的本地nexus。 mvn clean deploy 像一个魔咒一样工作并且部署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步)
pom.xml基本上与5.0.0-post版本相同,但最重要的部分是:

<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>
...

所以我先补充说 <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 接下来我尝试了maven的版本插件 mvn versions:set -DnewVersion=5.0.0-1 clean deploy 但她抱怨父母:
[错误]无法执行目标org.codehaus。mojo:versions-maven-plugin:2.7:kafka connect hdfs项目上的set(默认cli):项目版本从父级继承。->[帮助1]
我甚至不在乎代码中的版本是不是5.0.0,我只想在我们的工件中部署到不同的版本。
我不是一个Maven,所以也许我错过了一些非常基本的线索,但所有的帮助是欢迎的。

m0rkklqb

m0rkklqb1#

所以有一些很好的建议,但最终在我们的设置中最适合我的是使用 deploy:deploy-file 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 ,等等),但它是有效的,这才是最重要的:-)

yx2lnoni

yx2lnoni2#

可以使用指定版本 ${revision} 参数。
为此,您需要添加 <version> 在pom.xml中使用此变量进行标记:

<artifactId>kafka-connect-hdfs</artifactId>
<version>5.0.0-${revision}</version>
<packaging>jar</packaging>

然后提供给maven命令。例如。, mvn clean package -Drevision=01 将生成 kafka-connect-hdfs-5.0.0-01.jar 文件。

相关问题