DevOps Classroom Series – Maven – 20/Dec/2019

Maven

  • Is a Project Management Tool.

  • Can be used for

    • build
    • dependency Management
    • Releases
    • Documentation
    • Test Executions
  • Maven prefers conventions over configurations

  • Maven also works for Java Based Languages

    • groovy
    • Scala
  • Maven uses a file called as pom.xml to define

    • dependencies
    • project information’s
    • plugins

Installation

  • Before installing maven ensure Java is installed
  • Ubuntu:
sudo apt-get update
sudo apt-get install maven -y

Maven folder conventions

  • Code: <projectdirectory>/src/main/java/
  • Location of pom: <projectdirectory>/pom.xml
  • Test: <projectdirectory>/src/test/java/
  • Target Folder: <projectdirectory>/target

pom.xml

  • POM (Project Object Model): is a xml which defines
    • Project info
    • Dependencies
    • Plugins
    • Profiles

Goals

  • compile : compile the code
  • test: compile the code + test the code
  • package: test the code + package the application
  • install: pushes the pom file and jar/war to ~/.m2
  • deploy: pushes the pom file and jar/war to Remote/Central Repo
  • clean: remove the target folder

Executing goals

  • single goal execution
mvn compile
mvn test
  • multi goals
mvn clean package

Maven Repository Architecture

Preview

Using Maven with Jenkins

  • Install maven and ensure Jenkins User has access to maven
  • In the build section of Free style project
    • Execute Shell: directly execute the maven command
    • Invoke Top level Maven Targets: Specify goals from here Preview

Leave a Reply

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

About continuous learner

devops & cloud enthusiastic learner