Java Reference
In-Depth Information
Chapter 5. Build processes
This chapter covers
• Adding Groovy to Ant builds
• Using Maven with Groovy
• Groovy Grapes and @Grab
• The future: Gradle
Building source code is almost always a pain point in development organizations. An ideal
build process is automated end-to-end, including compilation, running tests, generating re-
ports, and producing any required artifacts. The process needs to be fast enough that it can
be done frequently, especially given modern agile approaches, and yet flexible enough to
adapt to the exigencies of individual teams.
In the Java world two primary approaches to automated builds have emerged over time.
Both are open source projects from Apache. The first is Ant ( http://ant.apache.org ), which
uses a library of tasks configured in XML backed by Java classes. The other is Maven ( ht-
tp://maven.apache.org ), which offers a rich array of options and promises to make the entire
process simple, but uses a highly opinionated API that requires a degree of mastery to use
effectively.
To start I want to address the goals of any build process, and then see how the various tools
attempt to meet them.
5.1. The build challenge
A software build combines several features that individually seem like they ought to be easy
but in practice become complicated. To build your code you must
• Download any necessary dependencies.
• Compile the source code with the dependencies properly resolved, handling any
cross-language issues that may arise.
• Run the unit, integration, and/or functional tests.
• Produce the desired artifacts, whatever they may be.
Search WWH ::




Custom Search