=== Spring Cloud Contract Stub Runner

One of the issues that you could have encountered while using Spring Cloud Contract Verifier was to pass the generated WireMock JSON stubs from the server side to the client side (or various clients).
 The same takes place in terms of client side generation for messaging.

Copying the JSON files / setting the client side for messaging manually is out of the question.

==== Snapshot versions

Add the additional snapshot repository to your build.gradle to use snapshot versions which are automatically uploaded after every successful build:

[source,groovy,indent=0]
----
repositories {
    (...)
    //Required only for SNAPSHOT versions
    maven { url "https://repo.spring.io/libs-snapshot-local" }
}
----

==== Publishing stubs as JARs

The easiest approach would be to centralize the way stubs are kept. For example you can keep them as JARs in a Maven repository.

===== Gradle

Example of Spring Cloud Contract Verifier Gradle setup:

[source,groovy,indent=0]
----
include::{plugins_path}/spring-cloud-contract-gradle-plugin/src/test/resources/functionalTest/scenarioProject/build.gradle[tags=jar_setup,indent=0]
----

===== Maven

Example of Maven can be found in the https://github.com/spring-cloud/spring-cloud-contract/[Spring Cloud Contract Verifier README]

==== Modules

Spring Cloud Contract Stub Runner comes with a new structure of modules

[source,indent=0]
----
└── spring-cloud-contract-stub-runner
    ├── spring-cloud-contract-stub-runner
    ├── spring-cloud-contract-stub-runner-boot
    ├── spring-cloud-contract-stub-runner-spring
    └── spring-cloud-contract-stub-runner-spring-cloud
----

include::{stubrunner_core_path}/README.adoc[]


==== Common properties for JUnit and Spring

Some of the properties that are repetitive can be set using system properties or configuration properties (for Spring). Here are their names with their default values:

[frame="topbot",options="header"]
|======================
| Property name | Default value | Description
|stubrunner.minPort|10000| Minimal value of a port for a started WireMock with stubs
|stubrunner.maxPort|15000| Minimal value of a port for a started WireMock with stubs
|stubrunner.stubs.repositoryRoot|| Maven repo url. If blank then will call the local maven repo
|stubrunner.stubs.classifier|stubs| Default classifier for the stub artifacts
|stubrunner.workOffline|false| If true then will not contact any remote repositories to download stubs
|stubrunner.stubs.ids|| Array of Ivy notation stubs to download
|======================

===== Stub runner stubs ids

You can provide the stubs to download via the `stubrunner.stubs.ids` system property. They follow the following pattern:

[source,java,indent=0]
----
groupId:artifactId:version:classifier:port
----

`version`, `classifier` and `port` are optional.

* If you don't provide the `port` then a random one will be picked
* If you don't provide the `classifier` then the default one will be taken.
* If you don't provide the `version` then the `+` will be passed and the latest one will be downloaded

Where `port` means the port of the WireMock server.