Document PublishStubsToScmTask API changes.

This commit is contained in:
Olga Maciaszek-Sharma
2020-05-13 12:58:32 +02:00
parent 8778cf264b
commit ea50b40c57
3 changed files with 35 additions and 1 deletions

View File

@@ -36,7 +36,7 @@ The registered WireMock server is reset after each test class, however, if you n
If you use `@AutoConfigureWireMock`, it registers WireMock JSON stubs from the file
system or classpath (by default, from `file:src/test/resources/mappings`). You can
customize the locations byusing the `stubs` attribute in the annotation, which can be an
customize the locations by using the `stubs` attribute in the annotation, which can be an
Ant-style resource pattern or a directory. In the case of a directory, `**/*.json` is
appended. The following code shows an example:

View File

@@ -718,6 +718,36 @@ the `publish` task is executed
*/
publish.dependsOn("publishStubsToScm")
----
It is also possible to further customise the `publishStubsToScm` gradle task. In the following example,
the task is customised to pick contracts from a local git repository:
[source,groovy,indent=0,role="secondary"]
.gradle
----
publishStubsToScm {
// We want to modify the default set up of the plugin when publish stubs to scm is called
// We want to pick contracts from a Git repository
contractDependency {
stringNotation = "${project.group}:${project.name}:${project.version}"
}
/*
We reuse the contract dependency section to set up the path
to the folder that contains the contract definitions. In our case the
path will be /groupId/artifactId/version/contracts
*/
contractRepository {
repositoryUrl = "git://file://${new File(project.rootDir, "../target")}/contract_empty_git/"
}
// We set the contracts mode to `LOCAL`
contractsMode = "LOCAL"
}
----
IMPORTANT:: Starting with `2.3.0.RELEASE` the `customize{}` closure previously used for the
`publishStubsToScm` customization is no longer available. The settings should be applied directly
within the `publishStubsToScm` closure as in the example above.
====
With such a setup:

View File

@@ -37,6 +37,10 @@ import org.springframework.cloud.contract.stubrunner.spring.StubRunnerProperties
* to the cloned repo with contracts and stubs. Will also
* commit the changes and push them to origin.
*
* NOTE: starting with 2.3.0.RELEASE the <code>customize{}</code> closure previously used for
* {@link PublishStubsToScmTask} customisation is no longer available. The settings should be applied directly
* within the <code>publishStubsToScm</code> closure as in the example above.
*
* @author Marcin Grzejszczak
* @author Anatoliy Balakirev
* @since 2.0.0