maven

20
Project management and Comprehension tool

Upload: nishant-arora

Post on 12-Apr-2017

60 views

Category:

Technology


1 download

TRANSCRIPT

Page 1: Maven

Project management and Comprehension tool

Page 2: Maven

Maven... What is it?

Dependency ManagementPlugin-ins

POM

Lifecycles Inheritance

Page 3: Maven

Maven... What is it?

"build tool" • Generates deployable artifacts from the source

code.• Preprocessing, compilation, packaging, testing and

distribution.

"project management tool"

• Generates Web Site (Project Documentation)

• Run Reports

Page 4: Maven

Convention over Configuration Systems should "just work“.

o Pre-defined directory structures • Source • Tests • Documentation o Based on goals • compile, test, package, install, deploy, site… o Just learn the conventions! o Archetype plugin for easy project creation • mvn archetype:generate

Page 5: Maven

Standard Directory Layout

Page 6: Maven

POM (Project Object Model)o  Fundamental unit of work in Maveno Maven projects, dependencies, builds, artifacts: all of these are objects

to be modeled and described. These objects are described by an XML file called a Project Object Model (POM).

Reference: pom.xml

Page 7: Maven

POM – Important Attributesproject It is the root element of pom.xml file.

modelVersion It is the sub element of project. It specifies the modelVersion. It should be set to 4.0.0.

groupId * It is the sub element of project. It specifies the id for the project group.

artifactId * It is the sub element of project. It specifies the id for the artifact (project). An artifact is something that is either produced or used by a project. Examples of artifacts produced by Maven for a project include: JARs, source and binary distributions, and WARs.

Version * It is the sub element of project. It specifies the version of the artifact under given group.

* Maven Coordinates

Page 8: Maven

Dependency Management Mechanism for centralizing dependency information. Managing dependencies become difficult task once we've to deal

with multi-module projects (consists of hundreds of modules/sub-projects). Maven provides a high degree of control to manage such scenarios.

Page 9: Maven

Dependency Management(Contd.) o Maven Co-Ordinates – groupid, artifactid, version.

o type – packaging type.• jar• pom• test-jar• ejb-client etc.

o scope - compile (default), provided, runtime, test, system

o systemPath - use only if the dependency scope is “system”.

o optional - Marks optional a dependency when this project itself is a dependency.

Page 10: Maven

Dependency Management(Contd.)

Page 11: Maven

Maven - Plug-ins Maven is actually a plugin execution framework where every task is actually done by

plugins.

Types: Build Plugin - They execute during the build and should be configured in the

<build/> element of pom.xml. Ex: maven-dependency-plugin Reporting Plugin - They execute during the site generation and they should be

configured in the <reporting/> element of the pom.xml Ex: maven-site-plugin

Page 12: Maven

Maven - Plug-ins(Contd.)

Page 13: Maven

Maven - Plug-ins(Contd.) Beyond the standard coordinate of groupId:artifactId:version, there are elements which configure the plugin or this builds interaction with it.

inherited - true or false, whether or not this plugin configuration should apply to POMs which inherit from this one. Default value is true.

configuration - package specific configuration

executions - configure the execution of a plugin's goals.

Page 14: Maven

LifecyclesLifecycle is an organized sequence of phases that exist to give order to a set of goals.1) Clean

1) pre-clean2) clean3) post-clean

2) Default (sometimes called build) 1) validate2) compile3) test4) package5) verify6) install7) deploy

3) Site1) pre-site2) site3) post-site4) site-deploy

Page 15: Maven

Inheritanceo Provides inheritance via the parent element.

o All Maven POMs inherit values from a parent POM. If a POM does not specify a direct parent using the <parent> element, that POM will inherit values from the Super POM.

o The packaging type required to be pom for parent and aggregation (multi-module) projects.

Page 16: Maven

Inheritance (Contd.)

The elements in the parent POM that are inherited by its children are:

dependencies

developers and contributors

plugin lists

reports lists

plugin executions with matching ids

plugin configuration

Page 17: Maven

Super POMo All Maven project POMs extend the Super POM, which defines a set of

defaults shared by all projects. This Super POM is a part of the Maven installation.

o An analogy to how the Super POM is the parent for all Maven POM files, would be how java.lang.Object is the top of the class hierarchy for all Java classes.

Page 18: Maven

Lots covered…questions?

Page 20: Maven