0% found this document useful (0 votes)
424 views37 pages

Maven & Gradle Build Guide

Uploaded by

21csa30
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd

Topics covered

  • Maven Repositories,
  • Maven Best Practices,
  • Maven Compile Phase,
  • Report Plugins,
  • Artifact Creation,
  • Maven Architecture,
  • External Dependencies,
  • Maven Features,
  • Maven Install Phase,
  • Build Profiles
0% found this document useful (0 votes)
424 views37 pages

Maven & Gradle Build Guide

Uploaded by

21csa30
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd

Topics covered

  • Maven Repositories,
  • Maven Best Practices,
  • Maven Compile Phase,
  • Report Plugins,
  • Artifact Creation,
  • Maven Architecture,
  • External Dependencies,
  • Maven Features,
  • Maven Install Phase,
  • Build Profiles

UNIT - II

UNIT II COMPILE AND BUILD USING MAVEN & GRADLE

Introduction, Installation of Maven, POM files, Maven Build lifecycle, Build phases(compile build, test, package)
Maven Profiles, Maven repositories(local, central, global),Maven plugins, Maven create and build Artificats,
Dependency management, Installation of Gradle, Understand build using Gradle
UNIT - II

UNIT II COMPILE AND BUILD USING MAVEN & GRADLE

Introduction Maven: “Mavan Can do Anything”

Maven is a simple build automation tool which is used with Java projects. Maven is also defined as a comprehensive project management
tool. It aims to provide the developers a complete and detailed build life cycle framework of an application. (Based on the concept of a
project object model (POM))

Maven can Manage:

1) Maintain Structure

2) Build Code

3) Dependency Management

4) Create documentation sites

5) Release and Distribution

6) Encouraging better development practices


UNIT - II

Maven aims to describe 2 important things :

1. How a software is built.

2. The dependencies, plug-ins & profiles that the project is associated in a standalone or a distributed environment.

Important Terminology:

1) Group ID - A unique base name of the company or group that created the project

2) Artifact ID - A unique name of the project

3) Archetype - Maven project template toolkit

4) Dependencies - Dependencies are the libraries, which are needed by the project like JAR, ZIP, etc.,

5) Plugins - Adds a specific feature to an existing computer program

6) Version – A version of the Project


UNIT - II

Challenges Arising During Project Development Without Maven:

Dependency Management: One of the most significant challenges is managing external dependencies. Without Maven, developers must

manually download, configure, and include libraries and dependencies, which can be error-prone and time-consuming.

Build Process Complexity: Building the project without a build automation tool like Maven can lead to a complex and non-standardized

build process. This can result in inconsistencies, making it harder for team members to collaborate effectively.

Version Control: Without Maven's standardized project structure, it becomes more challenging to manage version control for the project.

Inconsistent directory structures and manually managed dependencies can lead to version conflicts and compatibility issues.

Lack of Convention: Maven promotes convention over configuration, meaning that it follows a standardized project structure and naming

conventions. Without it, team members may spend more time discussing and deciding on project configurations, which can slow down

development.
UNIT - II

Documentation: Maven automatically generates documentation, which is beneficial for project maintainability.
Without it, developers may need to invest extra time and effort in manually creating and updating
documentation.

Plugin Ecosystem: Maven offers a wide range of plugins for various tasks, such as code analysis, code coverage,
and deployment. Without Maven, developers may need to use third-party tools and plugins or create their
own, leading to additional complexity.

Integration with IDEs: Most popular Integrated Development Environments (IDEs) have built-in support for
Maven, making it easier to manage projects. Without Maven, developers may need to configure IDEs manually,
which can be time-consuming.
UNIT - II

Convention Over Configuration:

• Maven uses Convention over Configuration, which means developers are not required to create build process themselves.

• Developers do not have to mention each and every configuration detail. Maven provides sensible default behavior for
projects. When a Maven project is created, Maven creates default project structure. Developer is only required to place
files accordingly and he/she need not to define any configuration in pom.xml.

Following table shows the default values for project source code files, resource files and other configurations. ${basedir}
denotes the project location −
UNIT - II

