Introduction

The purpose of this chapter is to show a migration path from an existing build in Ant to Maven.

The Maven migration example is based on the Spring Framework build, which uses an Ant script. This example will take you through the step-by-step process of migrating Spring to a modularized, component-based, Maven build.

You will learn how to start building with Maven, while still running your existing, Ant-based build system. This will allow you to evaluate Maven’s technology, while enabling you to continue with your required work.

You will learn how to use an existing directory structure (though you will not be following the standard, recommended Maven directory structure), how to split your sources into modules or components, how to run Ant tasks from within Maven, and among other things, you will be introduced to the concept of dependencies.

Introducing the Spring Framework

The Spring Framework is one of today’s most popular Java frameworks. For the purpose of this example, we will focus only on building version 2.0-m1 of Spring, which is the latest version at the time of writing.
The Spring release is composed of several modules, listed in build order:

  • spring-core
  • spring-beans
  • spring-aop
  • spring-context
  • spring-context-mock
  • spring-dao
  • spring-jdbc
  • spring-support
  • spring-web
  • spring-web-mock
  • spring-webmvc
  • spring-remoting
  • spring-portlet
  • spring-jdo
  • spring-hibernate2
  • spring-hibernate3
  • spring-toplink
  • spring-ojb
  • spring-mock


Figure 1-1: Dependency relationship between Spring modules
In figure 1-1. you can see graphically the dependencies between the modules. Optional dependencies are indicated by dotted lines.
Each of these modules corresponds, more or less, with the Java package structure, and each produces a JAR. These modules are built with an Ant script from the following source directories:

  • src and test: contain JDK 1.4 compatible source code and JUnit tests respectively
  • tiger/src and tiger/test: contain additional JDK 1.5 compatible source code and JUnit tests
  • mock: contains the source code for the spring-mock module
  • aspectj/src and aspectj/test: contain the source code for the spring-aspects module

Each of the source directories also include classpath resources (XML files, properties files, TLD files, etc.).
For Spring, the Ant script compiles each of these different source directories and then creates a JAR for each module, using inclusions and exclusions that are based on the Java packages of each class. The src and tiger/src directories are compiled to the same destination as the test and tiger/test directories, resulting in JARs that contain both 1.4 and 1.5 classes.

Thank you for requesting a Maestro evaluation! This is our passion, and we want you to be successful. Please let us know how we may help!

Please enter your name, company email address and phone, and we will send you a link to your pre-built hosted evaluation within minutes.






I have read and agree to the Terms and Conditions.