This topic describes how to create and edit a project file when your code requires multiple or complicated checkout and build commands.
Project configuration files define the commands required to access your source files and to build your code base. These commands are used when preparing your code for analysis. In most cases a
project file, containing all of the necessary detail, can be created interactively using the
bootstrap command. However, your project may have a complicated checkout or build procedure that cannot be defined in a single step with
bootstrap. In such cases, it may be necessary to modify your project file manually to include your extra commands.
You can create a new project file using either the
createProject commands. The most appropriate method to use depends upon the exact nature of the code base of your new project, as explained below. After you have created a
project file you can manually change the following elements:
checkout—This defines the commands that are used to get a revision of your code from a source control repository.
build—This defines the commands that are used to build the code base for compiled languages, or the extractor process to run for interpreted languages.
source-location—(optional) This defines where the build should occur.
In addition, you should check that the values defined by the
timeout elements are suitable for the new project. For further information, see project file.
Assessing your source code
Each project file provides the
source-location information for the files written in a single language in your project. Therefore, if your project consists of more than one language, additional
project files are required. You can check exactly which languages are present in a project using the
- Check out the latest version of your source code into a local directory–for further information about adding your code to a local directory see Managing code checkout of large projects.
- Move into the directory that the source files have been added to.
The command analyzes all files in the new directory and reports the number of files, lines of code, and lines of comment for each file extension that it finds. You must create a separate
project file for each language that you want to analyze using one of the approaches outlined below. For further information about the command, see overview.
bootstrap to perform the project creation steps
bootstrap command simplifies the project creation process and is the best command to use if your new code base is not similar to any of your existing projects. In this case, you can use the command to perform the initial and create the project file in the correct format. You can then exit the
bootstrap process and continue editing your project file manually, which allows you to add multiple checkout and build commands. You can also specify the directories from where your checkout and build commands should be run.
createProject to copy an existing project
You can create a new project file using the
createProject command, by copying an existing project file. This method is useful if the new code base has similar build and checkout commands to an existing project (for example, a different branch of the same repository). When
createProject is complete, you can then edit the project file to modify the checkout and build commands for the new code base.
createProject to copy a template
You can also create a new project using the
createProject command to copy a template file. This method is useful if the new project has similar build and checkout commands to a predefined template. If this is the case run the
createProject command as above and specify the path to the template directory using the
--template flag. Again, when
createProject is complete, you must edit the project file to define the checkout and build commands required for the new code base.
You can edit a project file using your preferred text editor.
Changes to most elements in the project file are applied to all new snapshots created after the change (created using the addSnapshot or addLatestSnapshot command). For further information about changing specific XML elements in the project file, you should refer to: