本文介绍了我可以在pom或settings.xml中包含mvn deploy:deploy文件而不是cli目标吗的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要将自定义jar和从Java项目生成的jar一起部署到Artifactory.目前,我唯一可以找到的方法是使用以下命令通过命令行目标:

I need to deploy a custom jar to Artifactory along with the jar generated from my Java project. Currently the only method I can find is through command line goal using:

mvn deploy:deploy-file -DgroupId=<group-id> \
  -DartifactId=<artifact-id> \
  -Dversion=<version> \
  -Dpackaging=<type-of-packaging> \
  -Dfile=<path-to-file> \
  -Durl=<url-of-the-repository-to-deploy>

是否可以将其包含在pom文件中?作为插件还是其他?

Is there a way of including this in the pom file? As a plugin or something?

推荐答案

好的.只需定义 maven-deploy-plugin:deploy-file 的执行即可目标绑定到deploy阶段,并使用您的值进行配置.部署项目时,将调用此执行并部署JAR.

Sure. Just define an execution of the maven-deploy-plugin:deploy-file goal bound to the deploy phase, configured with your values. When deploying your project, this execution will be invoked and the JAR will be deployed.

<plugin>
    <artifactId>maven-deploy-plugin</artifactId>
    <version>2.8.2</version>
    <executions>
        <execution>
            <id>deploy-file</id>
            <phase>deploy</phase>
            <goals>
                <goal>deploy-file</goal>
            </goals>
            <configuration>
                <file><!-- path-to-file --></file>
                <url><!-- url-of-the-repository-to-deploy --></url>
                <groupId><!-- group-id --></groupId>
                <artifactId><!-- artifact-id --></artifactId>
                <version><!-- version --></version>
                <packaging><!-- type-of-packaging --></packaging>
            </configuration>
        </execution>
    </executions>
</plugin>

请注意,您可能需要添加 repositoryId .这是要在settings.xml<server>部分下的<id>上映射的服务器ID.

Note that you will probably need to add a repositoryId also. This is the server id to map on the <id> under the <server> section of the settings.xml.

这篇关于我可以在pom或settings.xml中包含mvn deploy:deploy文件而不是cli目标吗的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-14 06:07