Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can't create maven project from console on Windows - error

I tried to generate maven project in Windows XP.

I created folder with pom.xml:

<project>
    <modelVersion>4.0.0</modelVersion>

    <groupId>selenium.web.driver</groupId>
    <artifactId>OMS_selenium_Test</artifactId>
    <version>1.0</version>

    <packaging>jar</packaging>
    <name>selenium_tests</name>

    <dependencies>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.0</version>
            <scope></scope>
        </dependency>
    </dependencies>
</project>

Opened cmd and going into this folder.

Run the next command:

C:\Documents and Settings\Admintemp\maven_test>mvn archetype:generate -DgroupId=
selenium.web.driver -DartifactId=OMS_selenium_Test -Dversion=1.0-SNAPSHOT -Dinte
ractiveMode=false

Instead of generating project with this data I caught next errror:

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-archetype-plugin:2
.2:generate (default-cli) on project OMS_selenium_Test: Unable to add module to
the current project as it is not of packaging type 'pom' -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e swit
ch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please rea
d the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureExc
eption

Why this exactly happen? Maybe I miss smt, but I can't figure out what exactly...

  • How to solve this trouble and generate project with maven?
like image 288
catch23 Avatar asked Oct 23 '13 11:10

catch23


2 Answers

Your mistake has been to create a POM file by hand. Maven will do this automatically when you run the command you attempted. Delete your POM file and try running the command again.

Maven assumed you wanted to add a sub-module to an existing Maven project. This failed because your existing POM file was "jar" project (e.g. normal Java code) when it was expecting a "pom" project.

like image 73
Duncan Jones Avatar answered Sep 22 '22 02:09

Duncan Jones


This happens when you run the generate command from within the same folder where you ran the mvn archetype:create-from-project from (or in this case, the POM you generated made maven think this was an existing project).

Ernestas answer worked because they switched to a different folder and ran the same command.

like image 37
max Avatar answered Sep 21 '22 02:09

max