๐— ๐—ผ๐—ฑ๐˜‚๐—น๐—ฒ-๐Ÿฏ :ย ๐—บ๐˜ƒ๐—ป ๐—ฝ๐—ฎ๐—ฐ๐—ธ๐—ฎ๐—ด๐—ฒ : ๐—ง๐—ต๐—ถ๐—ป๐—ด๐˜€ ๐—ฏ๐—ฒ๐—ต๐—ถ๐—ป๐—ฑ ๐—บ๐˜ƒ๐—ป ๐—ฝ๐—ฎ๐—ฐ๐—ธ๐—ฎ๐—ด๐—ฒ

๐— ๐—ผ๐—ฑ๐˜‚๐—น๐—ฒ : ๐Ÿฌ๐Ÿฐ : ๐—บ๐˜ƒ๐—ป ๐—ฝ๐—ฎ๐—ฐ๐—ธ๐—ฎ๐—ด๐—ฒ : ๐—ง๐—ต๐—ถ๐—ป๐—ด๐˜€ ๐—ฏ๐—ฒ๐—ต๐—ถ๐—ป๐—ฑ ๐—บ๐˜ƒ๐—ป ๐—ฝ๐—ฎ๐—ฐ๐—ธ๐—ฎ๐—ด๐—ฒ

” ฬฒ๐š–ฬฒ๐šŸฬฒ๐š—ฬฒโ€‚ฬฒ๐š™ฬฒ๐šŠฬฒ๐šŒฬฒ๐š”ฬฒ๐šŠฬฒ๐šฬฒ๐šŽฬฒ “: Things behind mvn package
Many beginners think Maven is just a command like : mvn package

๐— ๐—ฎ๐˜ƒ๐—ฒ๐—ป ๐—ถ๐˜€ ๐—ฎ ๐—ฏ๐˜‚๐—ถ๐—น๐—ฑ ๐—ฎ๐˜‚๐˜๐—ผ๐—บ๐—ฎ๐˜๐—ถ๐—ผ๐—ป ๐˜๐—ผ๐—ผ๐—น ๐—ณ๐—ผ๐—ฟ ๐—๐—ฎ๐˜ƒ๐—ฎ ๐—ฝ๐—ฟ๐—ผ๐—ท๐—ฒ๐—ฐ๐˜๐˜€.

It handles:

– Building code
– Managing dependencies
– Automating the build process

In short : ๐— ๐—ฎ๐˜ƒ๐—ฒ๐—ป = ๐—•๐˜‚๐—ถ๐—น๐—ฑ + ๐——๐—ฒ๐—ฝ๐—ฒ๐—ป๐—ฑ๐—ฒ๐—ป๐—ฐ๐˜† ๐— ๐—ฎ๐—ป๐—ฎ๐—ด๐—ฒ๐—บ๐—ฒ๐—ป๐˜ + ๐—”๐˜‚๐˜๐—ผ๐—บ๐—ฎ๐˜๐—ถ๐—ผ๐—ป

Instead of manually compiling code, downloading libraries, running tests, and packaging applications, Maven automates everything using a ๐—ฏ๐˜‚๐—ถ๐—น๐—ฑ ๐—น๐—ถ๐—ณ๐—ฒ๐—ฐ๐˜†๐—ฐ๐—น๐—ฒ.

๐—ช๐—ต๐—ฎ๐˜ ๐—ถ๐˜€ ๐— ๐—ฎ๐˜ƒ๐—ฒ๐—ป ๐—Ÿ๐—ถ๐—ณ๐—ฒ๐—ฐ๐˜†๐—ฐ๐—น๐—ฒ?

