Maven - SPLessons
SPLessons 5 Steps, 3 Clicks
5 Steps - 3 Clicks

Maven Pom XML

Maven Pom XML

shape Introduction

Before learning about Maven Pom XML files, Maven Archetype has is to be known. Maven Pom XML chapter explains about the File Structure and POM files.

shape Description

Basically, Maven creates two things: Initially, run Maven Archetype colon generate command to get the output.

File Structure

shape Description

Initially, Maven finds source/main/Java directory in the project and then compiles the code to a target directory by referencing the default and the code is written in pom.xml file.

shape Structure

After testing & packaging into the jar file and by executing the Maven package, the following structure appears.

POM Files

shape Description

POM stands for Project Object Model, in which the structure and identity of a project is declared and the builds are configured. POM will relate various projects. POM gives detailed information about the project and helps in generating source output by modifying the default behavior. It is similar to Java’s web.xml or ANT’s build.xml. The description and configuration is established in four different categories.

shape Conceptual figure

Super POM

shape Description

Super POM is the extension of POM in a project and defines the default configuration variables being shared by the projects.
  • The default super POM has a remote repository called central.
  • Central repository has plug-ins.
  • Default values for directories can be set using build element in the Standard Directory layout.
  • Default versions of core plug-ins are defined in Super POM.

shape Examples

The following is an example of super POM: [xml] <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <parent> <groupId>org.codehaus.mojo</groupId> <artifactId>my-parent</artifactId> <version>2.0</version> <relativePath>../my-parent</relativePath> </parent> <artifactId>my-project</artifactId> ... </project>[/xml]

Summary

shape Key Points

  • POM is the Project Object Model.
  • It defines the relationship between the projects.
  • All POM files will be inherited from Super POM.