0% found this document useful (0 votes)
115 views4 pages

Maven Build Tool Overview and Installation

Maven is a build tool used primarily for Java projects that uses a project object model (POM) file to manage dependencies and the build lifecycle through goals like compile, test, and package. It handles building artifacts like JAR and WAR files, running tests, and publishing artifacts to repositories. Maven has advantages over the older Ant build tool like enforced conventions, dependency management, and an extensive plugin system.

Uploaded by

Sandeep Sesham
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
115 views4 pages

Maven Build Tool Overview and Installation

Maven is a build tool used primarily for Java projects that uses a project object model (POM) file to manage dependencies and the build lifecycle through goals like compile, test, and package. It handles building artifacts like JAR and WAR files, running tests, and publishing artifacts to repositories. Maven has advantages over the older Ant build tool like enforced conventions, dependency management, and an extensive plugin system.

Uploaded by

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

maven : build tool.

maven ==>>> apache.

Developers ==>> code ==>> push ==>> github ===>>> code ==>> maven ==>> build tool
==>> build ==>>> package ===>>> war / jar / ear ===>>copy ==>> tomcat
( webserver)===>> APP ==>> EU.

Maven is worked for java based projects only..

Maven ===>>> alternative tool ==>> ANT ( build tool ==>>> older tool )

******* maven vs ant*****************

MAVEN : build tool

1. works for java based projects only

2. maven has life cycle.

3. maven works for project object based model.===>> maven ==>> [Link]

4. defaultly junit test cases run..

5. maven has plugins ==>> plugins ==>> install ==>> extranal features adding to our
project.

plugins are reusable.

6. maven checks the dependencys..

ANT : build tool

1. works for java based projects only

2. Ant has no life cycle.

3. ANT has [Link]

4. Ant does not checks junit test cases.

5. ant has scripts. ==>>> scripts are not reusable.

6. Ant does not checks dependencys..

===================================================================================
===================

maven works for project object based model..

maven ==>> [Link]

[Link] ==>> file ==>> written by developers..

Every project has one [Link]

[Link] or pom.xml2
[Link] should be unique name.==>> [Link]

[Link] has the fields

groupid ==>> clientname or projectname ==>>> SBI

artifactid ==>> feturename ==>> Creditcard

versionid ==>> threefields ==>> [Link]/bugfixrelease


==>>> 8.2.0

typeofpackage ==>>> war/jar/ear

properties ===>>>> sonarqube url link ( ops team)

dependencys ==>> 1.8 ===>> 1.7

distribution management ==>>> nexus url ===>> ( ops team)

plugins..

maven has in built one [Link] ==>>> superpom / parentpom

superpom ==>> propeties are inherit to normal [Link] ( develeper ===>> developed
[Link]).

===============================================================

maven searching way : 3 types..

1. central repository ===>>> online

2. remote repository ==>> organization level ==>>> IBM ( real time)

3. local repository ==>> our ownlaptop.

=====================================================================

maven lifecycle.

1. default

2. clean

3. site

===>1. default :

1. compile

2. validate.

3. test

4. package

5. install

6. verify
====>>>2. clean

1. preclean

2. clean

3. postclean

====>> 3. site :

1. presite

2. site

3. postsite

[Link]-deploy

maven goals or maven commands..

maven commands starts with mvn

mvn compile

mvn compile verify clean

mvn test install package site

mvn clean package

Note and Keypoint : maven always looks for [Link]

every command / goals you need type in maven ===>>> always looks for [Link] in
current directory..

=============================================================

maven ===>> relases and snapshots..

releases ==>>

[Link] ==>>> versionid ==>>> 8.2.0 ===>> it is going to release.

releases are mainting the versioning..

snapshots ==>>>

[Link] ==>>> versionid ==>>> 8.2.0-SNAPSHOT ===>> it is in under developement


process.

snapshots are not mainting the versioning..

===================================================================================
============================

maven installation steps :

1. we need to take one ec2 instance and login into the ec2instace.
2. we need to install java.

3. we need to install git

4. cloning the githuburl ===>> git clone githuburl..

5. we need to install maven ( 3 steps )

6. cd myweb

7. mvn clean package

ls

in target directory ==>> war file will generate. ===>>[Link]

===================================================================

*********** maven home directory ==>> /usr/share/apache-maven *********

=======================================================================

Common questions

Powered by AI

Maven distinguishes itself from older tools like Ant by adopting a Project Object Model approach, inherent lifecycle management, and robust dependency checking . This makes Maven less error-prone and more streamlined, with reduced manual intervention compared to Ant . Additionally, Maven's integration of JUnit test cases and reusable plugins provides features that are not inherently available with Ant's script-based approach .

The Maven lifecycle provides a structured process for building, cleaning, and deploying projects, which contributes to its efficiency as a build tool. It consists of three main phases: default, clean, and site. These phases automate tasks such as compiling code, running tests, packaging, cleaning build directories, and generating project sites . The lifecycle ensures consistency and standardization in the build process, streamlining project development and maintenance .

Maven's repository structure optimizes dependency resolution through its three-tiered system: central, remote, and local repositories . The central repository provides a reliable source for commonly used dependencies, accessible online. Remote repositories cater to organization-specific artifacts that are not publicly available, ensuring privacy and control over company-specific components . Local repositories on individual machines allow for efficient builds via cached dependencies, reducing reliance on external access and speeding up the build process by minimizing network usage .

The Maven installation process integrates Maven into a Java development environment by specifying steps that ensure all prerequisites are met. This includes setting up an EC2 instance, installing Java and Git, and downloading the Maven software . By following these steps, developers ensure that Maven is correctly configured to handle builds and can access necessary repositories and dependencies .

Maven treats snapshots as versions under development, indicated by the version identifier appended with '-SNAPSHOT'. This means they are not stable and can change at any time, allowing for ongoing integration and testing . Releases, on the other hand, are stable versions that do not change, ensuring consistency and reliability in production environments . The distinction allows for controlled development cycles, separating ongoing work from stable deployments and facilitating continuous development .

Maven plugins extend the capabilities of Maven projects by adding extra features that can be reused across different projects. They are responsible for tasks such as compiling code, testing, and deployment . By allowing developers to include only the plugins they need, Maven encourages modularity and prevents feature bloat. The reusability of these plugins also means increased efficiency and reduced efforts for recurring tasks .

Maven ensures backward compatibility through its approach to versioning and the structured nature of pom.xml files which standardizes dependency declarations and plugin integrations . By maintaining a consistent project model across versions, developers can update Maven without altering core configurations, minimizing disruptions in existing projects . Maven also supports the concept of superpom, where properties are inherited by various pom.xml files, enabling seamless integration across different versions .

The pom.xml file is crucial in Maven projects as it defines the project structure, configurations, dependencies, and plugins used. It typically contains groupid, artifactid, versionid, package type, dependencies, and distribution management details . This central configuration file allows for easy project maintenance, as changing settings here can propagate throughout the project. Its standardized format helps ensure stability and consistency across builds .

Maven relies on pom.xml because it contains all the necessary configuration details to execute Maven commands effectively, such as compiling, testing, and packaging code . Without this file, Maven cannot understand the project's structure or dependencies, leading to failed build processes and mismanaged project configurations. The absence of pom.xml would thus result in improper package assembly and lack of consistency in project builds .

Maven is based on a Project Object Model (POM), which is specified in a pom.xml file, and includes management of project dependencies automatically . In contrast, Ant relies on a procedural approach through build scripts in a build.xml file and lacks built-in dependency management . Moreover, Maven supports reusable plugins, whereas Ant primarily uses non-reusable scripts for additional functionality .

You might also like