6. 6
INSTALLATION - config
• Per Project- Defined in the POM itself (pom.xml).
• Per User- Defined in the Maven-settings
(%USER_HOME%/.m2/settings.xml).
• Global- Defined in the global Maven-settings
(%M2_HOME%/conf/settings.xml).
13. 13
PROJECT OBJECT MODEL
• What does a project contain?
• What type of packaging a project
needs?
• Does the project have a parent?
• What are the dependencies?
22. 22
Build Lifecycle
• “Build Lifecycle” is the central concept
• A build lifecycle is an organized
sequence of phases that exists to
give order to a set of goals
• A build lifecycle is made up of phases
• A build phase is made up of goals
(verbs)
30. 30
DEPENDENCIES
• compile : - the project needs this dependency at compile time
- compile is the default scope;
• provided : - provided dependencies are used when you expect the
JDK or a container to provide them.
-They are not transitive.
- Ex: servlet API
• runtime : - runtime dependencies are required to execute and test
the system, but they are not required for compilation.
- Ex: JDBC driver
• test : - test-scoped dependencies are not required during the
normal operation of an application
- they are available only during test compilation and
execution phases.
• system: -The system scope is similar to provided except that you
have to provide an explicit path to the JAR on the local file
system. ( NOT RECOMMENDED)
31. 31
DEPENDENCIES – version ranges– Exclusive [ , ] , Inclusive ( , )
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>[3.8,4.0)</version>
</dependency>
– Less then
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>[ ,3.8.1]</version>
</dependency>
– Preferred version
<version>3.8.1</version>
– Exact version
<version>[3.8.1]</version>
32. 32
DEPENDENCIES – Transitive & Optional
• Transitive dependencies
A B C
Act-OL Hibernate Commons Collections
Exercise:
Act-OL – test JUnit – comp. Commons
• Optional dependencies
42. 42
BUILD PROFILES
• Allow the customization of a particular
build for a particular environment;
• Enable portability between different
build environments
43. 43
PROFILES – PROFILE TYPES
• Per Project- Defined in the POM itself (pom.xml).
• Per User- Defined in the Maven-settings
(%USER_HOME%/.m2/settings.xml).
• Global- Defined in the global Maven-settings
(%M2_HOME%/conf/settings.xml).
44. 44
PROFILES – how to trigger ?
• Explicitly
mvn groupId:artifactId:goal -P profile-1,profile-2
• Through Maven settings
<settings>
...
<activeProfiles>
<activeProfile>profile-1</activeProfile>
</activeProfiles>
</settings>
45. 45
• Based on env. vars
<profile>
<activation>
<property>
<name>environment</name>
<value>test</value>
</property>
</activation>
...
</profile>
• Build settings
<activation>
<jdk>1.4</jdk>
</activation>
• OS settings