A Maven Lifecycle is a predefined sequence of steps used to build and deliver an application. One command triggers multiple phases automatically.

 ๐˜Œ๐˜น๐˜ข๐˜ฎ๐˜ฑ๐˜ญ๐˜ฆ : ๐˜ฎ๐˜ท๐˜ฏ ๐˜ฑ๐˜ข๐˜ค๐˜ฌ๐˜ข๐˜จ๐˜ฆ
 ๐˜›๐˜ฉ๐˜ช๐˜ด ๐˜ณ๐˜ถ๐˜ฏ๐˜ด  ๐˜ƒ๐—ฎ๐—น๐—ถ๐—ฑ๐—ฎ๐˜๐—ฒ โ†’ ๐—ฐ๐—ผ๐—บ๐—ฝ๐—ถ๐—น๐—ฒ โ†’ ๐˜๐—ฒ๐˜€๐˜ โ†’ ๐—ฝ๐—ฎ๐—ฐ๐—ธ๐—ฎ๐—ด๐—ฒ

๐—ช๐—ต๐˜† ๐— ๐—ฎ๐˜ƒ๐—ฒ๐—ป ๐—Ÿ๐—ถ๐—ณ๐—ฒ๐—ฐ๐˜†๐—ฐ๐—น๐—ฒ ๐—˜๐˜…๐—ถ๐˜€๐˜๐˜€
Before Maven:
– Developers compiled code manually
– Dependencies downloaded manually
– Tests executed manually
– Packaging done manually

Problems:
– Inconsistent builds
– Human errors
– โ€œWorks on my machineโ€ issues
– Dependency conflicts

๐— ๐—ฎ๐˜ƒ๐—ฒ๐—ป ๐—ถ๐—ป๐˜๐—ฟ๐—ผ๐—ฑ๐˜‚๐—ฐ๐—ฒ๐—ฑ ๐—ฎ ๐˜€๐˜๐—ฎ๐—ป๐—ฑ๐—ฎ๐—ฟ๐—ฑ๐—ถ๐˜‡๐—ฒ๐—ฑ ๐—ฎ๐˜‚๐˜๐—ผ๐—บ๐—ฎ๐˜๐—ฒ๐—ฑ ๐—ฏ๐˜‚๐—ถ๐—น๐—ฑ ๐—ฝ๐—ฟ๐—ผ๐—ฐ๐—ฒ๐˜€๐˜€.

Key Outcomes :

  • Standardized builds
  • Automated workflows
  • Repeatable builds
  • CI/CD friendly

๐— ๐—ฎ๐˜ƒ๐—ฒ๐—ป ๐—›๐—ฎ๐˜€ ๐Ÿฏ ๐—Ÿ๐—ถ๐—ณ๐—ฒ๐—ฐ๐˜†๐—ฐ๐—น๐—ฒ๐˜€

1๏ธโƒฃ Default Lifecycle : Builds and deploys the application.
2๏ธโƒฃ Clean Lifecycle : Removes previous build files.
3๏ธโƒฃ Site Lifecycle : Generates project documentation.

โ€€ฬฒ”ฬฒโ€€ฬฒ๐™ผฬฒ๐š˜ฬฒ๐šœฬฒ๐šฬฒโ€€ฬฒ๐™ณฬฒ๐šŽฬฒ๐šŸฬฒ๐™พฬฒ๐š™ฬฒ๐šœฬฒโ€€ฬฒ๐š™ฬฒ๐š’ฬฒ๐š™ฬฒ๐šŽฬฒ๐š•ฬฒ๐š’ฬฒ๐š—ฬฒ๐šŽฬฒ๐šœฬฒโ€€ฬฒ๐š–ฬฒ๐šŠฬฒ๐š’ฬฒ๐š—ฬฒ๐š•ฬฒ๐šขฬฒโ€€ฬฒ๐šžฬฒ๐šœฬฒ๐šŽฬฒโ€€ฬฒ๐šฬฒ๐š‘ฬฒ๐šŽฬฒโ€€ฬฒ๐™ณฬฒ๐šŽฬฒ๐šฬฒ๐šŠฬฒ๐šžฬฒ๐š•ฬฒ๐šฬฒโ€€ฬฒ๐™ปฬฒ๐š’ฬฒ๐šฬฒ๐šŽฬฒ๐šŒฬฒ๐šขฬฒ๐šŒฬฒ๐š•ฬฒ๐šŽฬฒโ€€ฬฒ”ฬฒ

