Maven install-file won't generate pom.xml

不问归期 提交于 2019-12-04 04:47:01

You tell it to! :-)

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.

Edit:

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

(No generated POM.)

The install:install-file goal has an optional parameter generatePom (since version 2.1) that allows to:

Generate a minimal POM for the artifact if none is supplied via the parameter pomFile.
Defaults to true if there is no existing POM in the local repository yet.

This parameter defaults to true since version 2.3 (and false in 2.1, 2.2). So if you're using a version of the install plugin prior to 2.3, you'll have to pass the parameter in the command.

Just in case, the syntax to explicitly use the version 2.3 of the install plugin would be:

mvn org.apache.maven.plugins:maven-install-plugin:2.3:install-file \
    -Dfile=/home/anotherCoder/Downloads/nifty-1.0.jar -DgroupId=nifty-gui \
    -DartifactId=nifty-gui -Dversion=1.0 -Dpackaging=jar

I had the same issue I think as you, I had a shell script using the install:install-file goal like this:

mvn -o install:install-file -e 
  -DgroupId=org.jfree.jcommon 
  -DartifactId=jcommon
  -Dversion=1.0.15
  -Dpackaging=jar
  -Dfile=jcommon-1.0.15.jar 

Couple of things to note:

artifactId cannot contain '.' ... not sure why but the install would fail if this contained '.'

Running the above command only generated a pom with maven 3.x. By adding the following arguments, I was able to get the jar's to be copied:

-DgeneratePom=true -DupdateReleaseInfo=true

Well and in case your third party library really is "nifty gui" all you need to do is to add the nifty maven repository to your pom.xml:

<repositories>
  <repository>
    <id>nifty-maven-repo.sourceforge.net</id>
    <url>http://nifty-gui.sourceforge.net/nifty-maven-repo</url>
  </repository>
</repositories>

and your maven project will automatically download nifty :D

PS: I know that this was not your actual question but it might help with nifty integration :)

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!