Features of Maven

• Simple project setup that follows best practices.

• Consistent usage across all projects.

• Dependency management including automatic updating.

• A large and growing repository of libraries.

• Extensible, with the ability to easily write plugins in Java or scripting languages.

• Instant access to new features with little or no extra configuration.

• Model-based builds − Maven is able to build any number of projects into predefined output types such as jar, war,
metadata.

• Coherent site of project information − Using the same metadata as per the build process, maven is able to generate a
website and a PDF including complete documentation.
UNIT - II

• Release management and distribution publication − Without additional configuration, maven will integrate
with your source control system such as CVS and manages the release of a project.

• Backward Compatibility − You can easily port the multiple modules of a project into Maven 3 from older
versions of Maven. It can support the older versions also.

• Automatic parent versioning − No need to specify the parent in the sub module for maintenance.

• Parallel builds − It analyzes the project dependency graph and enables you to build schedule modules in
parallel. Using this, you can achieve the performance improvements of 20-50%.

• Better Error and Integrity Reporting − Maven improved error reporting, and it provides you with a link to the
Maven wiki page where you will get full description of the error.
UNIT - II

Maven Installation: (Refer - mkyong.com)


JDK 1.8, Eclipse, mavan

1. Verify Java Installation in Your Machine


java –version
2. Set JAVA Environment
3. Maven Archive
4. Set Maven Environment Variables
5. Add Maven bin Directory Location to System Path
6. Verify Maven Installation
mvn -version

Mavan Installation:
Refer - mkyong.com
UNIT - II

Maven Architecture:

How Does the Maven Architecture Work?


• The first step refers to configuring Maven, which is stored in a pom.xml file
• The POM file includes all of the configurations that Maven needs. The second step is to download the dependencies defined in pom.xml
into the local repository from the central repository
• After the user starts working in Maven, the tool provides various default settings, so there is no need to add every configuration in the
pom.xml
UNIT - II

Project Object Model (POM):

• It is fundamental unit of work in Maven. It is an XML file that resides in the base directory of the project as
pom.xml.

• The POM contains information about the project and various configuration detail used by Maven to build
the project(s).

• POM also contains the goals and plugins. While executing a task or goal, Maven looks for the POM in the
current directory. It reads the POM, gets the needed configuration information, and then executes the
goal.

• Before creating a POM, we should first decide the project group (groupId), its name (artifactId) and its
version as these attributes help in uniquely identifying the project in repository.
UNIT - II

The following tables lists some of the configuration that can be specified in the POM.
UNIT - II

POM Example
<project xmlns = http://maven.apache.org/POM/4.0.0
xmlns:xsi = "http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation = "http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>com.ecommerce</groupId>
<artifactId>Aravid</artifactId>
<version>1.0</version>
</project>

*All POM files require the project element and three mandatory fields: groupId, artifactId, version.
UNIT - II

Maven Build lifecycle:

Maven provides a well-defined build lifecycle that consists of a sequence of phases and goals. These phases and goals are executed in a specific
order, allowing you to build, test, package, and deploy your projects with ease.

The standard Maven build lifecycle includes the following phases:

1. Clean Phase: This phase removes all files generated by previous builds, such as compiled classes and build artifacts. It provides a clean slate
for the project.

2. Validate Phase: In this phase, Maven validates the project's structure and configuration. It checks if the pom.xml file is valid and if the
required dependencies are available.

3. Compile Phase: This phase compiles the project's source code, generating the corresponding class files. These files are placed in the
target/classes directory by default.

4. Test Phase: In this phase, Maven executes the project's unit tests. It uses a testing framework like JUnit to run test cases. Failures in this phase
will prevent the build from progressing further.

5. Package Phase: In this phase, Maven packages the compiled classes and resources into a distributable format according to the project's
packaging type (e.g., JAR, WAR, or others). The resulting artifact is stored in the target directory.
UNIT - II

