5.4. Using Binary DependenciesImagine yourself on a team of several developers with a project made of several Maven subprojects. When you wish to build the Maven subproject you're working on you have two choices: start by building all its dependencies using the Multiproject plug-in (see Chapter 3) or directly build the said subproject assuming that the dependencies have already been built and are available in your Maven remote repository. The first strategy uses source dependencies (in the sense that you build the dependencies from the sources) and the second strategy uses binary dependencies. The latter is very useful on medium to large projects where building all dependent projects on each developer's machine would take too long. It's also extremely useful when you have several teams, each developing a subset of the full application; each team can concentrate on its own code and release the code as a binary artifact to the other teams. This lab will teach you how to set up a binary dependency strategy. 5.4.1. How do I do that?You know how to create your own remote repository, how to set up a continuous build, and how to deploy project artifacts. Now you have all of the ingredients necessary for implementing a binary dependencies strategy. Let's go through the architecture of a binary dependencies build strategy (see Figure 5-7) to see what we need to set up:
Figure 5-7. Building a Maven project using fresh binary dependenciesThe key here is to set up a continuous build so that the remote repository is constantly fed with the latest version of all the project's artifacts. Let's take the example of the QOTD multiproject that you saw in Chapter 3, and let's imagine that you have added a new acceptance test to the acceptance subproject and you'd like to build it. In the previous lab you added a new qotd:deploy goal that deploys all the project's artifacts to the remote repository. You simply need to modify the maven.cruisecontrol.goals property that you used in the previous lab so that CruiseControl calls the qotd:deploy goal and thus deploys fresh artifacts whenever there's a code change: maven.cruisecontrol.goals = scm:update|clean qotd:deploy Now, simply type maven qotd:build: C:\dev\mavenbook\code\qotd\acceptance>maven qotd:build [...] 5.4.2. What just happened?You have just set up one of the best possible Continuous Integration implementation strategies by using binary dependencies. Imagine the advantages of what you've set up:
|