Split files
This commit is contained in:
33
docs/modules/ROOT/pages/_project-features-contract/java.adoc
Normal file
33
docs/modules/ROOT/pages/_project-features-contract/java.adoc
Normal file
@@ -0,0 +1,33 @@
|
||||
[[contract-java]]
|
||||
= Contract DSL in Java
|
||||
|
||||
To write a contract definition in Java, you need to create a class that implements either the `Supplier<Contract>` interface (for a single contract) or `Supplier<Collection<Contract>>` (for multiple contracts).
|
||||
|
||||
You can also write the contract definitions under `src/test/java` (for example, `src/test/java/contracts`) so that you do not have to modify the classpath of your project. In this case, you have to provide a new location of contract definitions to your Spring Cloud Contract plugin.
|
||||
|
||||
The following example (in both Maven and Gradle) has the contract definitions under `src/test/java`:
|
||||
|
||||
====
|
||||
[source,xml,indent=0,subs="verbatim,attributes",role="primary"]
|
||||
.Maven
|
||||
----
|
||||
<plugin>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-contract-maven-plugin</artifactId>
|
||||
<version>${spring-cloud-contract.version}</version>
|
||||
<extensions>true</extensions>
|
||||
<configuration>
|
||||
<contractsDirectory>src/test/java/contracts</contractsDirectory>
|
||||
</configuration>
|
||||
</plugin>
|
||||
----
|
||||
|
||||
[source,groovy,indent=0,subs="verbatim,attributes",role="secondary"]
|
||||
.Gradle
|
||||
----
|
||||
contracts {
|
||||
contractsDslDir = new File(project.rootDir, "src/test/java/contracts")
|
||||
}
|
||||
----
|
||||
====
|
||||
|
||||
Reference in New Issue
Block a user