I'm following the Maven tutorial on their site: https://maven.apache.org/guides/getting-started/index.html#how-do-i-make-my-first-maven-project
When I run the following Maven generate command I get an error about a missing POM.xml
file.
mvn -B archetype:generate -DgroupId=com.mycompany.app -DartifactId=my-app -DarchetypeArtifactId=maven-archetype-quickstart -DarchetypeVersion=1.4
The error is:
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.074 s
[INFO] Finished at: 2021-11-23T15:52:42Z
[INFO] ------------------------------------------------------------------------
[ERROR] The goal you specified requires a project to execute but there is no POM in this directory (C:\Users\Jay\Desktop\java-youtube). Please verify you invoked Maven from the correct directory. -> [Help 1]
The confusion I'm having is according to the tutorial a POM.xml
should be generated after running this command, but instead I get the error above.
Any idea what I'm doing wrong?
mvn --version
results:
Apache Maven 3.8.4 (9b656c72d54e5bacbed989b64718c159fe39b537)
Maven home: C:\Users\Jay\bin\apache-maven-3.8.4
Java version: 17, vendor: Oracle Corporation, runtime: C:\Users\Jay\.jabba\jdk\openjdk@1.17.0
Default locale: en_GB, platform encoding: Cp1252
OS name: "windows 10", version: "10.0", arch: "amd64", family: "windows"
If I run your script with PowerShell, I get the same error.
You can either change your shell or use the version that works with PowerShell:
mvn -B archetype:generate -D"groupId=com.mycompany.app" -D"artifactId=my-app" -D"archetypeArtifactId=maven-archetype-quickstart" -D"archetypeVersion=1.4"
This might be a duplicate of: Cannot run Maven using mvn -D
argument within Microsoft Powershell, but works in Command Prompt