5. Exigen Services confidential
What to do with Maven?
• 4 independent artifacts with dependencies
• Build in one step?
• Organize versioning?
• Keeping up to date?
• Wrong!
• Maven Inheritance and Aggregation
• Solves the above problems
• Right!
5
6. Exigen Services confidential
Maven Inheritance & Aggregation
• <packaging>pom</packaging>
• Super pom
• Data in parent pom is inherited
• Maven dependency reactor
• Notes
• No cyclic dependencies
• No same modules
6
9. Exigen Services confidential
Maven in action
• What about deployment?
• EAR needed
• Special step needed
• Maybe divide frontend and backend?
• NB! One pom – one artifact
9
10. Exigen Services confidential
Maven in action
Parent
pom
Frontend
pom
Gwt
war
Frontend
wrapper
ear
Backend
pom
EJB A
ejb
EJB B
ejb
Backend
wrapper
ear
My library
jar
10
15. Exigen Services confidential
Maven reactor
• Collects all the available modules to build
• Sorts the projects into the correct build order
• a project dependency on another module in the build
• different rules with plugins dependencies
• the order declared in the <modules> element (if no other rule
applies)
• Builds the selected projects in order
• Be aware of cycles and same modules on different
parents
16
16. Exigen Services confidential
Conclusion
• Inheritance and aggregation
• Flat/Tree structure
• Maven reactor
• Dependency&Plugin management
• Deploy to Nexus/Weblogic problem
17
18. Exigen Services confidential
Maven properties
• Just as common Ant properties
• ${property_name}
• Case sensitive
• Upper case for environment variables
• Dot(.) notated path
19
19. Exigen Services confidential
Predefined properties
• Build in properties
• ${basedir} – directory with pom
• ${version} – artifact version
• Project properties
• ${project.build.directory}
• ${project.build.outputDirectory} (target/classes)
• ${project.name}
• ${project.version}
• Local user settings
• ${settings.localRepository}
• Environment properties
• ${env.M2_HOME}
20
20. Exigen Services confidential
Maven profiles
• Maven profile – special way for configuring
build
• Different environments – different results
• Renaming
• Different build cycles
• Special plugin configuration
• Just different targets
• For different users
22
21. Exigen Services confidential
Maven profiles
• Per project
• pom.xml
• Per user
• %USER_HOME%/.m2/settings.xml
• Per computer (Global)
• %M2_HOME%/conf/settings.xml
23
22. Exigen Services confidential
Maven profiles
• Activation
• By hand (-P profile1,profile2)
• <activeProfiles>
• <activation>
• By environment settings
• By properties
24
24. Exigen Services confidential
Mojo
• Plugin
• Executing action
• Mojo – magical charm in hoodoo
• Just a Goal
• Plugin consists of Mojos
• Some parameters
• MOJO aka POJO (Plain-old-Java-object)
27
25. Exigen Services confidential
Mojo
• When we should use mojos?
• Run from command line
• Different execution parameters for different
configurations
• Group of mojos from same plugin with
different configuration
28