## Fetching from Repositories

The infrastructure offered by PDE Build provides steps to fetch the source code to build from a repository as part of the build process. Two possibilities are available: let PDE build automatically fetch the source, or fetch the source code manually.

### Automated source code fetching from CVS

Given the identifier of a feature that needs to be built, the build infrastructure is able to fetch from CVS all the included features and plug-ins.

In order to know where to get things from, PDE uses map files. A map file is a java property file which maps feature and plug-in ids to a location and a tag in a repository. The format of a map file entry for fetching from CVS is:

    <elementType>@<elementID> = CVS, <TAG>, <CVSROOT>[,<PASSWORD>[,<PATH>[,<CVSPASSFILE>]]]

where `elementType` is one of `bundle`, `feature`, `plug-in` or `fragment`. If the path is not specified then the element name will be used as CVS module instead, for example:

    plugin@org.foo.bar=CVS,v20060501,:pserver:anonymous@cvs.example.org:/cvsroot/foo

will fetch the plug-in `org.foo.bar` that has been labeled with the tag `v20060501` from `cvs.eclipse.org/cvsroot/foo/org.foo.bar`

#### Setting up for CVS source fetching

To set up fetching your source from CVS, you should do the following:

- Make sure you have a cvs.exe on your system search path. (Download CVS from here).
- Create a folder called maps in the build directory.
- Create a file with extension .map in the maps folder.
- Fill in this map file with all the elements that need to be fetched from a repository.
- Edit the build.properties file from the configuration folder and comment out the line `skipFetch=true`. If that property is set, then PDE build will skip the entire fetch phase. If you want the tag specified in the map files to be ignored you can set the property `fetchTag` to a specific value. This is useful when doing a nightly build from HEAD instead of from the tagged versions.

#### Getting the map files from CVS

Map files are usually stored in a repository. PDE Build offers default infrastructure to get those map files from a CVS repository. To enable this function change the following properties in your configuration's build.properties from your configuration directory:

- skipMaps: Comment out this property. If this property is set, then PDE build will not fetch the map files.
- mapsRepo = :pserver:anonymous@example.com/path/to/repo. The CVS repository from which to get the map files.
- mapsRoot = /path/to/maps. The path in the CVS repository to the directory containing the map files.
- mapsCheckoutTag = HEAD. The CVS tag to use to checkout the map files.

Fetching the map files from CVS occurs during the Pre-Build phase of the build. Scripts to fetch all the features and plug-ins included in the feature you are building will be generated and run during the fetch phase of the build.

### Automatic fetching from other repositories

PDE Build provides an extension point where fetch script generators for different repositories can be plugged in. When your eclipse install contains a bundle that provides a script generator extension for a different type of repository, you can use that repository by specifying it in your map file entries:

    <elementType>@<elementID> = <REPOSITORY>, <TAG>, [...]

The format of the map entry after the TAG will depend on the extension.

If you are automatically fetching your map files from the repository, you will need to copy the customTarget.xml file from org.eclipse.pde.build/templates/headless-build into your configuration directory. The target getMapFiles is used to fetch the map files, this should be modified to fetch from your repository.

### Getting source code manually

You can write custom fetch targets to retrieve your plug-ins and features which can be invoked from the preSetup or postSetup targets in the customTargets.xml file. Features and plug-ins should be fetched to `${buildDirectory}/features` and `${buildDirectory}/plugins` respectively.