Spring Cloud Contract の作り方

Windows でのリポジトリのクローン作成

Windows でこのプロジェクトのクローンを作成しているときに、git リポジトリ内の一部のファイルが Windows の最大ファイルパス制限である 255 文字を超える可能性があり、その結果、リポジトリが誤って (おそらく部分的に) チェックアウトされる可能性があります。

この課題を解決するには、core.longPaths 属性を true に設定するか、Spring Cloud Contract リポジトリのクローンを作成します。

core.longPaths 属性を true に設定するには、次の 3 つのオプションがあります。

  • マシンのすべてのユーザーに対してこれを変更します (これには管理者権限が必要です)。

git config --system core.longPaths true
git clone https://github.com/spring-cloud/spring-cloud-contract.git
  • 現在のユーザー用に変更します (管理者権限は必要ありません)。

git config --global core.longPaths true
git clone https://github.com/spring-cloud/spring-cloud-contract.git
  • このリポジトリのみを変更します (管理権限はリポジトリの複製先によって異なります)。

git clone -c core.longPaths=true https://github.com/spring-cloud/spring-cloud-contract.git
ソースを適切に解決するには、IDE に必要な Groovy プラグインをすべてインストールする必要があります。例: Intellij IDEA では、Eclipse Groovy コンパイラープラグインと GMavenPlus Intellij プラグインの両方が存在すると、プロジェクトが適切にインポートされます。
Spring Cloud Contract は Docker イメージを構築します。忘れずに Docker をインストールしてください。
オフラインモードでビルドを実行する場合は、Maven 3.5.2+ がインストールされている必要があります。

プロジェクト構造

次のリストは、Spring Cloud Contract フォルダー構造を示しています。

├── 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

次のリストでは、プロジェクト構造の各最上位フォルダーについて説明します。

  • config: フォルダーには、Spring Cloud Release Tools 自動リリースプロセスのセットアップが含まれています

  • docker: フォルダーには docker イメージが含まれています

  • scripts: Maven、Gradle を使用して Spring Cloud Contract をビルドおよびテストするためのスクリプトが含まれています

  • specs: Contract DSL の仕様が含まれています。

  • spring-cloud-contract-dependencies: Spring Cloud Contract BOM が含まれています

  • spring-cloud-contract-shade: プラグインによって使用される陰影付きの依存関係

  • spring-cloud-contract-starters: Spring Cloud Contract スターターを含む

  • spring-cloud-contract-spec: 仕様モジュールが含まれています (契約の概念が含まれています)

  • spring-cloud-contract-stub-runner: Stub Runner 関連モジュールが含まれています

  • spring-cloud-contract-stub-runner-boot: Stub Runner Boot アプリが含まれています

  • spring-cloud-contract-toolsSpring Cloud Contract Verifier 用の Gradle および Maven プラグイン

  • spring-cloud-contract-verifierSpring Cloud Contract Verifier 機能の中核

  • spring-cloud-contract-wiremock: WireMock 関連のすべての機能

  • tests: さまざまなメッセージングテクノロジの統合テスト

コマンド

Maven プラグインと一緒にコア機能を構築するには、次のコマンドを実行できます。

./mvnw clean install -P integration

この関数を呼び出すと、コア、Maven プラグイン、および Gradle プラグインがビルドされます。

Gradle プラグインのみをビルドするには、次のコマンドを実行できます。

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

役立つスクリプト

プロジェクトを構築するために役立つスクリプトがいくつか提供されています。

プロジェクトを並行してビルドするには (デフォルトでは 4 つのコアが使用されますが、変更できます)、次のコマンドを実行します。

./scripts/parallelBuild.sh

8 つの 8 コアを使用するには、次のコマンドを実行します。

CORES=8 ./scripts/parallelBuild.sh

統合テストを行わずにプロジェクトをビルドするには (デフォルトでは 1 つのコアを使用します)、次のコマンドを実行します。

./scripts/noIntegration.sh

8 コアを使用するには、次のコマンドを実行します。

CORES=8 ./scripts/noIntegration.sh

ドキュメント (ルートプロジェクトと maven プラグインの両方) を生成するには、次のコマンドを実行します。

./scripts/generateDocs.sh