Maven生成POM文件 [英] maven generating pom file

查看:1135
本文介绍了Maven生成POM文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用maven 3.0.3并尝试为第三方jar生成pom,如下所示:

I use maven 3.0.3 and have tried to generate pom for third-party jar like this:

mvn install:安装文件-Dfile = cobra.jar -DgroupId = com.cobra -DartifactId =眼镜蛇-Dversion = 0.98.4 -Dpackaging = jar -DgeneratePom = true

mvn install:install-file -Dfile=cobra.jar -DgroupId=com.cobra -DartifactId=cobra -Dversion=0.98.4 -Dpackaging=jar -DgeneratePom=true

根据下面的链接,应生成正确的pom.xml并在存储库中安装工件. http://maven.apache.org/plugins /maven-install-plugin/examples/generic-pom-generation.html

According to link below it should generate proper pom.xml and install artifact in the repo. http://maven.apache.org/plugins/maven-install-plugin/examples/generic-pom-generation.html

同时,它返回这样的错误:

Meanwhile, it returns such a error:

[错误]您指定的目标需要一个项目来执行,但在那里 在此目录(D:\ cobra-0.98.4 \ lib)中没有POM.请验证你 从正确的目录调用了Maven. -> [帮助1]

[ERROR] The goal you specified requires a project to execute but there is no POM in this directory (D:\cobra-0.98.4\lib). Please verify you invoked Maven from the correct directory. -> [Help 1]

为什么要在生成pom.xml时要求pom.xml?

Why is it asking for pom.xml while it should generate pom.xml?

推荐答案

这是一个老问题,但是对我来说,这是一个严重的PITA,所以我想分享一下:

This is an old question, but was a serious PITA for me for a few minutes, so I thought I'd share:

我只是遇到了这个问题,我相信这个问题可能与平台有关.真正的提示是,Cyril回答的解决方案未按预期工作:尽管我在命令行中指定了-DgroupId=com.xyz-DartifactId=whatever,并且在POM文件中指定了相应的条目,但jar仍安装在com/whatever下的本地仓库.

I just ran into this problem, and I believe that the issue is probably platform-dependent. The real tip-off was that the solution from Cyril's answer wasn't working as expected: despite my specification of -DgroupId=com.xyz and -DartifactId=whatever on the command-line and the corresponding entry in the POM file, the jar was installed in the local repo under com/whatever.

这使我尝试用引号引起来,并通过格式化命令行(在删除POM文件之后)最终得到正确的结果:

This led me to experiment with quoting command-line arguments, and the eventual correct result from formatting the command-line like this (after deleting the POM file):

mvn install:install-file "-Dfile=cobra.jar" "-DgroupId=com.cobra" "-DartifactId=cobra" "-Dversion=0.98.4" "-Dpackaging=jar" "-DgeneratePom=true"

某些报价无疑是多余的,但是比后悔更安全,对吧?我恰好在这台计算机上运行Vista,如果这个问题是特定于此OS版本的,我不会感到惊讶...顺便说一句,这是Maven v3.0.4的问题.

Some of the quoting is doubtless redundant, but better safe than sorry, right? I happen to be running Vista on this computer, and would not be surprised if this problem were specific to this OS version...by the way, this was with Maven v3.0.4.

这篇关于Maven生成POM文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