A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://www.geeksforgeeks.org/advance-java/maven-build-automation/ below:

Maven - Build Automation - GeeksforGeeks

Maven - Build Automation

Last Updated : 05 Aug, 2025

The Maven build automation workflow typically follows these steps:

graph LR
A[Code Check-in] --> B[Build Trigger]
B --> C[Dependency Resolution]
C --> D[Compilation]
D --> E[Testing]
E --> F[Packaging]
F --> G[Verification]
G --> H[Installation/Deployment]
H --> I[Notification]
Workflow Breakdown:
  1. Code Check-in: Developers commit code to a version control system (e.g., Git).
  2. Build Trigger: A CI/CD server detects changes and triggers a new build.
  3. Dependency Resolution: Maven fetches dependencies listed in the pom.xml file.
  4. Compilation: Source code is compiled.
  5. Testing: Unit tests are executed.
  6. Packaging: The compiled code is packaged into a JAR or WAR.
  7. Verification: Integration tests run against the packaged code.
  8. Installation/Deployment: The artifact is installed in a local or remote repository.
  9. Notification: Developers are notified of the build status.
Example: Create a Maven Project Using Spring Initializr

Here, we will create a maven project by using Spring Initilizer with required dependencies.

Step 1: Dependency Declaration

First, we created a maven project by using required dependencies. Add these dependencies to the pom.xml file.

<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>

<dependency>


<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<scope>runtime</scope>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>

Project Structure:
Step 2: Project Setup

Create a Maven project using Spring Initializr and navigate to the project folder in the command prompt by using cd command.

Here the build is the project name. After this run the maven commands to build the project.

Step 3: Run the Maven Commands

1. Now run the below command to validate the maven project.

mvn validate
Output:

2. Once project validation is successful then compile the maven project.

mvn compile
Output:

3. Once maven project compiled successfully, then test the project by using test command.

mvn test
Output:

4. Now package the maven project into JAR or WAR file format by using below maven command.

mvn package
Output:

5. Now verify the integration test of maven project.

mvn verify
Output:

Maven Build Successfully:

6. Now run maven install command to install into local repository.

mvn install
Output:

7. Once every things completed, Then ready to production by running the deploy maven command.

mvn deploy
Output:

Maven Build Successfully:



RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4