【问题标题】:Usage of maven deploy-filemaven部署文件的使用
【发布时间】:2020-08-20 11:45:55
【问题描述】:

阅读文档。在deploy:deploy-file (https://maven.apache.org/plugins/maven-deploy-plugin/deploy-file-mojo.html) 中,似乎唯一需要的参数是 必需参数<file>, <repositoryId> and <url>, 尽管如此,当我跑步时:

mvn deploy:deploy-file -Durl={url} -DrepositoryId={repoId} -Dfile=D:\Users\nunito\IdeaProjects\calzada\target\calzada.zip

我收到了这个错误:

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.8.2:deploy-file (default-cli) on project oib-kw-guards-web: The artifact i
nformation is incomplete or not valid:
[ERROR]   [0]  'groupId' is missing.
[ERROR]   [1]  'artifactId' is missing.
[ERROR]   [2]  'version' is missing.

【问题讨论】:

  • 我假设您已经通过 maven-assembly-plugin 打包了该 zip 文件?如果是这样,您可以像往常一样使用mvn deploy...

标签: maven


【解决方案1】:

当我有一个没有pom.xml 的第三方工件时,我通常在命令行中使用deploy:deploy-file

cmd /v /c "set a=an-artifact-name&& set g=com.company.xxx&& \
mvn deploy:deploy-file -Dfile=C:\path\to\!a!.jar -Dpackaging=jar -DgroupId=!g! -DartifactId=!a! \
-Dversion=1.0-DEV-SNAPSHOT -DrepositoryId=nexus \
-Durl=http://company.com/nexus/content/repositories/company-snapshots/"

您只需在命令开头修改ag即可。

如果您有特定版本,您可以添加版本 v,并将其放入 Nexus 的发布部分:

cmd /v /c "set a=an-artifact-name&& set g=com.company.xxx&& && set v=1.2.3&& \
mvn deploy:deploy-file -Dfile=C:\path\to\!a!.jar -Dpackaging=jar -DgroupId=!g! -DartifactId=!a! \
-Dversion=!v! -DrepositoryId=nexus \
-Durl=http://company.com/nexus/content/repositories/company-releases/"

【讨论】:

    【解决方案2】:

    插件“使用”页面 (https://maven.apache.org/plugins/maven-deploy-plugin/usage.html) 指出:

    如果未以某种方式指定以下所需信息,则目标将失败:

    • 要部署的工件文件
    • 要部署的文件的组、工件、版本和打包。这些可以从指定的 pomFile 中获取,并使用命令行覆盖或指定。当 pomFile 包含 parent 部分时,如果没有为当前项目或在命令行上进一步指定 groupId,则可以考虑 parent 的 groupId。
    • 存储库信息:要部署到的 url 和映射到 settings.xml 文件中服务器部分的 repositoryId。如果您不指定 repositoryId,Maven 将尝试使用 id 'remote-repository' 提取身份验证信息。

    所以你要么需要指定坐标,要么给出一个 POM 文件。

    【讨论】:

      猜你喜欢
      • 2020-12-30
      • 2021-11-08
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2010-10-19
      • 2015-10-15
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多