Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 25

MAVEN AND GIT Training

What is Maven?
Maven is a build automation tool used mainly for java projects from apache.

Maven is a powerful project management tool that is based on POM (project


object model). It is used for projects build, dependency and documentation. It
simplifies the build process like ANT. But it is too much advanced than ANT.
In short terms we can tell maven is a tool that can be used for building and
managing any Java-based project. maven make the day-to-day work of Java
developers easier and generally help with the comprehension of any Java-based
project.

Ericsson | Commercial in Confidence | 2020-09-09 | Page 2


What maven does?
Maven does a lot of helpful task like:
› We can easily build a project using maven.
› We can add jars and other dependencies of the project easily using the help of
maven.
› Maven provides project information (log document, dependency list, unit test
reports etc.)
› Maven is very helpful for a project while updating central repository of JARs and
other dependencies.
› With the help of Maven we can build any number of projects into output types
like the JAR, WAR etc without doing any scripting.
› Using maven we can easily integrate our project with source control system
(such as Subversion or Git).

Ericsson | Commercial in Confidence | 2020-09-09 | Page 3


How maven works?

Ericsson | Commercial in Confidence | 2020-09-09 | Page 4


Core Concepts of Maven:

› POM Files
› Dependencies and Repositories
› Build Life Cycles, Phases and Goals
› Build Profiles
› Build Plugins

Ericsson | Commercial in Confidence | 2020-09-09 | Page 5


Installation process of Maven
In order to install maven you have to follow a few steps:
› Ensure JAVA_HOME environment variable exists and is set to your JDK
installation.
› Extract the maven package to any directory you want. If you are under unix
system, you can use the following commands:
› unzip: unzip apache-maven-3.3.9-bin.zip
› or tar: tar xzvf apache-maven-3.3.9-bin.tar.gz
› If you are under windows or if you have any extract tool, use it to extract maven.
› Add the bin directory to the system PATH environment variable. In unix system
you can do the following in a shell session:
› export PATH=/opt/apache-maven-3.3.9/bin:$PATH

Ericsson | Commercial in Confidence | 2020-09-09 | Page 6


Installation process of Maven

› In a windows system, you can access through ‘start + right click on computer’,
then choose properties. Click on ‘system avanced configuration’, click on
‘environment variables’ button. Edit path environment variable and add the
maven bin directory at the end.

› Now you are ready, open a shell window and type mvn -v. You should see the
maven version and many other things.

› You can follow the full instructions in order to install maven here:
https://maven.apache.org/install.html

Ericsson | Commercial in Confidence | 2020-09-09 | Page 7


Maven pom.xml file

Ericsson | Commercial in Confidence | 2020-09-09 | Page 8


Maven pom.xml file

› Project
› modelVersion
› groupId
› artifactId
› Version
› Dependencies
› Dependency
› Name
› Scope
› packaging

Ericsson | Commercial in Confidence | 2020-09-09 | Page 9


Practical Application Of Maven
› When working on a java project and that project contains a lot of dependencies,
builds, requirement, then handling all those things manually is very difficult and
tiresome. Thus using some tool which can do these works is very helpful.
Maven is such a build management tool which can do all the things like adding
dependencies, managing the classpath to project, generating war and jar file
automatically and many other things.

Ericsson | Commercial in Confidence | 2020-09-09 | Page 10


Creating an example project

› ECLIPSE EXAMPLE

Ericsson | Commercial in Confidence | 2020-09-09 | Page 11


Maven Lifecycle

Ericsson | Commercial in Confidence | 2020-09-09 | Page 12


Basic Maven Commands

› mvn clean
› mvn compile
› mvn test-compile
› mvn test
› mvn package
› mvn install
› mvn deploy

Ericsson | Commercial in Confidence | 2020-09-09 | Page 13


INTRODUCTION TO GIT

Version control:
› Version control is a system that records changes to a file or set of files over time
so that you can recall specific versions later. So ideally, we can place any file in
the computer on version control.

Ericsson | Commercial in Confidence | 2020-09-09 | Page 14


