DevOps Classroom Series – 02/Dec/2021

Maven Repositories Contd

  • Remote Repository:

    • Sometimes, Maven will not find dependencies in central as they might be your organizations private depenedency, In this cases maven will fail
    • Maven has a concept of Remote Repository which is organizations own private repository containing required libraries or jars.
    • To configure Remote repository, we can use pom.xml or even settings.xml
    • Refer Here for the sample containing your remote repository configuration
  • Maven dependency search sequence: When we execute maven commands to build, Maven starts looking depedency libraries in the following sequence

    • Step 1: Search the dependency in local repository, if it doesnot find then step 2 for further processing
    • Step 2: Searches the dependency in the central repository. If not found and remote repositories are mention in the pom.xml/settings.xml then step 3 for further processing. and if repositories are not mentioned then step 4
    • Step 3: Search the dependency in remote repository or repositories. If found download to the local repository for future reference, if it doesn’t find step 4
    • Step 4: Maven stops further processing and throws error
  • Refer Here for the available repository management softwares

  • Scenario: Your organization doesn’t want developers to use central repository and download any jars because your application is regulated, using external librarires needs to be audited for security

    • To solve these kind of scenarios, maven has a concept called mirro. Mirror is equivalent to an interceptor. It intercepts maven’s request for central repo and redirects the remote/central repository address to the address of the configured mirror.
    • The configuration of the mirror generally will be in settings.xml file
    <mirrors>
      <mirror>
         <id>India</id>
         <name>India Central</id>
         <url>http://india.qt.org/maven2</url>
         <mirrorOf>central</mirrorOf>
      </mirror>
      <mirror>
         <id>UK</id>
         <name>UK Central</id>
         <url>http://uk.qt.org/maven2</url>
         <mirrorOf>central</mirrorOf>
      </mirror>
      <mirror>
         <id>USA</id>
         <name>USA Central</id>
         <url>http://usa.qt.org/maven2</url>
         <mirrorOf>central</mirrorOf>
      </mirror>
    </mirrors>
    
  • Mirror setup for organization

Maven Plugins

  • Maven actually performs goals by executing plugins i.e. each task is done by plugins
  • Maven plugins are generally used to
    • create a jar file
    • create a war file
    • compile code files
    • unit testing of the code
    • create project docs
    • create project reports
  • Plugins can be classified into two types
    • Build Plugins
    • Reporting Plugins

Maven for DevOps

  • We will be using maven to compile, build jar/war file and generate unit testing reports
  • Pushing the artifacts (jars,wars, poms) to the remote repository so that other developers can use them as depdenencies (SNAPSHOTS). IF the project is complete we need to create the dependencies as RELEASES.
  • While deploying the application downloading the jars/wars into the servers from Repository management softwares so that QA can proceed (Automation/Manual)

Using Maven to build and generate test reports

  • When we execute the maven goal package => compile, test, package
  • Lets generate the test report and package for spring pet clinic Refer Here
  • So lets create a jenkins project which builds a spring petclinic package and shows the test results on the jenkins ui, so that it is easier to understand failures

Introduction to Distributed Builds

Leave a ReplyCancel reply

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

Please turn AdBlock off
Animated Social Media Icons by Acurax Responsive Web Designing Company

Discover more from Direct DevOps from Quality Thought

Subscribe now to keep reading and get access to the full archive.

Continue reading

Exit mobile version
%%footer%%