DevOps Classroom Series – 23/Sept/2020

Special Note on Windows Terminal

  • Watch Here for installation & configuration of Windows Terminal.

Formal Introduction to Apache Maven

  • This is Open source, Standards-based project management framework that simplifies
    • building
    • testing
    • reporting
    • packaging
  • Advantages of maven:
    • Standardized Directory Structure
    • Declarative Dependency Management
    • Plugins
    • Uniform Build Abstraction
    • Tools Support
    • Archetypes

Components of maven

  • Maven SCM
  • Maven Wagon: Responsible for downloading dependencies
  • Maven DOXIA: Responsible for generating documentations/dynamic contents such as PDF and webpages

Installing maven

  • Windows:
# Ensure JDK 8 is present
choco install jdk8 -y
choco install maven -y
  • Mac
brew install openjdk@8
brew install maven
  • Linux (ubuntu)
sudo apt update
sudo apt install openjdk-8-jdk
cd /tmp/
wget https://mirrors.estointernet.in/apache/maven/maven-3/3.6.3/binaries/apache-maven-3.6.3-bin.tar.gz
cd /opt/
sudo tar -xvzf /tmp/apache-maven-3.6.3-bin.tar.gz
ls
cd apache-maven-3.6.3/
chmod g+w,o+w apache-maven-3.6.3

# edit /etc/environment and the following lines to the end
M2_HOME=/opt/apache-maven-3.6.3
PATH=$PATH:$M2_HOME/bin
# logout and login

Preview

  • Lets build a java project using maven (game of life)
cd /tmp
git clone https://github.com/wakaleo/game-of-life.git
cd game-of-life
mvn compile
  • Lets look at the .m2 folder created in the home directory
cd ~/.m2
ls
  • All the necessary dependencies for building the project are copied into the repository folder
  • Now execute mvn compile & it compiles faster as all the dependencies to compile the project are available in local repo. Preview
  • In Enterprises, Remote Repositories are used Preview
  • Two major use cases of Remote Repositories are
    1. Using only authorized dependencies
    2. Every minor release will be updated in the Remote Repository and this will be used for giving customer releases.
  • By default, Maven is configured to connect to central repository, If you want to used Remote Repository
    1. Configure in pom.xml
    2. In .m2 folder create a file called as settings.xml

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

About learningthoughtsadmin