How to Build Spring Cloud Contract
Cloning the repository on Windows
在 Windows 上克隆此项目时,git 存储库中的一些文件可能会超过 Windows 255 个字符的最大文件路径限制,这可能会导致存储库签出不正确(可能部分签出)。
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.
若要解决此问题,您可以将 core.longPaths
属性设置为 true
或克隆 Spring Cloud Contract 存储库。
To resolve this issue, you can set the core.longPaths
attribute to true
or clone the Spring Cloud Contract repository.
若要将 core.longPaths
属性设置为 true
,您有三个选项:
To set the core.longPaths
attribute to true
, you have three options:
-
Change it for all users of the machine (doing so requires administrator privileges):
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):
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):
git clone -c core.longPaths=true https://github.com/spring-cloud/spring-cloud-contract.git
您需要安装所有必需的 Groovy 插件,以便您的 IDE 正确解析源。例如,在 Intellij IDEA 中,同时安装 Eclipse Groovy 编译器插件和 GMavenPlus Intellij 插件会导致正确导入项目。
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 构建 Docker 镜像。请记住安装 Docker。
Spring Cloud Contract builds Docker images. Remember to have Docker installed.
如果您想在脱机模式下运行构建,则必须安装 Maven 3.5.2+。
If you want to run the build in offline mode, you must have Maven 3.5.2+ installed.
Project structure
以下列表显示了 Spring Cloud Contract 文件夹结构:
The following listing shows the Spring Cloud Contract folder structure:
├── 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:
-
config
: Folder contains setup for Spring Cloud Release Tools automated release process -
docker
: Folder contains docker images -
samples
: Folder contains test samples together with standalone ones used also to build documentation -
scripts
: Contains scripts to build and testSpring Cloud Contract
with Maven, Gradle and standalone projects -
specs
: Contains specifications for the Contract DSL. -
spring-cloud-contract-dependencies
: Contains Spring Cloud Contract BOM -
spring-cloud-contract-shade
: Shaded dependencies used by the plugins -
spring-cloud-contract-starters
: Contains Spring Cloud Contract Starters -
spring-cloud-contract-spec
: Contains specification modules (contains concept of a Contract) -
spring-cloud-contract-stub-runner
: Contains Stub Runner related modules -
spring-cloud-contract-stub-runner-boot
: Contains Stub Runner Boot app -
spring-cloud-contract-tools
: Gradle and Maven plugin forSpring Cloud Contract Verifier
-
spring-cloud-contract-verifier
: Core of theSpring Cloud Contract Verifier
functionality -
spring-cloud-contract-wiremock
: All WireMock related functionality -
tests
: Integration tests for different messaging technologies
Commands
要连同 Maven 插件一起构建核心功能,您可以运行以下命令:
To build the core functionality together with the Maven Plugin, you can run the following command:
./mvnw clean install -P integration
调用该函数会构建核心、Maven 插件和 Gradle 插件,并按正确顺序对独立样本运行端到端测试(适用于 Maven 和 Gradle)。
Calling that function builds the core, the Maven plugin, and the Gradle plugin and runs end-to_end tests on the standalone samples in the proper order (both for Maven and Gradle).
要仅构建 Gradle 插件,您可以运行以下命令:
To build only the Gradle Plugin, you can run the following commands:
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.
要并行构建项目(默认情况下,它使用四个内核,但您可以更改它),请运行以下命令:
To build the project in parallel (by default, it uses four cores, but you can change it), run the following command:
./scripts/parallelBuild.sh
要使用 8 个核心,请运行以下命令:
To use eight 8 cores, run the following command:
CORES=8 ./scripts/parallelBuild.sh
要在不进行任何集成测试的情况下构建项目(默认情况下,这会使用一个核心),请运行以下命令:
To build the project without any integration tests (by default, this uses one core), run the following command:
./scripts/noIntegration.sh
若要使用八个核心,运行以下命令:
To use eight cores, run the following command:
CORES=8 ./scripts/noIntegration.sh
若要生成文档(包括根项目和 Maven 插件),运行以下命令:
To generate the documentation (for both the root project and the maven plugin), run the following command:
./scripts/generateDocs.sh