6. Integration Test Phase: This phase is responsible for running integration tests. It typically involves deploying the
application and executing tests that span multiple components or services.
7. Verify Phase: In this phase, Maven performs additional checks on the project, such as checking code quality and
generating reports. It ensures that the project meets quality standards.
8. Install Phase: Maven installs the project's artifact into the local Maven repository (~/.m2/repository). This makes it
available for other projects on your local machine to use as a dependency.
9. Deploy Phase: If your project needs to be deployed to a remote repository, this phase handles the deployment
process. It
copies the artifact to a remote repository for sharing with others or for deployment to production servers.

These are the standard phases in the Maven build lifecycle. You can invoke these phases using Maven commands (e.g., mvn
clean, mvn compile, etc.). Additionally, you can bind your own custom goals and plugins to specific phases to extend or
modify the build process to meet your project's requirements. Maven's build lifecycle ensures a consistent and reliable build
process for your projects.
UNIT - II

There are three types of standard lifecycles:

1. Default (or) Build

The default lifecycle is the most commonly used one and is responsible for building, testing, and packaging the project. It includes the following phases:
• Validate: Validates the project's configuration and dependencies.
• Compile: Compiles the project's source code.
• Test: Executes unit tests for the project.
• Package: Packages the compiled code and resources into a distributable format (e.g., JAR or WAR).
• Verify: Performs additional checks and generates reports to ensure code quality.
• Install: Installs the project's artifact in the local Maven repository.
• Deploy: Deploys the project's artifact to a remote repository (if needed).

2. Clean:

The clean life cycle handles project cleaning. The clean phase consists of the following three steps:
• Pre-clean
• Clean
• Post-clean

• The mvn post-clean command is used to invoke the clean lifestyle phases in Maven.
UNIT - II

3. Site:

The Maven site plugin handles the project site's documentation, which is used to create reports, deploy sites, etc.

The phase has four different stages:

• Pre-site: Executes tasks before generating the site documentation.

• Site: Generates project documentation and reports.

• Post-site: Executes tasks after generating the site documentation.

•Site-deploy: Deploys the generated site documentation to a remote server (if

needed). Ultimately, the site that is created contains the project report.

Each phase in these lifecycles corresponds to a specific goal or set of goals. By running a
Maven command, you can specify a
phase, and Maven will execute all the preceding phases as well, ensuring that the build
process is consistent and complete.
UNIT - II

Maven Profile:

Maven profiles are a powerful feature that allows you to customize your Maven build process based on different environments, build
configurations, or other criteria. They provide a way to define and activate specific sets of configuration settings, dependencies, and plugins
for different scenarios. Maven profiles are defined in the project's pom.xml file and can be activated manually or automatically based on
conditions.

To define a profile in your pom.xml file, you use the <profiles> element and specify the configuration within the <profile> tags.

Here's a simplified example:


<profiles>
<profile>
<id>development</id>
<properties>
<environment>development</environment>
</properties>
<dependencies>
<!-- Define development-specific dependencies -->
</dependencies>
<!-- Other configuration specific to the development profile -->
</profile>
</profiles>
UNIT - II

Types of build profiles:

The below table shows the types of build profiles in


Maven :
UNIT - II

Maven Repository:

A Maven repository is a directory to store all the project jars, library jar, plugins or any other artifacts.

For maven to download the required artifacts of the build and dependencies (jar files) and other plugins which are
configured as part of any project, there should be a common place where all such artifacts are placed. This common shared
area is called as Repository in maven.

There are three types of maven repositories:-


UNIT - II

Local Repository: The repository which resides in our local machine which are cached from the remote/central
repository downloads and ready for the usage. The folder to hold/place all the dependencies in local can be
configured in the settings.xml file of the maven folder under the tag <localRepository>.

Ex:
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0
http://maven.apache.org/xsd/settings-1.0.0.xsd">

<localRepository>D:/m2repo</localRepository>
</settings>
UNIT - II

Central Repository: This is the repository provided by maven community. This repository contains large set of commonly used/required
libraries for any java project. Basically, internet connection is required if developers want to make use of this central repository. But, no
configuration is required for accessing this central repository.

Key concepts of Central repository are as follows −


• This repository is managed by Maven community.
• It is not required to be configured.
• It requires internet access to be searched.

