Skip to content

SumanAddi/Java-project-maven-new

Β 
Β 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

73 Commits
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸš€ Maven Build Project - DevOps Practice

πŸ“Œ Overview

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)


🧠 What is Maven?

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


πŸ“¦ Types of Artifacts

Type Description
.jar Java Archive (Backend code)
.war Web Archive (Frontend + Backend)
.ear Enterprise Archive (JAR + WAR)

πŸ”„ Java Build Flow

.java β†’ .class β†’ .jar
  • .java β†’ Source code
  • .class β†’ Compiled bytecode
  • .jar β†’ Final artifact

πŸ“ Important File

πŸ”Ή pom.xml

  • Stands for Project Object Model

  • Contains:

    • Project details
    • Dependencies
    • Plugins
    • Build configuration

πŸ§ͺ Lab Setup (AWS EC2 - Amazon Linux)

Step 1: Install Required Tools

sudo yum install git maven tree -y

Step 2: Verify Maven

mvn -v

Step 3: Clone Project

git clone https://github.com/SumanAddi/All-About-MAVEN.git
cd java-project-maven-new

Step 4: View Structure

tree

βš™οΈ Maven Lifecycle & Commands

πŸ”Ή Maven Goals

A goal is a task executed by Maven.


1️⃣ Validate

mvn validate

2️⃣ Compile

mvn compile
  • Converts .java β†’ .class
  • Output stored in target/

3️⃣ Test

mvn test
  • Runs unit tests

4️⃣ Package

mvn package
  • Creates artifact (.jar / .war)

5️⃣ Install

mvn install
  • Copies artifact to local repo (~/.m2)

6️⃣ Clean

mvn clean
  • Deletes target/ folder

βœ… Most Used Command

mvn clean package
  • Cleans + Builds + Packages in one step

πŸ”„ Maven Lifecycle Flow

Validate β†’ Compile β†’ Test β†’ Package β†’ Install β†’ Deploy

πŸ”Œ Plugins

  • Small tools used by Maven
  • Automatically downloaded when needed
  • Help automate tasks

❗ Problems Without Maven

  • No proper project structure
  • Difficult dependency management
  • Manual build process
  • No easy artifact creation

πŸ” Alternative Build Tools

Language Tool
Java Maven / Gradle
Python pip / poetry
Node.js npm
C/C++ Make
.NET MSBuild

βš”οΈ Maven vs ANT

Feature Maven ANT
Type Build + Project Tool Build Tool
Config File pom.xml build.xml
Lifecycle Yes No
Reusability High Low
Approach Declarative Procedural

🧩 Key Concepts

Dependency Management

  • Handles required libraries automatically

  • Supports:

    • Transitive dependencies
    • Version control
    • Scope (test, compile, etc.)

Repository Types

  • Local Repo β†’ ~/.m2
  • Central Repo β†’ Online Maven repo

πŸ› οΈ Troubleshooting

  • Run commands in project root (where pom.xml exists)
  • Check Java version compatibility
  • Use:
mvn help:effective-pom
mvn dependency:tree

🎯 Summary 🎯

Maven simplifies the build process by:

  • Managing dependencies
  • Automating builds
  • Creating artifacts
  • Maintaining project consistency

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages

  • Java 65.8%
  • CSS 24.8%
  • JavaScript 9.4%