Maven-1

Maven-1

Build Tool

·

2 min read

INTRODUCTION

As a developer develop the code and have to create one remote repository(GitHub) to store the source code

-> After developing we need to deploy the source code into any of the Application servers (like- tomcat, JBoss, etc)

-->directly can take this code and deploy it to keep in the application server it is not going to work

---> For this purpose we need to create a packages

  • To create packages we use the build tool

  • BUILD TOOL means the process of creating packages and building artifacts

Maven

  • Maven is an open-source-java-based build tool

no.of build tools for different script

Java-based build tool = ANT/Maven/Gradle

.NET = Nant/MS Build

Python = PyBuilder

Rubby = Rake

HERE different types of Applications going build

  1. standalone Application

    • Only Java Code -> (jar __ Java Archive)

    • jar files contains (.classfiles + Manifest files)

  2. Web Application

    • Java Code+Web Content ->( HTML/CSS/JavaScript/XML/images) (.war__Web Archive )

    • war files contain (Jar files + web content)

  3. Enterprise Application

    • multiple modules (ear __ enterprise archive)

    • ear files contain (war + jar + resource file)

example:

Hello world.java ( how can we run this java class)--> source code

Compile (JavaC HelloWorld.java)

HelloWorld.Class --> Byte Code (byte Code will be understood by JVM) (Java Virtual Machine)

So to run the java file? Java HelloWorld

Maven Directory Structure

Maven and Apache Maven both are the same Apache is a provider of Maven

after downloading in instance wget apache-maven3.9.6-bin.zip (binary zip archive)

we will see the following

bin: binary file can contain -mvn

conf: configuration file - setting.xml

lib: libraries -jar files

boot: Maven

Maven Installation

pre-requisite---> java

The Maven website is written for Maven we will require certain Java only, just see it

JDK (Java Development KIT) we use it when we want to develop

JRE (Java Runtime Environment) we used when we deployed the developed code

IN UBUNTU SERVER follow these commands

sudo -i to switch to the root user

cd /opt

apt update to command refreshes the package index. system has the latest information about available software packages and security updates.

type java -version

then copy the first line which is sudo apt-get install font config openjdk-11-jre

then again type java -version

you will get this

Step2) Download the Maven Software

copy the second link that is binary zip archive --- right click > copy link address

then wget paste the link

wgethttps://dlcdn.apache.org/maven/maven-3/3.9.6/binaries/apache-maven-3.9.6-bin.zip

unzipapache-maven-3.9.5-bin.zip

Step3) Set the classpath/Environmental Variable

For Specific User
vi ~/.bash_profile

#maven installation
export M2_HOME=/opt/apache-maven-3.9.5
export PATH=$PATH:$M2_HOME/bin
source ~/.bash_profile

For All Users
vi /etc/profile
export M2_HOME=/apache-maven-3.9.5
export PATH=$PATH:$M2_HOME/bin
source /etc/profile

mvn -version