Ex:
<repositories>
<repository>
<id>central.repository</id>
<url>http://repo1.maven.org/maven2/</url>
</repository>
</repositories>
UNIT - II

Remote Repository: This repository as the name suggests resides in the remote server (which is developer's own
custom repository containing required libraries or other project jars.) and which can be accessed by using
different file transfer protocols like file:// or http://. Remote repository will be used for both downloading and
uploading the dependencies and artifacts.

Ex:

<repositories>

<repository>

<id>remote.repository</id>

<url>http://download.ogrname.com/maven2/</url>

</repository>

</repositories>
UNIT - II

Maven Dependency Search Sequence

When we execute Maven build commands, Maven starts looking for dependency libraries in the following
sequence −

Step 1 − Search dependency in local repository, if not found, move to step 2 else perform the further processing.

Step 2 − Search dependency in central repository, if not found and remote repository/repositories is/are
mentioned then move to step 4. Else it is downloaded to local repository for future reference.

Step 3 − If a remote repository has not been mentioned, Maven simply stops the processing and throws error
(Unable to find dependency).

Step 4 − Search dependency in remote repository or repositories, if found then it is downloaded to local
repository for future reference. Otherwise, Maven stops processing and throws error (Unable to find
dependency).
UNIT - II

Maven Plugins:

Plugin in maven is the one of the vital feature that is basically used to reuse the common build logic across different projects.
Plugins are the ones through which all the tasks like compiling code, testing them with the junits, creating jar/war/ear files
and documentation of the projects are carried out. Most of the work in maven is done using plugins, since the dependencies
(jar files) are added only to the classpath while executing tasks.

So, maven is nothing but a plugin execution framework in which every tasks are accomplished by the usage of plugins.

Below are the basic list of tasks that are handled by plugins in maven :

• Creating jar/war/ear files.

• Code compilation

• Unit testing of the code.

• Project documentation
UNIT - II

Behavior of any plugin can be changed using a set of parameters exposed by each plugin goal (also known as
Mojo). A Mojo in maven is just a goal, basically specifies the metadata of a goal - goal name, which phase it fits
into and parameters expected by the goal.

Types of Maven Plugins:

1. Build Plugins - Basically these plugins will execute during the build phase. These plugins are defined
under the <build> element in pom.xml

2. Report Plugins - These plugins are executed during the site generation (report or javadocs generation)
phase. These plugins will be configured under the <reporting> element in pom.xml
UNIT - II

Common Maven Plugins are:


UNIT - II

Ex:
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<source>1.8</source> <!-- Java source version -->
<target>1.8</target> <!-- Java target version -->
</configuration>
</plugin>
</plugins>
</build>
UNIT - II

Benefits of Maven Plugins:


• More detailed and well architecture.

• A managed life cycle

• Implementation of multiple languages

• Reusability of the common build logic.

• Ability to write maven plugins completely in java


UNIT - II

Maven create and build Artificats:

Maven is a powerful build tool and project management tool used primarily for Java projects. It is used to manage
dependencies, compile code, and create artifacts such as JAR (Java Archive) files.

Here's a general outline of how Maven creates and builds artifacts:

1. Project Setup: First, you need to set up your Maven project. This typically involves creating a project
directory structure with a pom.xml file, which defines the project's configuration and
dependencies.

2. POM.xml Configuration: In the pom.xml file, you specify the project's metadata, dependencies, and build
settings. You can define the project's packaging type, which could be JAR for a Java library, WAR for a
web application, or other formats.
UNIT - II

3. Dependency Resolution: Maven will automatically download and manage the project's dependencies based
on the specifications in the pom.xml file. It retrieves the required JAR files from a central repository or
other specified repositories.

4. Compilation: When you run the mvn compile command, Maven compiles your Java source code,
producing class files. These class files are stored in the target directory by default.

5. Testing: You can run tests on your code using the mvn test command. Maven executes test cases and
reports
the results.

6. Packaging: To create an artifact (such as a JAR file), you use the mvn package command. This step takes the
compiled classes and resources and packages them according to the project's packaging type (e.g.,
JAR).

