# Builds

The central EGit and JGit builds run on the JGit/EGit Hudson instance

Prerequisites for the Maven build are

- at least Maven 3.5.2
- see settings.xml reference on how to do basic Maven configuration
- if you want to learn how Maven works start reading the Maven Getting Started Guide

Hudson

- development build jobs
- maintenance and release build jobs

## JGit

- JGit can be built using Maven or Bazel
- use Java 8 to run the JGit build
- JGit packaging projects (Eclipse features and p2 repository) are built using Maven and Tycho.

## EGit

- EGit is built using Maven and Tycho.

## Mailing Lists

If you're interested in following builds, please check out the following mailing lists:

- Subscribe to jgit-build@eclipse.org
- Subscribe to egit-build@eclipse.org

## Maven Build

- Due to a limitation of Tycho it is not possible to mix pom-first and manifest-first builds in the same reactor build hence the pom-first JGit build has to run separately before the build for the manifest-first JGit packaging project.
- The local maven builds must share the same local Maven repository otherwise dependencies between these builds cannot be resolved.
- To run the build behind a firewall follow http://maven.apache.org/guides/mini/guide-proxies.html

Complete build sequence for a clean build (assuming $M2_HOME/bin is on the path and local Maven repository at ~/.m2/repository):

    [~/src/jgit] $ mvn clean install
    [INFO] Scanning for projects...
    ...

    [~/src/jgit] $ mvn -f org.eclipse.jgit.packaging/pom.xml clean install
    [INFO] Scanning for projects...
    ...

    [~/src/jgit] $ cd ../egit

    [~/src/egit] $ mvn clean install
    [INFO] Scanning for projects...
    ...

    [~/src/jgit] $ cd ../egit-github

    [~/src/egit-github] $ mvn clean install
    [INFO] Scanning for projects...
    ...

The EGit build uses the JGit p2 repository to resolve jgit dependencies. For local builds the build assumes that egit and jgit source trees are located under a common parent folder. If this is not the case the path to the jgit p2 repository has to be injected via system property:

    [~/src/egit] $ mvn clean install -Djgit-site=file:/path/to/jgit/org.eclipse.jgit.packaging/org.eclipse.jgit.repository/target/repository

in the same way you can configure a custom path for the build of egit-github to the egit p2 repository

    [~/src/egit-github] $ mvn clean install -Degit-site=file:/path/to/egit/org.eclipse.egit.repository/target/repository

The hudson build on build.eclipse.org uses (for SNAPSHOT builds):

    [~/src/egit] $ mvn clean install -Djgit-site=https://repo.eclipse.org/content/unzip/snapshots.unzip/
                         org/eclipse/jgit/org.eclipse.jgit.repository/${JGIT_VERSION}/org.eclipse.jgit.repository-${JGIT_VERSION}.zip-unzip/

If you wan to build EGit for the specific Photon (4.8) platform, consider using the `egit-4.8` target platform:

    [~/src/egit] $ mvn -Dtarget-platform=egit-4.8 clean install

For EGit version 4.10, `egit-4.5` (Mars, Eclipse 4.5), `egit-4.6` (Neon, Eclipse 4.6), `egit-4.7` (Oxygen, Eclipse 4.7), and `egit-4.8` (Photon, Eclipse 4.8) are available. In addition `egit-4.8-staging` refers to the Photon staging repository.

Upon a successful build, a p2 update site should be generated inside egit/org.eclipse.egit.repository/target/repository. If not, make sure the target platform has been downloaded from within Eclipse (Windows>Preferences>Plug-in Development>Target Platform). The default target platform defined in the maven build is currently Eclipse 4.7. If you skip setting the system property `target-platform` the target platform for Eclipse 4.7 will be used.

## JGit Bazel Build

Since Gerrit is built using Bazel a Bazel build was also implemented for JGit. This simplifies working on Gerrit features which also require changes in JGit.

- Install Bazel
- To build all libraries run

    bazel build :all

- The following test labels are supported: api, attributes, dfs, diff, http, lfs, lfs-server, nls, notes, pack, patch, pgm, reftree, revplot, revwalk, storage, submodule, symlinks, transport, treewalk, util
- To run all tests execute

    bazel test //...

- To run specific tests, using labels:

    bazel test --test_tag_filters=api,dfs,revplot,treewalk //...

- to run build with the errorprone static analyzer execute

    bazel build --java_toolchain //tools:error_prone_warnings_toolchain :all

Note that the Bazel build does not yet support building JGit OSGi bundles, Eclipse features and the p2 repository which are required to install JGit in Eclipse.

## FindBugs and PMD

As part of the build, JGit and EGit run FindBugs and PMD to find issues.

- JGit FindBugs Results
- JGit DRY (PMD) Results
- EGit FindBugs Results
- EGit DRY (PMD) Results

## Checking for JGit API Changes using API Baseline

The JGit projects have API tooling enabled. In order to use PDE API tools to get assistance with maintaining API changes and additions you need to set an API baseline:

- download the p2 repository for the latest EGit release (which includes the JGit artifacts) to a local folder, e.g. `~/egit-releases/updates-4.9.1`, find the p2 repository URLs here and download the p2 repository of the latest minor release (service releases don't change API) using the corresponding link in the last column of that table
- in Eclipse click "Preferences > Plug-In Development > API Baselines", click "Add Baseline..." and define a new baseline (e.g. egit-4.9.1) and point it to the local copy of the corresponding EGit p2 repository.
- the API tools will then raise warning/errors for all detected problems and provide quick fixes helping to resolve these problems
- see the PDE API Tools User Guide for more details.

## Signing and Publishing

EGit and JGit builds running on the JGit/EGit Hudson are automatically signed (using the CBI eclipse-jarsigner-plugin) and published to the folder

    master branch:         /home/data/httpd/download.eclipse.org/egit/updates-nightly
    latest stable branch:  /home/data/httpd/download.eclipse.org/egit/updates-stable-nightly

- To enable signing the maven profile `eclipse-sign` must be enabled via the option `-P eclipse-sign` in the respective build jobs running at https://hudson.eclipse.org/egit/
- To enable publishing to download.eclipse.org the maven profile `publish` must be enabled via the option `-P publish` in the egit build job.

## Contribution to Release Train

The release train contribution for JGit and EGit is maintained in the git repository

    ssh://git.eclipse.org/gitroot/simrel/org.eclipse.simrel.build.git

in the file

    egit.b3aggrcon

The release train build is coordinated on the cross-project-issues-dev mailing list