Your SlideShare is downloading. ×
Maven plugins, properties en profiles: Advanced concepts in Maven
Upcoming SlideShare
Loading in...5

Thanks for flagging this SlideShare!

Oops! An error has occurred.


Introducing the official SlideShare app

Stunning, full-screen experience for iPhone and Android

Text the download link to your phone

Standard text messaging rates apply

Maven plugins, properties en profiles: Advanced concepts in Maven


Published on

An introduction to some advanced concepts in Maven: Plugins, Properties and Profiles.

An introduction to some advanced concepts in Maven: Plugins, Properties and Profiles.

Published in: Technology, Art & Photos

1 Like
  • Be the first to comment

No Downloads
Total Views
On Slideshare
From Embeds
Number of Embeds
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

No notes for slide


  • 1. Maven Plugins, Properties and Profiles ADVANCED CONCEPTS
  • 2. Agenda Plugins ◦ Maven lifecycles ◦ Plugin binding ◦ Plugin configuration Properties ◦ Build properties ◦ System properties ◦ Filtering Profiles Reactor
  • 3. Maven in a nutshell
  • 4. Maven Basics Convention over configuration ◦ Convention for source code organization ◦ src/main/java ◦ src/webapp ◦ src/test/java ◦ Plugins with default configurations ◦ Jar, war, ear ◦ Surefire tests ◦ Reporting Dependency Management ◦ Remote repository and local repository ◦ Transitive dependencies
  • 5. Maven Plugins Various components that take advantage of a project model. ◦ Build tasks ◦ Test tasks ◦ Installation tasks A set of goals + configuration ◦ Can be executed directly: ◦ $ mvn plugin:goal ◦ Can be bound to a phase in a maven lifecycle ◦ $ mvn package ◦ Multiple plugin goals can be bound to the same phase
  • 6. Maven Lifecycle 3 lifecycles ◦ Clean ◦ Default ◦ Site Fixed set of phases Default plugin bindings ◦ Depends on packaging ◦ See
  • 7. 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 ◦ Custom <execution> to bind to a different goal
  • 8. Plugin Configuration Plugin <configuration> element. ◦ In plugin definition ◦ Applied for default lifecycle bindings ◦ Applied for explicit execution ◦ In <execution> ◦ Applied for bound execution only ◦ XML Deserialization for complex configuration elements Plugins can use build properties to get default configuration values ◦ Defined in plugin documentation ◦ Useful for default plugins (convention over configuration) ◦ E.g. -DskipTests
  • 9. 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
  • 10. 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 Replaces ${xxx} by corresponding build property. ◦ During copy, not in place. ◦ Build property can be overriden by system property. ◦ At build time! Not changed later.
  • 11. System properties Supported by some plugins that launches other jvm processes E.g. surefire or failsafe plugin ◦ When using forkMode <> none ◦ <systemPropertyVariables> E.g. launching application containers ◦ JBoss-as plugin ◦ Jetty plugin ◦ Tomcat plugin
  • 12. 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 Could be used in combination with filtering ◦ To have different artifacts for different usages ◦ Use different classifier in resulting artifact ◦ Should not be used to escalate from DEV->TEST->PROD
  • 13. 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