This project demonstrates how to build Java applications using Maven in a real-world DevOps workflow.
It covers the complete flow:
Raw Code (.java) β Build β Test β Artifact β Deployment
π The final output is called an Artifact (JAR/WAR/EAR file)
Maven is a build and project management tool used to:
-
Manage dependencies
-
Build applications
-
Run tests
-
Generate artifacts
-
Maintain project structure
-
Developed by: Apache Software Foundation
-
Language: Java
-
First released: 2004
-
Maven Home Directory:
~/.m2
| Type | Description |
|---|---|
.jar |
Java Archive (Backend code) |
.war |
Web Archive (Frontend + Backend) |
.ear |
Enterprise Archive (JAR + WAR) |
.java β .class β .jar
.javaβ Source code.classβ Compiled bytecode.jarβ Final artifact
-
Stands for Project Object Model
-
Contains:
- Project details
- Dependencies
- Plugins
- Build configuration
sudo yum install git maven tree -ymvn -vgit clone https://github.com/SumanAddi/All-About-MAVEN.git
cd java-project-maven-newtreeA goal is a task executed by Maven.
mvn validatemvn compile- Converts
.javaβ.class - Output stored in
target/
mvn test- Runs unit tests
mvn package- Creates artifact (
.jar/.war)
mvn install- Copies artifact to local repo (
~/.m2)
mvn clean- Deletes
target/folder
mvn clean package- Cleans + Builds + Packages in one step
Validate β Compile β Test β Package β Install β Deploy
- Small tools used by Maven
- Automatically downloaded when needed
- Help automate tasks
- No proper project structure
- Difficult dependency management
- Manual build process
- No easy artifact creation
| Language | Tool |
|---|---|
| Java | Maven / Gradle |
| Python | pip / poetry |
| Node.js | npm |
| C/C++ | Make |
| .NET | MSBuild |
| Feature | Maven | ANT |
|---|---|---|
| Type | Build + Project Tool | Build Tool |
| Config File | pom.xml |
build.xml |
| Lifecycle | Yes | No |
| Reusability | High | Low |
| Approach | Declarative | Procedural |
-
Handles required libraries automatically
-
Supports:
- Transitive dependencies
- Version control
- Scope (test, compile, etc.)
- Local Repo β
~/.m2 - Central Repo β Online Maven repo
- Run commands in project root (where
pom.xmlexists) - Check Java version compatibility
- Use:
mvn help:effective-pom
mvn dependency:treeMaven simplifies the build process by:
- Managing dependencies
- Automating builds
- Creating artifacts
- Maintaining project consistency