Chapter 17. Writing Plugins


Although this chapter covers an advanced topic, don’t let the idea of writing a Maven plugin intimidate you. For all of the theory and complexity of this tool, the fundamental concepts are easy to understand and the mechanics of writing a plugin are straightforward. After you read this chapter, you will have a better grasp of what is involved in creating a Maven plugin.

Programming Maven

Most of this book has dealt with using Maven, though you haven’t yet seen many code examples dealing with Maven customization. In fact, you haven’t seen any. This is by design, since 99 out of 100 Maven users will never need to write a custom plugin to customize Maven. There is an abundance of configurable plugins, and unless your project has particularly unique requirements, you will have to work to find a reason to write a new plugin. And a very small percentage of people who end up writing custom plugins will ever need to crack open the source code for Maven and customize a core Maven component. If you really needed to customize the behavior of Maven, you would then write a plugin. Modifying the core Maven code is as far out of scope for most developers as modifying the TCP/IP stack on an operating system; it is that abstract for most Maven users.

On the other hand, if you are going to start writing a custom plugin, you will have to learn a bit about the internals of Maven: How does it manage software components? What does a plugin do? How can I customize ...

Get Maven: The Definitive Guide now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.