Version control system
› A Version control system tracks any kind of changes made to the project file,
why these changes were made and references to the problems fixed or
enhancements introduced. It allows developer teams to manage and track
changes in code over time. It allows a person to switch to the previous states of
the file, compare the versions and helps to identify issues in a file in a more
efficient way.
› A Version Control System (VCS) allows you to revert files back to a previous
state, revert the entire project back to a previous state, review changes made
over time, see who last modified something that might be causing a problem,
who introduced an issue and when, and more. Using a VCS also means that if
you screw things up or lose files, you can generally recover easily. And
sometimes you just want to know “who wrote this crap”, and having access to
that information is worthwhile ?.
Ericsson | Commercial in Confidence | 2020-09-09 | Page 15
Git (A Version control system)

› Git is one of the way of implementing the idea of version control. It is Distributed
Version Control System(DVCS)
Unlike Centralized Version Control System that uses a central server to store all
files and enables team collaboration, DVCS just can be implemented just with a
help of a desktop, single software available at a command line. So the failure of
the central server does not create any problem in DVCS. So a lot of operations
can be performed when you are offline.

Ericsson | Commercial in Confidence | 2020-09-09 | Page 16


GIT …. Continued?

› What GIT is about?


› Why Use Version Control Software?
› Characteristics of Git

Ericsson | Commercial in Confidence | 2020-09-09 | Page 17


How GIT Works

› A Git repository is a key-value object store where all objects are indexed by


their SHA-1 hash value.
› All commits, files, tags and filesystem tree nodes are different types of objects
living in this repository.
› A Git repository is a large hash table with no provision made for hash
collisions.
› Git specifically works by taking “snapshots” of files

Ericsson | Commercial in Confidence | 2020-09-09 | Page 18


four fundamental elements

› Working Directory, 
› Staging Area,
›  Local Repository
› Remote Repository.

Ericsson | Commercial in Confidence | 2020-09-09 | Page 19


four fundamental elements

Ericsson | Commercial in Confidence | 2020-09-09 | Page 20


GIT INSTALLATION
Prerequisites
Administrator privileges
Access to a command-line
Your favorite coding text editor
Download Git for Windows
1. Browse to the official Git website: https://git-scm.com/downloads
2. Click the download link for Windows and allow the download to complete.
Extract and Launch Git Installer
3. Browse to the download location (or use the download shortcut in your
browser). Double-click the file to extract and launch the installer.
4. Allow the app to make changes to your device by clicking Yes on the User
Account Control dialog that opens.

Ericsson | Commercial in Confidence | 2020-09-09 | Page 21


GIT INSTALLATION
› 5. Review the GNU General Public License, and when you’re ready to install, click Next.
› 6. The installer will ask you for an installation location. Leave the default, unless you have reason to change it, and click Next.
› 7. A component selection screen will appear. Leave the defaults unless you have a specific need to change them and click Next.
› 8. The installer will offer to create a start menu folder. Simply click Next.
› 9. Select a text editor you’d like to use with Git. Use the drop-down menu to select Notepad++ (or whichever text editor you prefer) and
click Next.
› 10. This installation step allows you to change the PATH environment. The PATH is the default set of directories included when you run a
command from the command line. Leave this on the middle (recommended) selection and click Next.
› 11. The next option relates to server certificates. Most users should use the default. If you’re working in an Active Directory environment,
you may need to switch to Windows Store certificates. Click Next.
› 12. The next selection converts line endings. It is recommended that you leave the default selection. This relates to the way data is
formatted and changing this option may cause problems. Click Next.
› 13. Choose the terminal emulator you want to use. The default MinTTY is recommended, for its features. Click Next.
› 14. The default options are recommended, however this step allows you to decide which extra option you would like to enable. If you use
symbolic links, which are like shortcuts for the command line, tick the box. Click Next.
› 15. Depending on the version of Git you’re installing, it may offer to install experimental features. At the time this article was written, the
option to include interactive options was offered. Unless you are feeling adventurous, leave them unchecked and click Install.
› 16. Once the installation is complete, tick the boxes to view the Release Notes or Launch Git Bash, then click Finish.

Ericsson | Commercial in Confidence | 2020-09-09 | Page 22


GIT COMMANDS
› git config
› git init
› git clone
› git add
› git commit
› git diff
› git reset
› git status
› git rm
› git log

Ericsson | Commercial in Confidence | 2020-09-09 | Page 23


GIT COMMANDS
› git show
› git tag
› git branch
› git checkout
› git merge
› git remote
› git push
› git pull
› git stash

Ericsson | Commercial in Confidence | 2020-09-09 | Page 24


Ericsson | Commercial in Confidence | 2020-09-09 | Page 25

You might also like