7. Install: If you want to install the artifact in your local Maven repository, you can use the mvn install
UNIT - II

8. Deployment: For distributing your artifact to a remote repository, you would configure Maven to deploy it
using the mvn deploy command. This is often used when sharing your library with others or deploying a
web application to a server.

9. Customization: You can customize the build process by adding plugins to your pom.xml file. Plugins can
perform various tasks, such as code generation, code analysis, or even custom packaging.

Remember that Maven's power lies in its convention-over-configuration approach. By following standard
directory structures and naming conventions, you can create and build artifacts without needing to specify every
detail in your build configuration.
UNIT - II

Maven Dependencies Management:

• Maven has built-in dependency management. We can just specify in the POM file what external libraries the
project depends on, and which version.

• All the basic list of dependencies in maven is handled by the maven repository at which a project downloads
the required dependencies. But, there will be certain scenario at which some particular dependencies may not
be available in the maven remote and central repositories. Maven still answers this scenario by providing the
feature of external dependency management.

• If these external libraries need other libraries, then Maven would download their dependency libraries into
your local Maven repository as well.

• We can specify dependencies inside the dependencies element in the POM file.
UNIT - II

Ex:
<dependencies>

<!-- https://mvnrepository.com/artifact/mysql/mysql-connector-java -->

<dependency>

<groupId>mysql</groupId>

<artifactId>mysql-connector-java</artifactId>

<version>8.0.13</version>

</dependency>

</dependencies>
UNIT - II

An external dependency can be such as sqljdbc.jar. In maven, any external dependencies can be easily
configurable as other dependencies in the pom.xml file. So, let us see a simple example to add sqljdbc.jar as an
external dependency into a maven project.
• Create a folder called lib in the maven project.

• Download the sqljdbc.jar and put it inside the lib folder.

• Now, open the pom.xml of the project and add a new dependency as shown below:

• Specify groupId as name of the jar file

• Specify artifactId as name of the jar file

• Specify the scope of the system

• Specify the relative path of the jar file to project location.


UNIT - II

Ex:

<dependency>

<groupId>sqljdbc</groupId>

<artifactId>sqljdbc</artifactId>

<scope>system</scope>

<version>1.0</version>

<systemPath>${basedir}\src\lib\sqljdbc.jar</systemPath>

</dependency>
UNIT - II

Dependency Scope:

Dependency scope in maven is classified into 5 different types. Each of these scope controls the dependencies
that are available in the class path and dependencies that are included in the application.

Common questions

Powered by AI

Managing external dependencies without Maven can lead to several challenges, including manually downloading, configuring, and maintaining libraries, which is both error-prone and time-consuming . Additionally, inconsistent version management can introduce compatibility issues, and the lack of a unified structure may lead to a complex and fragmented build process . Maven addresses these challenges by automating dependency resolution and management through its POM file, which defines and manages all project dependencies in a single location . It retrieves required libraries from central or specified repositories, ensuring that the correct versions are used consistently across builds. This automation reduces errors and enhances productivity while maintaining a clear and organized project structure, allowing developers to focus on core development activities.

Maven plugins enhance project builds by extending Maven's capability to perform a variety of tasks that streamline and automate aspects of the build lifecycle. Plugins can execute tasks such as compiling code, packaging distributions, deploying applications, and running tests . They form a crucial part of the Maven ecosystem as they allow customizations that are not provided out-of-the-box, effectively making Maven a flexible tool adaptable to diverse project requirements. The significance of plugins lies in their ability to encapsulate specific functionalities like custom reports, code analysis, and advanced deployment strategies, all of which can be integrated seamlessly into the Maven build process . This extensibility through plugins allows developers to automate complex tasks efficiently without delving into complex scripting, promoting best practices in software development.

The Maven Project Object Model (POM) is foundational to Maven's build lifecycle and project management. POM, an XML file at the base directory of a project, includes configurations, metadata, and dependencies needed for building the project . It defines goals and plugins that automate tasks in the build process by specifying them once, thus ensuring repeatability and consistency . During the build lifecycle, Maven reads the POM to validate configurations, manage dependencies, compile code, and package artifacts in specified formats like JAR or WAR . This centralized configuration and dependency management significantly enhance project management by reducing manual configuration and ensuring project alignment with defined goals.

