How do you cache dependencies and speed up Maven builds in CI?
IntermediateConceptBuild Tools and Artifact Repositories
Answer
Cache ~/.m2/repository keyed on pom.xml hashes, use a mirror proxy, build with -T 1C for parallel module builds, skip work you do not need (-DskipTests in a package-only job, but never in the test job), and use -B batch mode with -ntp to suppress download progress logs.
mvn -B -ntp -T 1C verify
More on Build Tools and Artifact Repositories
What is Maven and what is its build lifecycle?BeginnerWhat is the difference between `mvn package`, `install` and `deploy`?BeginnerHow do Maven dependency scopes and transitive dependencies work?IntermediateWhat is `settings.xml` in Maven and how do CI builds use it?IntermediateWhat is the Maven Wrapper and why use it?BeginnerWhat is the difference between `npm install` and `npm ci`?Beginner