Generating Maven projects in batch mode using PowerShell
It just took me 75 minutes to create a Maven quickstart project on Windows 10 using PowerShell in batch mode.
DONT MAKE MY MISTAKES.
Do the following instead:
- Provide all mandatory parameters or batch mode won’t work. This is poorly documented in the official Maven tutorial, but correctly documented here:
-B
for batch mode or-DinteractiveMode=false
instead-DarchetypeGroupId=org.apache.maven.archetypes
-DarchetypeArtifactId=maven-archetype-quickstart
-DarchetypeVersion=1.1
-DgroupId=com.example
-DartifactId=app
-Dversion=1.0-SNAPSHOT
-Dpackage=com.example.project
- In PowerShell you have to use double quotes around every parameter, e.g.
"-DgroupId=com.example"
- Don’t use line breaks in your
archetype:generate
command.
Full example:
mvn archetype:generate -B "-DarchetypeGroupId=org.apache.maven.archetypes" "-DarchetypeArtifactId=maven-archetype-quickstart" "-DarchetypeVersion=1.1" "-DgroupId=com.example" "-DartifactId=app" "-Dversion=1.0-SNAPSHOT" "-Dpackage=com.example.project"