Maven supports version control and backward compatibility through its standardized approach to project structure and dependency management. Maven uses a versioning system where each project's version must be specified in the POM, aiding in tracking changes and ensuring consistent builds across different setups . For backward compatibility, Maven can port projects to newer versions while supporting older Maven versions, allowing legacy projects to transition smoothly to more recent setups without significant redevelopment . This is achieved by Maven's consistent directory structures and version iteration processes that externalize version management for both projects and dependencies. Consequently, with automatic parent versioning and parallel builds, Maven enables efficient handling of project evolution without compromising stability .

Maven provides several advantages over not using build automation tools. It greatly simplifies dependency management by automatically handling external library downloads and configurations, reducing the error-prone and time-consuming manual management that would otherwise be required . By using a standardized project structure and naming conventions, Maven avoids the complexities and inconsistencies of a manual build process, promoting better collaboration among developers . Maven also improves version control and documentation generation effortlessly , which can otherwise be challenging and require significant manual effort. Its plugin ecosystem and IDE integration further streamline development tasks without the need for third-party tools .

Maven's 'Convention over Configuration' principle simplifies project setup and management by providing a set of standard conventions that projects can follow, thereby reducing the need for detailed configuration. With this approach, developers can adopt the predefined project structures and settings that come with Maven instead of manually specifying each aspect of the build process . This results in faster project setup with consistent usage across different projects and eliminates configurations that could otherwise lead to errors or inconsistencies . By handling defaults such as directory layouts and typical build settings, Maven allows developers to focus on writing and maintaining code, which streamlines project management.

Maven utilizes a repository system to manage dependencies and build artifacts, facilitating efficient and consistent project builds. There are three main types of repositories in Maven: local, central, and remote. The local repository is cached on a developer's machine where downloaded artifacts are stored for quicker access in future builds . The central repository, managed by the Maven community, hosts a wide array of commonly used libraries and requires internet access for developers to retrieve dependencies . Remote repositories allow for connections to external repository sources a developer might create, which may contain specific libraries not available in the central repository. This structure enables Maven to automatically resolve and download dependencies through a defined sequence, starting from the local repository and moving outwards to central and remote sources as needed . This structured approach simplifies dependency management by reducing manual interventions and ensuring consistent access to necessary libraries.

Maven's build lifecycle significantly contributes to a systematic and efficient project build process by defining a sequence of predefined phases that organize and automate the steps required in building, packaging, and deploying a project . This lifecycle includes phases such as 'clean', which removes previous build artifacts, 'compile', which translates source code to class files, 'test', which verifies the code with unit tests, and 'package', which archives the compiled code into bundles like JAR or WAR files . By automatically managing these sequential steps, Maven ensures each build phase is executed only after previous phases are completed successfully, promoting consistency and preventing errors. This framework ensures that the right tasks are executed in an orderly and systematic manner, optimizing the development workflow and reducing the likelihood of human error.

Maven facilitates integration with IDEs through built-in support in most popular development environments, which simplifies project management and reduces manual configurations . This integration ensures that IDEs automatically recognize the project structure and dependencies from the POM file, enabling developers to execute Maven goals and commands directly within the IDE. Consequently, developers benefit from streamlined workflows as IDEs can handle dependency resolution, project builds, and error checking automatically, enhancing productivity. Furthermore, IDE integration provides consistent information across the development team, aiding in better collaboration and reducing setup overhead .

Maven profiles are configurations that allow developers to customize the build process based on environment, build configurations, or specific goals . Profiles can alter the set of dependencies, plugins, and configurations used for a build without changing the main POM file, thus enabling greater flexibility. For instance, in a scenario where a project needs different configurations for development and production environments, Maven profiles can be defined within the POM to accommodate these variations. The developer might set a 'development' profile to include tools for debugging and detailed logging, while the 'production' profile might include optimizations and performance monitoring tools. These profiles can be activated either manually or automatically based on pre-defined criteria .

You might also like