New Project Based Build System
Overview
InterMine has now been split into several distinct libraries. The code and resources for each library are grouped into individual "project" directories. There is a top-level directory called imbuild which contains the build infrastructure required by all projects. It contains all reusable ant build file implementations and build related ant-tasks.
The directory structure of a project that compiles some Java and produces a jar file will look like this:
my-library/
src/
lib/
resources/
build.xml
project.properties
project.properties should contain at the minimum a compile.dependencies property:
compile.dependencies = something/main, something-else/whatever
and the build file can be quite empty:
<project name="my-library" default="default" basedir="."> <description>build, test, package my-library</description> <import file="../../imbuild/library.xml"/> </project>
A project build file should be an empty as possible. Ideally it should contain the bare minimum of very product specific ant. Reusable ant is imported using the import task. Multiple imports can be used to pull in reusable targets/taskdefs/macrodefs. Imported targets can be overridden to customise the build process. The imported build implementations for different project types contain many targets that exist purely for this purpose. They have names like "-pre-jar" and are usually empty. The build scripts in imbuild contain many examples of these 'hook' targets and target overriding.
Tests
There is a separate type of project for tests. Tests are not stored in the project that the tests refer to but in a separate project that depends on the other. This makes the dependency handling system simpler (with each project produces exactly one artifact) and fully separates the test infrastructure from the production code. It also allows test projects to depend and extend on other test projects and this is handled through exactly the same dependency resolving system. The current convention is that library code is contained in a project directory "main" and the associated test project is in a directory called "test". Both "main" and "test" directories reside in a directory possessing the name of the library. For example:
intermine/
objectstore/
main/
test/
Useful links
- Ant macrodef task
- Ant import task
- Ant-contrib tasks -- we use a patched version (the OutOfDate? task).
- http://ant.apache.org/ant_in_anger.html -- everyone should read this
