【问题标题】:deploy:deploy-file not finding artifact, group, etc. from pom file部署:部署文件未从 pom 文件中找到工件、组等
【发布时间】:2014-06-06 16:02:50
【问题描述】:

根据documentation,直接指定pom文件时deploy:deploy-file应该可以工作;在这种情况下,文档说您不需要“groupId、artifactId、版本和打包参数......因为部署文件目标将从给定的 POM 中获取这些信息”。

但是,当我运行以下命令时:

mvn deploy:deploy-file -DpomFile=webapp-6.0.2.pom -Dfile=webapp-6.0.2.jar -DrepositoryId=internal -Durl=dav:http://server:9091/archiva/repository/internal -Dpackaging=jar -DgeneratePom=false

我收到此错误:

[INFO] Building Maven Default Project
[INFO]    task-segment: [deploy:deploy-file] (aggregator-style)
[INFO] ------------------------------------------------------------------------
[INFO] [deploy:deploy-file]
[INFO] ------------------------------------------------------------------------
[ERROR] BUILD ERROR
[INFO] ------------------------------------------------------------------------
[INFO] Missing group, artifact, version, or packaging information

使用mvn -e -X 不会显示任何额外的见解。我正在使用 Maven 2.0.9 和 maven-deploy-plugin 2.3 版。

是文档有误还是我遗漏了什么?

【问题讨论】:

  • 根据您提到的内容,我建议使用 maven-deploy-plugin 的最新版本,即 2.8.1 而不是 2.3。最重要的是使用 Maven 3.X,因为 Maven 2.0.9 太旧了,而且 2.0.9 不是 Maven 2.0 的最新(如果我们真的可以说的话)版本。 Maven 2.0.9 是从 2008 年开始的,这意味着 5 岁。更新到 Maven 3.1.1 或 Maven 3.2.1...
  • 现在升级对我来说不是一个选项,但是是的,newest version 似乎按照文档描述的方式工作。

标签: maven maven-deploy-plugin


【解决方案1】:

tl;dr:deploy-file mojo 不继承父项目的版本号,所以必须直接在 pom 中或指定为-Dversion=... 参数。

根据您的看法,这可能是一个错误或文档中的缺失。部署插件的来源有:

Parent parent = model.getParent();

if ( this.groupId == null )
{
    if ( parent != null && parent.getGroupId() != null )
    {
        this.groupId = parent.getGroupId();
    }
    if ( model.getGroupId() != null )
    {
        this.groupId = model.getGroupId();
    }
}
if ( this.artifactId == null && model.getArtifactId() != null )
{
    this.artifactId = model.getArtifactId();
}
if ( this.version == null && model.getVersion() != null )
{
    this.version = model.getVersion();
}
if ( this.packaging == null && model.getPackaging() != null )
{
    this.packaging = model.getPackaging();
}

这意味着插件只尝试从父级继承groupId,而不是版本号。在我的特殊情况下,我的 pom 缺少 version,我希望它像其他大多数 maven 一样从父级继承。

【讨论】:

    猜你喜欢
    • 2022-08-06
    • 1970-01-01
    • 2013-04-13
    • 1970-01-01
    • 2014-05-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多