How to Build Spring Cloud Contract

Cloning the repository on Windows

While cloning this project on Windows, some files in the git repository may exceed the Windows maximum file path limit of 255 characters, which may result in an incorrectly (probably partially) checked out repository.spring-doc.cn

To resolve this issue, you can set the core.longPaths attribute to true or clone the Spring Cloud Contract repository.spring-doc.cn

To set the core.longPaths attribute to true, you have three options:spring-doc.cn

  • Change it for all users of the machine (doing so requires administrator privileges):spring-doc.cn

git config --system core.longPaths true
git clone https://github.com/spring-cloud/spring-cloud-contract.git
  • Change it for the current user (no administrative privileges required):spring-doc.cn

git config --global core.longPaths true
git clone https://github.com/spring-cloud/spring-cloud-contract.git
  • Change for just this repository (administrative privileges depend on where the repository is being cloned to):spring-doc.cn

git clone -c core.longPaths=true https://github.com/spring-cloud/spring-cloud-contract.git
You need to have all the necessary Groovy plugins installed for your IDE to properly resolve the sources. For example, in Intellij IDEA, having both the Eclipse Groovy Compiler Plugin and the GMavenPlus Intellij Plugin results in properly imported project.
Spring Cloud Contract builds Docker images. Remember to have Docker installed.
If you want to run the build in offline mode, you must have Maven 3.5.2+ installed.

Project structure

The following listing shows the Spring Cloud Contract folder structure:spring-doc.cn

├── config
├── docker
├── samples
├── scripts
├── specs
├── spring-cloud-contract-dependencies
├── spring-cloud-contract-shade
├── spring-cloud-contract-starters
├── spring-cloud-contract-stub-runner
├── spring-cloud-contract-stub-runner-boot
├── spring-cloud-contract-tools
├── spring-cloud-contract-verifier
├── spring-cloud-contract-wiremock
└── tests

The following list describes each of the top-level folders in the project structure:spring-doc.cn

  • config: Folder contains setup for Spring Cloud Release Tools automated release processspring-doc.cn

  • docker: Folder contains docker imagesspring-doc.cn

  • scripts: Contains scripts to build and test Spring Cloud Contract with Maven, Gradlespring-doc.cn

  • specs: Contains specifications for the Contract DSL.spring-doc.cn

  • spring-cloud-contract-dependencies: Contains Spring Cloud Contract BOMspring-doc.cn

  • spring-cloud-contract-shade: Shaded dependencies used by the pluginsspring-doc.cn

  • spring-cloud-contract-starters: Contains Spring Cloud Contract Startersspring-doc.cn

  • spring-cloud-contract-spec: Contains specification modules (contains concept of a Contract)spring-doc.cn

  • spring-cloud-contract-stub-runner: Contains Stub Runner related modulesspring-doc.cn

  • spring-cloud-contract-stub-runner-boot: Contains Stub Runner Boot appspring-doc.cn

  • spring-cloud-contract-tools: Gradle and Maven plugin for Spring Cloud Contract Verifierspring-doc.cn

  • spring-cloud-contract-verifier: Core of the Spring Cloud Contract Verifier functionalityspring-doc.cn

  • spring-cloud-contract-wiremock: All WireMock related functionalityspring-doc.cn

  • tests: Integration tests for different messaging technologiesspring-doc.cn

Commands

To build the core functionality together with the Maven Plugin, you can run the following command:spring-doc.cn

./mvnw clean install -P integration

Calling that function builds the core, the Maven plugin, and the Gradle plugin.spring-doc.cn

To build only the Gradle Plugin, you can run the following commands:spring-doc.cn

cd spring-cloud-contract-tools/spring-cloud-contract-gradle-plugin
./gradlew clean build

Helpful scripts

We provide a couple of helpful scripts to build the project.spring-doc.cn

To build the project in parallel (by default, it uses four cores, but you can change it), run the following command:spring-doc.cn

./scripts/parallelBuild.sh

To use eight 8 cores, run the following command:spring-doc.cn

CORES=8 ./scripts/parallelBuild.sh

To build the project without any integration tests (by default, this uses one core), run the following command:spring-doc.cn

./scripts/noIntegration.sh

To use eight cores, run the following command:spring-doc.cn

CORES=8 ./scripts/noIntegration.sh

To generate the documentation (for both the root project and the maven plugin), run the following command:spring-doc.cn

./scripts/generateDocs.sh