๐——๐—ฒ๐—ณ๐—ฎ๐˜‚๐—น๐˜ ๐—Ÿ๐—ถ๐—ณ๐—ฒ๐—ฐ๐˜†๐—ฐ๐—น๐—ฒ ๐—ฃ๐—ต๐—ฎ๐˜€๐—ฒ๐˜€ :Order matters.

1 validate
2 compile
3 test
4 package
5 verify
6 install
7 deploy

” ๐—ฅ๐˜‚๐—ป๐—ป๐—ถ๐—ป๐—ด ๐—ฎ ๐—น๐—ฎ๐˜๐—ฒ๐—ฟ ๐—ฝ๐—ต๐—ฎ๐˜€๐—ฒ ๐—ฒ๐˜…๐—ฒ๐—ฐ๐˜‚๐˜๐—ฒ๐˜€ ๐—ฒ๐˜ƒ๐—ฒ๐—ฟ๐˜†๐˜๐—ต๐—ถ๐—ป๐—ด ๐—ฏ๐—ฒ๐—ณ๐—ผ๐—ฟ๐—ฒ ๐—ถ๐˜.

Example: mvn deploy

Runs all phases from validate โ†’ deploy. ‘

๐—œ๐—บ๐—ฝ๐—ผ๐—ฟ๐˜๐—ฎ๐—ป๐˜ ๐—ฃ๐—ต๐—ฎ๐˜€๐—ฒ๐˜€ ๐—˜๐˜…๐—ฝ๐—น๐—ฎ๐—ถ๐—ป๐—ฒ๐—ฑ

๐Ÿญ ๐˜ƒ๐—ฎ๐—น๐—ถ๐—ฑ๐—ฎ๐˜๐—ฒ : ๐—–๐—ต๐—ฒ๐—ฐ๐—ธ๐˜€ ๐—ฝ๐—ฟ๐—ผ๐—ท๐—ฒ๐—ฐ๐˜ ๐˜€๐˜๐—ฟ๐˜‚๐—ฐ๐˜๐˜‚๐—ฟ๐—ฒ ๐—ฎ๐—ป๐—ฑ ๐—ฝ๐—ผ๐—บ.๐˜…๐—บ๐—น.
Command: mvn validate

๐Ÿฎ ๐—ฐ๐—ผ๐—บ๐—ฝ๐—ถ๐—น๐—ฒ : ๐—–๐—ผ๐—บ๐—ฝ๐—ถ๐—น๐—ฒ๐˜€ ๐˜€๐—ผ๐˜‚๐—ฟ๐—ฐ๐—ฒ ๐—ฐ๐—ผ๐—ฑ๐—ฒ.
.java โ†’ .class

Output : target/classes
Command: mvn compile

๐Ÿฏ ๐˜๐—ฒ๐˜€๐˜ : ๐—ฅ๐˜‚๐—ป๐˜€ ๐˜‚๐—ป๐—ถ๐˜ ๐˜๐—ฒ๐˜€๐˜๐˜€ (๐—๐—จ๐—ป๐—ถ๐˜, ๐—ง๐—ฒ๐˜€๐˜๐—ก๐—š).
Command: mvn test

๐Ÿฐ ๐—ฝ๐—ฎ๐—ฐ๐—ธ๐—ฎ๐—ด๐—ฒ : ๐—–๐—ฟ๐—ฒ๐—ฎ๐˜๐—ฒ๐˜€ ๐—ฎ๐—ฝ๐—ฝ๐—น๐—ถ๐—ฐ๐—ฎ๐˜๐—ถ๐—ผ๐—ป ๐—ฝ๐—ฎ๐—ฐ๐—ธ๐—ฎ๐—ด๐—ฒ.
Examples:
.jar โ†’ Java / Spring Boot apps
.war โ†’ Web applications

Output example: target/myapp-1.0.jar
Command: mvn package

