Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error when creating a new maven project

When I try create a new maven project (with several archetypes, not only the one below), I am facing this error:

Unable to create project from archetype [org.apache.maven.archetypes:maven-archetype-quickstart:RELEASE]
Unable to add module to the current project as it is not of packaging type 'pom'

Anyone know why this is happening, and how to solve it?

like image 269
Kleber Mota Avatar asked Apr 22 '14 10:04

Kleber Mota


People also ask

How do I resolve project build error in POM xml?

You can usually resolve these errors by updating Maven dependencies as follows: Right-click on your top-level project (not on the pom. xml file) in the Project Explorer view. From the menu, choose Maven > Update project.

How do I fix POM xml error in Eclipse?

Additionally,right click on the pom. xml file in the 'project explorer' > click on 'validate'. This should remove the red-error mark on file, if there are no problems in the XML configuration.


4 Answers

It seems that your directory is not empty. this command line works for me: (in an empty directory)

mvn archetype:generate -DgroupId=fr.myGroupId -DartifactId=MyApplication -Dpackagename=fr.myGroupId -DarchetypeArtifactId=maven-archetype-quickstart

the result is:

[INFO] Using property: groupId = fr.myGroupId
[INFO] Using property: artifactId = MyApplication
Define value for property 'version':  1.0-SNAPSHOT: : 
[INFO] Using property: package = fr.myGroupId
Confirm properties configuration:
groupId: fr.myGroupId
artifactId: MyApplication2
version: 1.0-SNAPSHOT
package: fr.myGroupId
 Y: : 
[INFO] ----------------------------------------------------------------------------
[INFO] Using following parameters for creating project from Old (1.x) Archetype: maven-archetype-quickstart:1.0
[INFO] ----------------------------------------------------------------------------
[INFO] Parameter: groupId, Value: fr.myGroupId
[INFO] Parameter: packageName, Value: fr.myGroupId
[INFO] Parameter: package, Value: fr.myGroupId
[INFO] Parameter: artifactId, Value: MyApplication2
[INFO] Parameter: basedir, Value: /home/ABC-OBJECTIF/philippe.demanget/workspace/pdemanget/tmp/mvn
[INFO] Parameter: version, Value: 1.0-SNAPSHOT
[INFO] project created from Old (1.x) Archetype in dir: /home/ABC-OBJECTIF/philippe.demanget/workspace/pdemanget/tmp/mvn/MyApplication2
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 9.764s
[INFO] Finished at: Tue Apr 22 13:35:17 CEST 2014
[INFO] Final Memory: 14M/216M
[INFO] ------------------------------------------------------------------------

I can reproduce your error by doing this command line inside the newly created directory:

cd MyApplication
mvn archetype:create -DgroupId=fr.myGroupId -DartifactId=MyApplication -Dpackagename=fr.myGroupId -DarchetypeArtifactId=maven-archetype-quickstart
[...] [INFO] BUILD FAILURE
like image 195
pdem Avatar answered Oct 12 '22 23:10

pdem


I got the same issue, solved by manually removing a unused pom.xml file at the root of workspace directory

like image 36
Florent Barreau Avatar answered Oct 13 '22 00:10

Florent Barreau


You have to remove the already existing pom.xml or if you need it to execute the maven command, try adding <packaging>pom</packaging> to your pom.

Since if you have an already existing in the current directory, it should match with the package structure. It is always to good to start with no pom file in the parent directory.

This should work.

like image 43
Prasanna Muppidi Avatar answered Oct 13 '22 00:10

Prasanna Muppidi


I was having the same problem using Windows PowerShell in a newly created directory with nothing in it. I tried the command using the regular Windows Command Prompt, and it worked fine.

like image 37
Jonathan Avatar answered Oct 13 '22 01:10

Jonathan