Home > Enterprise >  How to speed up running speed of the mvn archetype:generate?
How to speed up running speed of the mvn archetype:generate?

Time:09-06

I was trying to run the following command:

mvn archetype:generate -D"groupId=com.example" -DartifactId="my-app" `
  -D"archetypeArtifactId=maven-archetype-quickstart" `
  -DarchetypeVersion="1.4" `
  -D"interactiveMode=false" -X

In this simple command, it took around 2 minute to complete. The hotspot of the total time is here:

[INFO] Generating project in Batch mode
[DEBUG] Searching for remote catalog: https://repo.maven.apache.org/maven2/archetype-catalog.xml

The archetype-catalog.xml has 12.3M in file size and the network speed of the repo.maven.apache.org site is slow. So that the total run time become very long.

Does Apache Maven have any cache mechanism for this can increase the run speed?

CodePudding user response:

I'm not sure about your connectivity issues (in my env your initial command takes about 10 seconds), however you may avoid consulting global catalog by specifying -DarchetypeCatalog=internal, smth. like:

mvn archetype:generate -DgroupId=com.example -DartifactId=my-app \
  -DarchetypeArtifactId=maven-archetype-quickstart \
  -DarchetypeGroupId=org.apache.maven.archetypes \
  -DarchetypeVersion=1.4 \
  -DarchetypeCatalog=internal \
  -DinteractiveMode=false -X

  • Related