# Maven for devops

<mark>Today, I took a deeper dive into Apache Maven, a powerful build automation tool primarily used for Java projects. I practiced building a project with Maven and deployed the final artifact to an EC2 instance for testing. Here’s what I learned and implemented</mark>

**<mark>📘 What is Maven?</mark>**

<mark>Apache Maven is a build automation and dependency management tool. It simplifies the build process, especially for Java applications, by:</mark>

* <mark>Managing project structure and build lifecycle</mark>
    
* <mark>Automatically handling dependencies (via the pom.xml file)</mark>
    
* <mark>Generating reproducible builds across different environments</mark>
    
* <mark>Making collaboration easier with a standardized project layout</mark>
    
* <mark>my-app/</mark>
    
* <mark>├── src/ │</mark>
    
* <mark>└── main/ │</mark>
    
* <mark>└── java/ │ └── com/example/</mark>[<mark>App.java</mark>](http://App.java) <mark> ├</mark>
    
* <mark>── target/</mark>
    
* <mark># Compiled code and final build go here ├── pom.xml # Project Object Model (configuration file)</mark>
    

**<mark>⚙️ Maven Lifecycle Phases I Used Today:</mark>**

<mark>Maven has a default build lifecycle with phases. Here’s what I used:</mark>

### **Cleans up the target directory (removes old builds)**

mvn clean

### Compiles the source code

mvn compile

### Packages the compiled code into a .jar or .war file

mvn package

## result JAR file located in the target/ folder — ready for deployment!
