Maven-2

Maven-2

Build Tool

·

2 min read

Table of contents

No heading

No headings in the article.

Build Extensions

ANT - build.xml

Maven - pom.xml

Gradle - build. Gradle

build file extension

Maven repositories

  1. local repositories

    -in maven Home Directory >conf >setting.xml

    -then we will find <local repo>there keep the path </local repo>

    It is a local folder that is used to store all the project dependencies(plugin jars and other files that are downloaded by Maven)

    • when you build a Maven project all dependency files will be stored in the Maven local repository

- default maven local repository defaults to .m2 folder

-mac os > ~/.m2 (/users/Suma/.m2/repository)

-Windows > c:\users\Suma\.m2\repository

-Linux > /home/Suma/.m2/repository

  1. central repositories

    the repo provides by the maven community. It contains a large repository of commonly used libraries.

    • this repo comes into play when Maven does not find libraries in the local repo

    • the central repo can be found at https://maven.apache.org/

  2. Remote repositories

    It usually maintains its repo for the libraries that are being used for the project. These differ from the local repo, a repo is maintained on a separate server different from the developer machine and is accessible within the organization

Maven Architecture

Maven life cycle

lifecyclegoals
cleanclean: it will delete the previous build files
sitesite: it will generate the documentation for the source code
defaultvalidate: it will validate the directory structure and file
compile: it will compile the source code and j unit test case code
test: it will run the JUnit test cases
package: it will creates the packages. (jar/war/ear)create
install: it will store the build artifact/package in the Maven local repo
deploy: it will store the build artifact in the remote repo

apt install maven

mvn -version

apt install git -y

git --version

https://github.com/Vkusuma/maven-standalone-application to get source code from GitHub for a jar file

https://github.com/MithunTechnologiesDevOps/maven-web-application.git it is for war file

https://github.com/MithunTechnologiesDevOps/maven-enterprise-application.git for ear file

take the repository and copy the URL (code >https)

then clone from remote to local shown in below

then try mvn package

mvn compile

mvn validate

mvn test

mvn clean

/opt/apache-maven-3.9.5/maven-standalone-application# cd /opt/apache-maven-3.9.5/conf/

ls

vi settings.xml

in home dir vi .profile

if you want to skip running unit test cases mvn clean package -Dskiptest

mvn install

mvn deploy

thank you for reading this. i hope it is clear to understand