11. What is Maven
• Dependency management tool
• With repository
log4j:log4j:1.2.15
c.e.m:web:7.0
org.apache.struts:structs-core:2.1.0
org.springframework:spring-core:2.5
12. What is Maven
• Dependency management tool
• With repository
log4j:log4j:1.2.15
Depends on org.apache.struts:structs-core:2.1.0
Repository
org.springframework:spring-core:2.5
c.e.m:web:7.0
21. Core Concepts
• Coordinate
• groupId – derived from project name, rather than
organization name
• artifactId – derived from module name, rather
than project name
• version – project version
22. Core Concepts
• Coordinate
• groupId – derived from project name, rather than
organization name
• artifactId – derived from module name, rather
than project name
• version – project version
• packaging – project packaging type, like jar
(default)
23. Core Concepts
• Coordinate
• groupId – derived from project name, rather than
organization name
• artifactId – derived from module name, rather
than project name
• version – project version
• packaging – project packaging type, like jar
(default)
• classifier – additional artifacts, like -javadoc.jar
24. Core Concepts
• Dependency
• GAV
• type
• scope
• optional
• exclusions
26. Core Concepts
• Repository Layout
• GAV
• Repository Type upload
• Local
• Remote download
• Central
• Nexus
27. Core Concepts
• Snapshot version
• 7.0.0-SNAPSHOT
• 7.0.0-20120214.221414-13
• > mvn clean install -U
• Update daily by default, -U to force updating
• Used for intermedium version
28. Core Concepts
• Snapshot version
• 7.0.0-SNAPSHOT
7.0.0-pc1-SNAPSHOT
•
7.0.0
7.0.0-20120214.221414-13
7.0.0-pc2-SNAPSHOT
7.0.1-SNAPSHOT 7.0.1 7.0.2-SNAPSHOT
• > mvn clean install -U 7.0.1-pc1-SNAPSHOT
• Update daily by default, -U to force updating
7.0.0-SNAPSHOT 7.1.0-SNAPSHOT master
• Used for intermedium version
30. Lifecycle and Plugin
Plugin internal binding
Lifecycle Phase Plugin Goal Task
process-resource maven-resources-plugin:resources copy main resources file to output dir
compile maven-compiler-plugin:compile compile main java code to output dir
process-test-resource maven-resources-plugin:testResources copy test resource file to test output dir
test-compile maven-compiler-plugin:testCompile compile test java code to test output dir
test maven-surefire-plugin:test run tests
package maven-jar-plugin:jar pack the jar file
install maven-install-plugin:install install project output artifacts to local repo
deploy maven-deploy-plugin:deploy deploy project output artifacts to remote repo
31. Acknowledgement
• Most of the contents are
from Juven's book
• You'll have chance to go
through the whole
training session talking
about Maven hold by
Juven
Juven Xu
www.juvenxu.com
juven.xu@outsofting.com
twitter.com/juvenxu
weibo.com/juvenxu
32. Acknowledgement
• Most of the contents are
from Juven's book
• You'll have chance to go
through the whole
training session talking
about Maven hold by
Juven
Juven Xu
www.juvenxu.com
juven.xu@outsofting.com
twitter.com/juvenxu
weibo.com/juvenxu
33. JUnit in Action
• Why Unit Test
• Go with Maven
• The Calculator Case
• Coverage
• Guidelines
34. Why Unit Test
http://www.agitar.com/solutions/why_unit_testing.html
35. Why Unit Test
• Be professional
• Find defects as early as possible
• Living description of how the unit works
• Insurance and confidence for refactoring
• A lot of pleasure
39. Coverage
• Coverage helps
• Understand unit test quality
• Understand Product quality
• Pass QD5 in /// the company
40. Coverage
• Coverage helps
• Understand unit test quality
• Understand Product quality
• Pass QD5 in /// the company
• Coverage types
• Line
• Branch
• ...
41. Coverage
• Coverage helps
• Understand unit test quality
• Understand Product quality
• Pass QD5 in /// the company
• Coverage types
• Line
• Branch
• ...
• Coverage tools
• Cobertura
• Emma
• Clover (commercial)
43. Homework
• Convert AddressBook project to Maven
based
• Add unit test
• Search and learn how to use Cobertura, and
make sure unit test line coverage reaches
85%
• Add necessary configuration and files to
facilitate generating Maven site