enterprize
enterprize

Reputation: 1179

maven error BUILD FAILURE

I am following a maven tutorial. I am trying to execute this command which is my 1st maven command. Tutorial says it will crate a directory named my-app, but it didn't. This is command & its output, command:

mvn archetype:generate -DgroupId=com.mycompany.app -DartifactId=my-app -DarchetypeArtifactId=maven-archetype-quickstart -DinteractiveMode=false

output:

C:\Users\Babar>mvn archetype:generate -DgroupId=com.mycompany.app -DartifactId=m
y-app -DarchetypeArtifactId=maven-archetype-quickstart -DinteractiveMode=false
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building Maven Stub Project (No POM) 1
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] >>> maven-archetype-plugin:2.1:generate (default-cli) @ standalone-pom >>
>
[INFO]
[INFO] <<< maven-archetype-plugin:2.1:generate (default-cli) @ standalone-pom <<
<
[INFO]
[INFO] --- maven-archetype-plugin:2.1:generate (default-cli) @ standalone-pom --
-
[INFO] Generating project in Batch mode
[INFO] -------------------------------------------------------------------------
---
[INFO] Using following parameters for creating project from Old (1.x) Archetype:
 maven-archetype-quickstart:1.0
[INFO] -------------------------------------------------------------------------
---
[INFO] Parameter: groupId, Value: com.mycompany.app
[INFO] Parameter: packageName, Value: com.mycompany.app
[INFO] Parameter: package, Value: com.mycompany.app
[INFO] Parameter: artifactId, Value: my-app
[INFO] Parameter: basedir, Value: C:\Users\Babar
[INFO] Parameter: version, Value: 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 22.971s
[INFO] Finished at: Fri Nov 18 00:07:12 EET 2011
[INFO] Final Memory: 6M/11M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-archetype-plugin:2
.1:generate (default-cli) on project standalone-pom: Directory my-app already ex
ists - please run from a clean directory -> [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
'cmd' is not recognized as an internal or external command,
operable program or batch file.

error msg says directory already exists but it's not. I execute this command more than oncw

EDIT

command(suggested in answer)

mvn archetype:generate -DarchetypeGroupId=org.apache.maven.archet
    ypes -DarchetypeArtifactId=maven-archetype-quickstart -DarchetypeVersion=5-SNAPS
    HOT

OUTPUT

C:\Users\Babar>mvn archetype:generate -DarchetypeGroupId=org.apache.maven.archet
ypes -DarchetypeArtifactId=maven-archetype-quickstart -DarchetypeVersion=5-SNAPS
HOT
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building Maven Stub Project (No POM) 1
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] >>> maven-archetype-plugin:2.1:generate (default-cli) @ standalone-pom >>
>
[INFO]
[INFO] <<< maven-archetype-plugin:2.1:generate (default-cli) @ standalone-pom <<
<
[INFO]
[INFO] --- maven-archetype-plugin:2.1:generate (default-cli) @ standalone-pom --
-
[INFO] Generating project in Interactive mode
[INFO] Archetype repository missing. Using the one from [org.apache.maven.archet
ypes:maven-archetype-quickstart:1.1] found in catalog remote
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 5.552s
[INFO] Finished at: Fri Nov 18 01:09:15 EET 2011
[INFO] Final Memory: 6M/12M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-archetype-plugin:2
.1:generate (default-cli) on project standalone-pom: The desired archetype does
not exist (org.apache.maven.archetypes:maven-archetype-quickstart:5-SNAPSHOT) ->
 [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
'cmd' is not recognized as an internal or external command,
operable program or batch file.

Upvotes: 6

Views: 85423

Answers (7)

 MUKUL RANA
MUKUL RANA

Reputation: 21

For windows 10 and 11 also, the maven version 3+

we need to add the "double quotes" means the link u r pasting have "com.mycompany.app" may be because of parsing or compiler it couldn't able to get without quotes

and also make sure that u have edit the enviroment path perfectly to run mvn

thanks to others stack overflow contributor as well as chatgpt couldn't able to revolve at that time now may be it will.

data 09/03/2024

mvn archetype:generate -DgroupId="com.mycompany.app" -DartifactId=my-app -DarchetypeArtifactId=maven-archetype-quickstart -DinteractiveMode=false

Upvotes: 0

Anas Satti
Anas Satti

Reputation: 11

I faced the same issue, and I resolved by run the commond(MVN Clean) from inside the folder where pom.xml located. Please follow below steps:

  1. Open Eclipse
  2. Open your Maven project.
  3. Right Click on pom.xml
  4. Click on properties 5.Copy pom.xml location URL
  5. Open cmd
  6. Write and paste the pom.xml location in the cmd until before /pom.xml as below, cd C:\Users\X\eclipse-workspace\Your project Name
  7. Hit Enter.
  8. Run mvn clean commond again.

Upvotes: 1

Ansoo Lee
Ansoo Lee

Reputation: 21

  1. Close your eclipse
  2. Delete the .m2 folder which shows the server connnection
  3. Re-run your eclipse.

Upvotes: 2

user3460302
user3460302

Reputation: 31

Try this :

mvn archetype:generate -DgroupId="com.mycompany.app" -DartifactId=my-app -DarchetypeArtifactId=maven-archetype-quickstart -DinteractiveMode=false

Your sentences have been modified -DgroupId="com.mycompany.app". You need to use double quotes.

I´ve worked on windows 8 and it works. I don´t know if it happens on Linux.

Upvotes: 3

Eric Yu
Eric Yu

Reputation: 29

Try this one, it works for maven 3-3-9 for win7 32bit

mvn archetype:generate -DgroupId="com.mycompany.app" -DartifactId=my-app -DarchetypeArtifactId=maven-archetype-quickstart -DinteractiveMode=false

Upvotes: 1

Sri Sankaran
Sri Sankaran

Reputation: 8310

You will note that the original error said

Directory my-app already exists - please run from a clean directory

Did you possibly run that command from a directory where there is already a Maven project (one with a pom.xml file)? If so please start with a clean location.

When I ran the command you used verbatim on an empty directory, it ran without error and created a directory called my-app.

Upvotes: 0

dMb
dMb

Reputation: 9337

This line is of concern:

[INFO] Using following parameters for creating project from Old (1.x) Archetype: maven-archetype-quickstart:1.0

Looking at the maven docs page at http://maven.apache.org/archetype/maven-archetype-bundles/maven-archetype-quickstart/, i see that the command you should be using is:

mvn archetype:generate -DarchetypeGroupId=org.apache.maven.archetypes -DarchetypeArtifactId=maven-archetype-quickstart -DarchetypeVersion=5-SNAPSHOT

Which is not exactly what you are running (you are missing the -DarchetypeVersion=5-SNAPSHOT part).

Upvotes: 0

Related Questions