我使用maven 3.0.3,并尝试为第三方jar生成pom,如下所示:
mvn install:install-file -Dfile=cobra.jar -DgroupId=com.cobra -DartifactId=cobra -Dversion=0.98.4 -Dpackaging=jar -DgeneratePom=true
根据下面的链接,它应该生成正确的pom.xml并在仓库中安装 Artifact 。
http://maven.apache.org/plugins/maven-install-plugin/examples/generic-pom-generation.html
同时,它返回这样的错误:
[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?
最佳答案
这是一个古老的问题,但是对我来说,这是一个严重的PITA,所以我想分享一下:
我只是遇到了这个问题,我相信这个问题可能与平台有关。真正的提示是,Cyril的答案无法按预期工作:尽管我在命令行上指定了-DgroupId=com.xyz
和-DartifactId=whatever
以及POM文件中的相应条目,但该jar仍安装在本地存储库中com/whatever
下。
这使我尝试用引号引用命令行参数,并通过格式化这样的命令行(在删除POM文件之后)最终得到正确的结果:
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。
关于maven - Maven生成POM文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6704813/