I am using mvn archetype:generate -B ...
to generate a maven project.
It places the generated project in the current working directory.
Can this be customized to place the generated project in a directory I specify? I don't see any options to do so in the command line --help
menu.
You cannot specify a directory for archetype:generate
, this plugin always targets the current working directory.
The Maven Archetype docs suggest using the basedir
parameter. Something like this perhaps:
mvn archetype:generate
-DgroupId=foo
-DartifactId=bar
-Dbasedir=/some/other/directory
But, unfortuntately that doesn't work, even with that parameter specified the archetype is generated into the current working directory. Looking at the Maven Archetype JIRA I can see that there is an open issue for this:
https://issues.apache.org/jira/browse/ARCHETYPE-311
This issue has been open since April 2010 and it has been raised against version 2.2.0 of the archetype plugin and I have just verified that this issue still exists with in latest version of the archetype plugin, the following command completed but created bar
in the current working directory rather than in /some/other/path
...
mvn org.apache.maven.plugins:maven-archetype-plugin:3.0.1:generate
-DarchetypeArtifactId=maven-archetype-quickstart
-DinteractiveMode=false
-DgroupId=bar
-DartifactId=foo
-Dbasedir=/some/other/directory
So, if you want to use archetype:generate and you want the generated project to exist somewhere else then I think you might have to write a simple script which ...