O'Reilly logo

Maven: The Definitive Guide by Sonatype Company

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 18. Writing Plugins in Alternative Languages

You can write a Mojo in Java, or you can write a Mojo in an alternative language. Maven has support for a number of implementation languages, and this chapter will show you how to create plugins in three languages: Ant, Ruby, and Groovy.

Writing Plugins in Ant

Ant isn’t a language as much as it is a build tool that allows you to describe a build as a set of tasks grouped into build targets. Ant then allows you to declare dependencies between build targets; for example, in Ant you are essentially creating your own lifecycle. An Ant build.xml might have an install target that depends on a test target that depends on a compile target. Ant is something of an ancestor to Maven; it was the ubiquitous procedural build tool that almost every project used before Maven introduced the concept of wide-scale reusability of common build plugins and the concept of a universal lifecycle.

Although Maven is an improvement on Ant, Ant can still be useful when describing parts of the build process. Ant provides a set of tasks that can come in handy when you need to perform file operations or XSLT transformations or any other operation you can think of. There is a large library of available Ant tasks for everything from running JUnit tests to transforming XML to copying files to a remote server using SCP. An overview of available Ant tasks can be found online in the Apache Ant Manual. You can use these tasks as a low-level build customization language, ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required