๐Ÿฑ ๐˜ƒ๐—ฒ๐—ฟ๐—ถ๐—ณ๐˜† : ๐—ฅ๐˜‚๐—ป๐˜€ ๐—ฎ๐—ฑ๐—ฑ๐—ถ๐˜๐—ถ๐—ผ๐—ป๐—ฎ๐—น ๐—ฐ๐—ต๐—ฒ๐—ฐ๐—ธ๐˜€ ๐—น๐—ถ๐—ธ๐—ฒ ๐—ถ๐—ป๐˜๐—ฒ๐—ด๐—ฟ๐—ฎ๐˜๐—ถ๐—ผ๐—ป ๐˜๐—ฒ๐˜€๐˜๐˜€ ๐—ผ๐—ฟ ๐—พ๐˜‚๐—ฎ๐—น๐—ถ๐˜๐˜† ๐—ฐ๐—ต๐—ฒ๐—ฐ๐—ธ๐˜€.

๐Ÿฒ ๐—ถ๐—ป๐˜€๐˜๐—ฎ๐—น๐—น : ๐—ฆ๐˜๐—ผ๐—ฟ๐—ฒ๐˜€ ๐˜๐—ต๐—ฒ ๐—ฏ๐˜‚๐—ถ๐—น๐˜ ๐—ฎ๐—ฟ๐˜๐—ถ๐—ณ๐—ฎ๐—ฐ๐˜ ๐—ถ๐—ป ๐˜๐—ต๐—ฒ ๐—น๐—ผ๐—ฐ๐—ฎ๐—น ๐— ๐—ฎ๐˜ƒ๐—ฒ๐—ป ๐—ฟ๐—ฒ๐—ฝ๐—ผ๐˜€๐—ถ๐˜๐—ผ๐—ฟ๐˜†.

Location:
~/.m2/repository
Allows other local projects to use it.

Command: mvn install

๐Ÿณ ๐—ฑ๐—ฒ๐—ฝ๐—น๐—ผ๐˜† : ๐—จ๐—ฝ๐—น๐—ผ๐—ฎ๐—ฑ๐˜€ ๐˜๐—ต๐—ฒ ๐—ฎ๐—ฟ๐˜๐—ถ๐—ณ๐—ฎ๐—ฐ๐˜ ๐˜๐—ผ ๐—ฎ ๐—ฟ๐—ฒ๐—บ๐—ผ๐˜๐—ฒ ๐—ฟ๐—ฒ๐—ฝ๐—ผ๐˜€๐—ถ๐˜๐—ผ๐—ฟ๐˜†.
Common repositories:
– Nexus
– Artifactory
– GitHub Packages
– AWS CodeArtifact
Command: mvn deploy

(Usually executed in CI/CD pipelines.)

๐—ž๐—ฒ๐˜† ๐—ฃ๐—ผ๐—ถ๐—ป๐˜

๐—ฅ๐˜‚๐—ป๐—ป๐—ถ๐—ป๐—ด ๐—ฎ ๐— ๐—ฎ๐˜ƒ๐—ฒ๐—ป ๐—ฐ๐—ผ๐—บ๐—บ๐—ฎ๐—ป๐—ฑ ๐˜๐—ฟ๐—ถ๐—ด๐—ด๐—ฒ๐—ฟ๐˜€ ๐—ฎ๐—ป ๐—ฎ๐˜‚๐˜๐—ผ๐—บ๐—ฎ๐˜๐—ฒ๐—ฑ ๐—ฏ๐˜‚๐—ถ๐—น๐—ฑ ๐—ฝ๐—ถ๐—ฝ๐—ฒ๐—น๐—ถ๐—ป๐—ฒ, ๐—ป๐—ผ๐˜ ๐—ท๐˜‚๐˜€๐˜ ๐—ฎ ๐˜€๐—ถ๐—ป๐—ด๐—น๐—ฒ ๐˜€๐˜๐—ฒ๐—ฝ.

Leave a Comment