17.08.2016 Views

Apache Maven 3 Cookbook

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Extending <strong>Apache</strong> <strong>Maven</strong><br />

<br />

org.apache.maven.plugins<br />

maven-jxr-plugin<br />

2.1<br />

<br />

<br />

<br />

Creating a <strong>Maven</strong> plugin using Ant<br />

<strong>Apache</strong> Ant is a software build automation tool for the Java platform. It uses an XML build<br />

configuration file (similar to <strong>Apache</strong> <strong>Maven</strong> and dissimilar to Make) for defining project builds.<br />

Ant is extremely popular. Not only is it lightweight and an occasional replacement for <strong>Maven</strong><br />

itself, but it inherently is easy to use for non-programmers. This is because it consists of<br />

instructions written in XML rather than any programming language.<br />

If you want to create an extension for <strong>Maven</strong>, that is, create a <strong>Maven</strong> plugin in <strong>Apache</strong> Ant,<br />

then this recipe is for you.<br />

Getting ready<br />

For this recipe, you need <strong>Apache</strong> <strong>Maven</strong> 3 installed and set up correctly. You also need to be<br />

familiar with <strong>Maven</strong> concepts such as archetypes, project co-ordinates, dependencies, and<br />

so on.<br />

Additionally, you need to be familiar with <strong>Apache</strong> Ant and the overall reporting/documentation<br />

process in an <strong>Apache</strong> <strong>Maven</strong> project.<br />

How to do it...<br />

Let's get started.<br />

1. Create a new project named maven-plugant-plugin with the following folder tree<br />

structure thereafter:<br />

└───src<br />

└───main<br />

└───scripts<br />

2. Create an XML file named src/main/scripts/hello.build.xml with the<br />

following contents:<br />

<br />

<br />

Hello, World<br />

<br />

<br />

198

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!