Maven安装文件不会生成pom.xml [英] Maven install-file won't generate pom.xml

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

问题描述

我已使用以下命令在我的存储库中安装了一些第三方jar:

I've installed some third party jars to my repository using the following command:

mvn install:install-file -Dfile=/home/anotherCoder/Downloads/nifty-1.0.jar -DgroupId=nifty-gui -DartifactId=nifty-gui -Dversion=1.0 -Dpackaging=jar

但是,一旦执行mvn编译,maven就会抱怨存储库中没有pom文件,并尝试下载它,但不能导致它没有在任何远程存储库中发布.

However, once I do mvn compile, maven complains that there is no pom file in the repository and attempts to download it, but can't cause it is not published at any remote repository.

这是来自Maven的确切消息:

Here is the exact message from maven:

Downloading: http://repo1.maven.org/maven2/nifty-gui/nifty-gui/1.0/nifty-gui-1.0.pom
[INFO] Unable to find resource 'nifty-gui:nifty-gui:pom:1.0' in repository central (http://repo1.maven.org/maven2)

那么我如何让Maven为该jar生成一个pom文件并将其放入我的本地存储库中?

So how do I get maven to generate a pom file for that jar and put it in my local repository?

推荐答案

您告诉它! :-)

mvn install:install-file
  -Dfile=/home/anotherCoder/Downloads/nifty-1.0.jar
  -DgroupId=nifty-gui
  -DartifactId=nifty-gui
  -Dversion=1.0
  -Dpackaging=jar
  -DgeneratePom=true

(命令位于多行上,因此您可以轻松查看最后一个参数.)

(Command placed on multiple lines so you can easily see the last parameter.)

很好,是吗?将来,您可以转到插件的文档,查看其目标,并可以查看其接受的所有参数.例如,安装文件目标.

Nice, huh? In the future you can go to a plug-in's documentation, view its goals, and you can see all the parameters it accepts. For example, the install-file goal.

关于generatePom标志的默认行为的问题,文档指出它默认为true,并且代码似乎支持该行为.但是,将Maven 2.0.9与maven-install-plugin版本2.2(两个版本都已过时)一起使用时,它不会生成POM.因此,也许增加版本将使默认设置有效.

Regarding the question of the default behavior of the generatePom flag, the documentation indicates it defaults to true, and the code appears to support that. However, using Maven 2.0.9 with the maven-install-plugin version 2.2 (both versions are slightly out of date), it does not generate a POM. So, perhaps incrementing the version(s) will allow the default to work.

> touch DeleteMe.jar
> mvn install:install-file -DgroupId=Delete -DartifactId=Me -Dversion=0.0.0 -Dpackaging=jar -Dfile=DeleteMe.jar
...
[INFO] BUILD SUCCESSFUL
...
> ls ~/.m2/repository/Delete/Me/0.0.0/
Me-0.0.0.jar

(未生成POM.)

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

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