Maven Life Cycles

Compile : .java → .class (/target)


Package : .class → .jar (/target/sample-1.0.2-SNAPSHOT.jar) — same as .exe zip

Install : .jar → copies in local mvn repository ( local — /.m2/…)

deploy: .jar → push to public server — for other developers

Cash: cash something for other job(stages) to use

cf. How to change Java version
Permanently changing

  • /.M2 : Home directory of where the mvn commands are running ~/.m2
    This is where .jar and .class are stored/cached
  • Mvn needs to bring from public repository?

→ done by surefire plugin (default, no need to download or configure)
Results are generated … Results are .txt & .xml … html (by surefire report plugin)


This will build jar files(.exe) in the /target directory
uses maven-jar-plugin(JAR) or maven-war-plugin(WAR)
Final JAR and WAR file = SNAPSHOT (project-4.2.5-SNAPSHOT)
+ can also skip tests

→ save the war (snapshot) in ‘registry’

ex. in gitlab to use ‘deploy’ stage → save in package registry(snapshot)
>create ci-settings.xml in project directory (with job-token)
>change pom.xml file with the url & project ID
>gitlab-ci.yml file change → Refer to this website :

Refer to :
Cash → multiple PATHs ( — /target, — .m2/…) → PATH is what you want to cache …. normally pushes to external repository googleapi something..
Jobs pick up the cash by KEY of cash

Maven Repository

Maven uses 3 repositories

  • Local repository (.m2)
  • Central repository (Maven Central)
  • Remote repository (Nexus, Gitlab)

Sequence >>
1. Search in local repository → .m2
2. Search in Central repository
3. Remote repository

To manually input a local repository (if not default will be $HOME/.m2)
- Change the [maven installation directory]/conf/settings.xml
There is a <localrepository> section → change this!
- Or input by parameter during mvn command execution
→ mvn clean installorwhatever