maven generating pom file
Asked Answered
Q

10

38

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?

Queeniequeenly answered 15/7, 2011 at 9:5 Comment(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.Queeniequeenly
C
103

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.

Chambless answered 26/6, 2012 at 2:2 Comment(6)
What a rubbish error message "The goal you specified requires a project to execute..." is.Numbers
+1. This works for me when using Console. CMD works as expected without quoting.Mazzola
Similar to what flesk wrote, for Windows I get that error in powershell, not in cmd, thanks fleskStriker
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.Kwa
Wow, I just found this out and I am so angry.Tripod
what is in your "cobra.jar" file?Balanchine
W
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'
Willardwillcox answered 15/7, 2011 at 20:22 Comment(2)
There is no such a typo. Can you tell the maven version which you use?Queeniequeenly
I have exactly that same versions... No idea really, maybe I will debug maven code and see what is happening there.Queeniequeenly
P
5

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
...
Proserpina answered 18/7, 2011 at 12:18 Comment(0)
G
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"
Glyptodont answered 17/1, 2021 at 1:37 Comment(0)
C
1

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

Consign answered 1/7, 2013 at 14:58 Comment(1)
I had same problem this will fix.Consign
P
0

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

Pantry answered 19/2, 2015 at 9:36 Comment(0)
B
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.

Bitterling answered 12/4, 2016 at 2:5 Comment(0)
C
0

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

Constipate answered 9/10, 2016 at 13:50 Comment(0)
D
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.

Daye answered 1/4, 2020 at 22:53 Comment(1)
please provide more details for question like adding error or code etcVelasco
N
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.

Naji answered 1/9, 2022 at 16:24 Comment(1)
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.Soredium

© 2022 - 2024 — McMap. All rights reserved.