Professional Documents
Culture Documents
Properties and
Profiles
ADVANCED CONCEPTS
Agenda
Plugins
Maven lifecycles
Plugin binding
Plugin configuration
Properties
Build properties
System properties
Filtering
Profiles
Reactor
Maven in a nutshell
Maven Basics
Convention over configuration
Convention for source code organization
src/main/java
src/webapp
src/test/java
Dependency Management
Remote repository and local repository
Transitive dependencies
Maven Plugins
Various components that take advantage of a project model.
Build tasks
Test tasks
Installation tasks
Maven Lifecycle
3 lifecycles
Clean
Default
Site
Plugin Binding
Some plugin goals are bound to a phase by default.
E.g. maven-failsafe-plugin
Not included by default
When declared, two goals bind to a lifecycle phase
failsafe:integration-test -> integration-test
failsafe:verify -> verify
Plugin Configuration
Plugin <configuration> element.
In plugin definition
Applied for default lifecycle bindings
Applied for explicit execution
In <execution>
Applied for bound execution only
Maven Properties
Build properties
Defined in pom.xml <properties> element
Inherited from parent poms
System properties are copied over build properties
Usage
Plugin configuration
Dependency versions
Dependency management
Filtering
Supported in resources plugin, war plugin and some more.
Enabled by <filtering>true</filtering>
Standard resources in build definition
Plugin configuration for war plugin
System properties
Supported by some plugins that launches other jvm processes
E.g. surefire or failsafe plugin
When using forkMode <> none
<systemPropertyVariables>
Profiles
Profiles allows alternative build executions within the same pom
Different <modules/>, <dependencies/>, etc.
Different plugin configuration, different resources
Inherited from parent
Activation
Explicit: $ mvn Pprofile1,profile2
Activated by properties
Activated by settings.xml
Maven reactor
Maven builds recursively, using nested <modules/>
Can be tweaked by maven parameters
$ mvn N
$ mvn pl m1, m2,
$ mvn pl :m1
$ mvn pl m1 am
$ mvn pl m1 amd
$ mvn rf m1
-> non-recursive
-> project list
-> by artifact id instead of directory name
-> also make requirements
-> also make dependents
-> resume from