41

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

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

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:

[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]

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

1
  • I just run this line in cmd on Windows 7 and it works for Maven 3.0.5. Maybe they fixed it in this version. Commented Jun 13, 2013 at 13:13

10 Answers 10

111

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

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.

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" 

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.

Sign up to request clarification or add additional context in comments.

6 Comments

What a rubbish error message "The goal you specified requires a project to execute..." is.
+1. This works for me when using Console. CMD works as expected without quoting.
Similar to what flesk wrote, for Windows I get that error in powershell, not in cmd, thanks flesk
As an additional clarification, it's the dots messing up the powershell parsing. You only have to quote the arguments with a dot in them.
what is in your "cobra.jar" file?
|
8

Are you sure that you are executing the install-file goal? I checked your command and it works for me, but when I place a blank install :install-file (maybe you have this typo) the install goal would be used which needs a pom.xml.

Try to use the -X parameter to get more debug information:

 -X,--debug Produce execution debug output 

My system

Maven

c:\>mvn -version Apache Maven 3.0.3 (r1075438; 2011-02-28 18:31:09+0100) Maven home: C:\progs\apache-maven-3.0.3 Java version: 1.6.0_21, vendor: Sun Microsystems Inc. Java home: c:\Program Files (x86)\Java\jdk1.6.0_21\jre Default locale: de_DE, platform encoding: Cp1252 OS name: "windows 7", version: "6.1", arch: "x86", family: "windows" 

Install Plugin

c:\>mvn -Dplugin=install help:describe Name: Maven Install Plugin Description: Copies the project artifacts to the user's local repository. Group Id: org.apache.maven.plugins Artifact Id: maven-install-plugin Version: 2.3.1 Goal Prefix: install This plugin has 3 goals: install:help Description: Display help information on maven-install-plugin. Call mvn install:help -Ddetail=true -Dgoal=<goal-name> to display parameter details. install:install Description: Installs the project's main artifact in the local repository. install:install-file Description: Installs a file in the local repository. For more information, run 'mvn help:describe [...] -Ddetail' 

2 Comments

There is no such a typo. Can you tell the maven version which you use?
I have exactly that same versions... No idea really, maybe I will debug maven code and see what is happening there.
6

I found a bypass. You need to create a simple pom.xml like this :

<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>com.cobra</groupId> <artifactId>cobra</artifactId> <version>0.98.4</version> </project> 

It's not perfect but it's worked for me. If you find a better way to do that, I'm interested.

My config :

$mvn -version Apache Maven 3.0.3 (r1075438; 2011-02-28 18:31:09+0100) Maven home: /usr/local/maven Java version: 1.6.0_20, vendor: Sun Microsystems Inc. Java home: /usr/local/jdk1.6.0_20/jre Default locale: en_US, platform encoding: UTF-8 OS name: "linux", version: "2.6.32-25-generic-pae", arch: "i386", family: "unix" $mvn -Dplugin=install help:describe ... Name: Maven Install Plugin Description: Copies the project artifacts to the user's local repository. Group Id: org.apache.maven.plugins Artifact Id: maven-install-plugin Version: 2.3.1 Goal Prefix: install ... 

Comments

2

Using maven version 3.6.3, this worked for me to generate pom file in my chosen directory:

C:<MyChosenDir> mvn archetype:generate "-DgroupId=com.mycompany.app" "-DartifactId=my-app" "-DarchetypeArtifactId=maven-archetype-quickstart" "-DarchetypeVersion=1.4" "-DinteractiveMode=false" 

Comments

1

Try to run it on cmd.exe or execute cmd command before the mvn command.

1 Comment

I had same problem this will fix.
0

just go under your project directory where you can find your pom.xml file then execute the same command ! it works for me ;)

Comments

0

If you are having trouble with the command line version of Maven, you might want to try the M2E plugin for eclipse. It is far more user friendly for people without very much experience with Maven.

Comments

0

It worked for me when I changed Powershell to Cygwin. Powershell is somehow parsing the command line argument incorrectly.

Comments

0

I had that error when I was using maven in Windows, what worked for me was opening the cmd and not the PowerShell. Apparently certain errors appear when you don't do it with the cmd. I hope it works.

1 Comment

please provide more details for question like adding error or code etc
0

If you are getting this error during jenkins pipeline setup , Then the error is we are placing git repository without .git in jenkins git url blank .Generally we put website url of git repo but we need to place clone url of git repo.Insert .git (cloned url) to website url , Simply insert git clone url.

1 Comment

As it’s currently written, your answer is unclear. Please edit to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers in the help center.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.